d6306cca3c43bc1c1b9df59a7cbf4c64817544ae
[WebKit-https.git] / Source / WebKit / WebProcess / WebPage / CoordinatedGraphics / CoordinatedLayerTreeHost.h
1 /*
2     Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
3     Copyright (C) 2013 Company 100, Inc.
4
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Library General Public
7     License as published by the Free Software Foundation; either
8     version 2 of the License, or (at your option) any later version.
9
10     This library is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13     Library General Public License for more details.
14
15     You should have received a copy of the GNU Library General Public License
16     along with this library; see the file COPYING.LIB.  If not, write to
17     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18     Boston, MA 02110-1301, USA.
19 */
20
21 #ifndef CoordinatedLayerTreeHost_h
22 #define CoordinatedLayerTreeHost_h
23
24 #if USE(COORDINATED_GRAPHICS)
25
26 #include "CompositingCoordinator.h"
27 #include "LayerTreeHost.h"
28 #include "OptionalCallbackID.h"
29 #include <wtf/RunLoop.h>
30
31 namespace WebCore {
32 class GraphicsLayerFactory;
33 }
34
35 namespace WebKit {
36
37 class WebPage;
38
39 class CoordinatedLayerTreeHost : public LayerTreeHost, public CompositingCoordinator::Client
40 {
41 public:
42     static Ref<CoordinatedLayerTreeHost> create(WebPage&);
43     virtual ~CoordinatedLayerTreeHost();
44
45 protected:
46     explicit CoordinatedLayerTreeHost(WebPage&);
47
48     void scheduleLayerFlush() override;
49     void cancelPendingLayerFlush() override;
50     void setRootCompositingLayer(WebCore::GraphicsLayer*) override;
51     void invalidate() override;
52
53     void forceRepaint() override;
54     bool forceRepaintAsync(CallbackID) override;
55     void sizeDidChange(const WebCore::IntSize& newSize) override;
56
57     void deviceOrPageScaleFactorChanged() override;
58     void pageBackgroundTransparencyChanged() override;
59
60     void clearUpdateAtlases() override;
61
62     void setVisibleContentsRect(const WebCore::FloatRect&, const WebCore::FloatPoint&);
63     void renderNextFrame();
64
65     WebCore::GraphicsLayerFactory* graphicsLayerFactory() override;
66
67     void scheduleAnimation() override;
68
69     void setViewOverlayRootLayer(WebCore::GraphicsLayer*) override;
70
71     // CompositingCoordinator::Client
72     void didFlushRootLayer(const WebCore::FloatRect& visibleContentRect) override;
73     void notifyFlushRequired() override { scheduleLayerFlush(); };
74     void commitSceneState(const WebCore::CoordinatedGraphicsState&) override;
75     void releaseUpdateAtlases(const Vector<uint32_t>&) override { };
76
77 private:
78     void layerFlushTimerFired();
79
80     CompositingCoordinator m_coordinator;
81     bool m_isWaitingForRenderer { false };
82     bool m_scheduledWhileWaitingForRenderer { false };
83     struct {
84         OptionalCallbackID callbackID;
85         bool needsFreshFlush { false };
86     } m_forceRepaintAsync;
87     RunLoop::Timer<CoordinatedLayerTreeHost> m_layerFlushTimer;
88 };
89
90 } // namespace WebKit
91
92 #endif // USE(COORDINATED_GRAPHICS)
93
94 #endif // CoordinatedLayerTreeHost_h