Remove "virtual" from all lines that have both "virtual" and "override".
[WebKit-https.git] / Source / WebKit2 / WebProcess / WebPage / mac / RemoteLayerTreeDrawingArea.h
1 /*
2  * Copyright (C) 2012-2014 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #ifndef RemoteLayerTreeDrawingArea_h
27 #define RemoteLayerTreeDrawingArea_h
28
29 #include "DrawingArea.h"
30 #include "GraphicsLayerCARemote.h"
31 #include "RemoteLayerTreeTransaction.h"
32 #include <WebCore/GraphicsLayerClient.h>
33 #include <WebCore/Timer.h>
34 #include <atomic>
35 #include <dispatch/dispatch.h>
36 #include <wtf/HashMap.h>
37 #include <wtf/WeakPtr.h>
38
39 namespace WebCore {
40 class PlatformCALayer;
41 }
42
43 namespace IPC {
44 class MessageEncoder;
45 }
46
47 namespace WebKit {
48
49 class RemoteLayerTreeContext;
50 class RemoteLayerTreeDisplayRefreshMonitor;
51
52 class RemoteLayerTreeDrawingArea : public DrawingArea, public WebCore::GraphicsLayerClient {
53     friend class RemoteLayerTreeDisplayRefreshMonitor;
54 public:
55     RemoteLayerTreeDrawingArea(WebPage&, const WebPageCreationParameters&);
56     virtual ~RemoteLayerTreeDrawingArea();
57
58     uint64_t nextTransactionID() const { return m_currentTransactionID + 1; }
59
60     WeakPtr<RemoteLayerTreeDrawingArea> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
61     
62 private:
63     // DrawingArea
64     void setNeedsDisplay() override;
65     void setNeedsDisplayInRect(const WebCore::IntRect&) override;
66     void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta) override;
67     void updateGeometry(const WebCore::IntSize& viewSize, const WebCore::IntSize& layerPosition, bool flushSynchronously, const WebCore::MachSendRight& fencePort) override;
68
69     WebCore::GraphicsLayerFactory* graphicsLayerFactory() override;
70     void setRootCompositingLayer(WebCore::GraphicsLayer*) override;
71     void scheduleCompositingLayerFlush() override;
72     void scheduleCompositingLayerFlushImmediately() override;
73     void attachViewOverlayGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*) override;
74
75     void addTransactionCallbackID(uint64_t callbackID) override;
76
77     RefPtr<WebCore::DisplayRefreshMonitor> createDisplayRefreshMonitor(PlatformDisplayID) override;
78     void willDestroyDisplayRefreshMonitor(WebCore::DisplayRefreshMonitor*);
79
80     bool shouldUseTiledBackingForFrameView(const WebCore::FrameView*) override;
81
82     void updatePreferences(const WebPreferencesStore&) override;
83
84     bool supportsAsyncScrolling() override { return true; }
85
86     void setLayerTreeStateIsFrozen(bool) override;
87
88     void forceRepaint() override;
89     bool forceRepaintAsync(uint64_t) override { return false; }
90
91     void setExposedRect(const WebCore::FloatRect&) override;
92     WebCore::FloatRect exposedRect() const override { return m_scrolledExposedRect; }
93
94     void acceleratedAnimationDidStart(uint64_t layerID, const String& key, double startTime) override;
95     void acceleratedAnimationDidEnd(uint64_t layerID, const String& key) override;
96
97 #if PLATFORM(IOS)
98     WebCore::FloatRect exposedContentRect() const override;
99     void setExposedContentRect(const WebCore::FloatRect&) override;
100 #endif
101
102     void didUpdate() override;
103
104 #if PLATFORM(IOS)
105     void setDeviceScaleFactor(float) override;
106 #endif
107
108     void mainFrameContentSizeChanged(const WebCore::IntSize&) override;
109
110     void viewStateDidChange(WebCore::ViewState::Flags changed, bool wantsDidUpdateViewState, const Vector<uint64_t>& callbackIDs) override;
111
112     bool adjustLayerFlushThrottling(WebCore::LayerFlushThrottleState::Flags) override;
113
114     bool dispatchDidLayout(WebCore::LayoutMilestones) override;
115
116     void updateScrolledExposedRect();
117     void updateRootLayers();
118
119     void flushLayers();
120
121     WebCore::TiledBacking* mainFrameTiledBacking() const;
122
123     uint64_t takeNextTransactionID() { return ++m_currentTransactionID; }
124
125     bool markLayersVolatileImmediatelyIfPossible() override;
126
127     class BackingStoreFlusher : public ThreadSafeRefCounted<BackingStoreFlusher> {
128     public:
129         static Ref<BackingStoreFlusher> create(IPC::Connection*, std::unique_ptr<IPC::MessageEncoder>, Vector<RetainPtr<CGContextRef>>);
130
131         void flush();
132         bool hasFlushed() const { return m_hasFlushed; }
133
134     private:
135         BackingStoreFlusher(IPC::Connection*, std::unique_ptr<IPC::MessageEncoder>, Vector<RetainPtr<CGContextRef>>);
136
137         RefPtr<IPC::Connection> m_connection;
138         std::unique_ptr<IPC::MessageEncoder> m_commitEncoder;
139         Vector<RetainPtr<CGContextRef>> m_contextsToFlush;
140
141         std::atomic<bool> m_hasFlushed;
142     };
143
144     std::unique_ptr<RemoteLayerTreeContext> m_remoteLayerTreeContext;
145     std::unique_ptr<WebCore::GraphicsLayer> m_rootLayer;
146
147     WebCore::IntSize m_viewSize;
148
149     WebCore::FloatRect m_exposedRect;
150     WebCore::FloatRect m_scrolledExposedRect;
151
152     WebCore::Timer m_layerFlushTimer;
153     bool m_isFlushingSuspended;
154     bool m_hasDeferredFlush;
155     bool m_isThrottlingLayerFlushes;
156     bool m_isLayerFlushThrottlingTemporarilyDisabledForInteraction;
157     bool m_isInitialThrottledLayerFlush;
158
159     bool m_waitingForBackingStoreSwap;
160     bool m_hadFlushDeferredWhileWaitingForBackingStoreSwap;
161
162     dispatch_queue_t m_commitQueue;
163     RefPtr<BackingStoreFlusher> m_pendingBackingStoreFlusher;
164
165     HashSet<RemoteLayerTreeDisplayRefreshMonitor*> m_displayRefreshMonitors;
166     HashSet<RemoteLayerTreeDisplayRefreshMonitor*>* m_displayRefreshMonitorsToNotify;
167
168     uint64_t m_currentTransactionID;
169     Vector<RemoteLayerTreeTransaction::TransactionCallbackID> m_pendingCallbackIDs;
170
171     WebCore::LayoutMilestones m_pendingNewlyReachedLayoutMilestones;
172
173     WebCore::GraphicsLayer* m_contentLayer;
174     WebCore::GraphicsLayer* m_viewOverlayRootLayer;
175     
176     WeakPtrFactory<RemoteLayerTreeDrawingArea> m_weakPtrFactory;
177 };
178
179 } // namespace WebKit
180
181 SPECIALIZE_TYPE_TRAITS_DRAWING_AREA(RemoteLayerTreeDrawingArea, DrawingAreaTypeRemoteLayerTree)
182
183 #endif // RemoteLayerTreeDrawingArea_h