Final part of "sync" to "flush" renaming
[WebKit-https.git] / Source / WebKit2 / WebProcess / WebPage / gtk / LayerTreeHostGtk.h
1 /*
2  * Copyright (C) 2011 Apple Inc. All rights reserved.
3  * Copyright (C) 2012 Igalia S.L.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24  * THE POSSIBILITY OF SUCH DAMAGE.
25  */
26
27 #ifndef LayerTreeHostGtk_h
28 #define LayerTreeHostGtk_h
29
30 #if USE(TEXTURE_MAPPER_GL)
31
32 #include "LayerTreeContext.h"
33 #include "LayerTreeHost.h"
34 #include "TextureMapperLayer.h"
35 #include <WebCore/GLContext.h>
36 #include <WebCore/GraphicsLayerClient.h>
37 #include <wtf/OwnPtr.h>
38
39 namespace WebKit {
40
41 class LayerTreeHostGtk : public LayerTreeHost, WebCore::GraphicsLayerClient {
42 public:
43     static PassRefPtr<LayerTreeHostGtk> create(WebPage*);
44     virtual ~LayerTreeHostGtk();
45
46 protected:
47     explicit LayerTreeHostGtk(WebPage*);
48
49     WebCore::GraphicsLayer* rootLayer() const { return m_rootLayer.get(); }
50
51     void initialize();
52
53     // LayerTreeHost.
54     virtual void invalidate();
55     virtual void sizeDidChange(const WebCore::IntSize& newSize);
56     virtual void deviceScaleFactorDidChange();
57     virtual void forceRepaint();
58     virtual void setRootCompositingLayer(WebCore::GraphicsLayer*);
59     virtual void scheduleLayerFlush();
60     virtual void setLayerFlushSchedulingEnabled(bool layerFlushingEnabled);
61
62 private:
63     // LayerTreeHost.
64     virtual const LayerTreeContext& layerTreeContext();
65     virtual void setShouldNotifyAfterNextScheduledLayerFlush(bool);
66
67     virtual void setNonCompositedContentsNeedDisplay(const WebCore::IntRect&);
68     virtual void scrollNonCompositedContents(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
69
70     virtual void didInstallPageOverlay();
71     virtual void didUninstallPageOverlay();
72     virtual void setPageOverlayNeedsDisplay(const WebCore::IntRect&);
73
74     virtual bool flushPendingLayerChanges();
75
76     // GraphicsLayerClient
77     virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time);
78     virtual void notifyFlushRequired(const WebCore::GraphicsLayer*);
79     virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect);
80     virtual bool showDebugBorders(const WebCore::GraphicsLayer*) const;
81     virtual bool showRepaintCounter(const WebCore::GraphicsLayer*) const;
82     virtual void didCommitChangesForLayer(const WebCore::GraphicsLayer*) const { }
83
84     void createPageOverlayLayer();
85     void destroyPageOverlayLayer();
86
87     enum CompositePurpose { ForResize, NotForResize };
88     void compositeLayersToContext(CompositePurpose = NotForResize);
89
90     void flushAndRenderLayers();
91     void cancelPendingLayerFlush();
92
93     void layerFlushTimerFired();
94     static gboolean layerFlushTimerFiredCallback(LayerTreeHostGtk*);
95
96     WebCore::GLContext* glContext();
97
98     LayerTreeContext m_layerTreeContext;
99     bool m_isValid;
100     bool m_notifyAfterScheduledLayerFlush;
101     OwnPtr<WebCore::GraphicsLayer> m_rootLayer;
102     OwnPtr<WebCore::GraphicsLayer> m_nonCompositedContentLayer;
103     OwnPtr<WebCore::GraphicsLayer> m_pageOverlayLayer;
104     OwnPtr<WebCore::TextureMapper> m_textureMapper;
105     OwnPtr<WebCore::GLContext> m_context;
106     bool m_layerFlushSchedulingEnabled;
107     unsigned m_layerFlushTimerCallbackId;
108 };
109
110 } // namespace WebKit
111
112 #endif
113
114 #endif // LayerTreeHostGtk_h