Merge "[Release] Webkit2-efl-123997_0.11.75" into tizen_2.2
[framework/web/webkit-efl.git] / Source / WebKit2 / WebProcess / WebPage / LayerTreeHost.h
1 /*
2  * Copyright (C) 2011, 2012 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 LayerTreeHost_h
27 #define LayerTreeHost_h
28
29 #include "LayerTreeContext.h"
30 #include <wtf/PassRefPtr.h>
31 #include <wtf/RefCounted.h>
32
33 namespace CoreIPC {
34 class ArgumentDecoder;
35 class Connection;
36 class MessageID;
37 }
38
39 namespace WebCore {
40 class FloatPoint;
41 class IntRect;
42 class IntSize;
43 class GraphicsLayer;
44
45 #if PLATFORM(WIN) && USE(AVFOUNDATION)
46 struct GraphicsDeviceAdapter;
47 #endif
48 }
49
50 namespace WebKit {
51
52 class UpdateInfo;
53 class WebPage;
54
55 #if PLATFORM(WIN)
56 struct WindowGeometry;
57 #endif
58
59 class LayerTreeHost : public RefCounted<LayerTreeHost> {
60 public:
61     static PassRefPtr<LayerTreeHost> create(WebPage*);
62     virtual ~LayerTreeHost();
63
64     static bool supportsAcceleratedCompositing();
65
66     virtual const LayerTreeContext& layerTreeContext() = 0;
67     virtual void scheduleLayerFlush() = 0;
68     virtual void setLayerFlushSchedulingEnabled(bool) = 0;
69     virtual void setShouldNotifyAfterNextScheduledLayerFlush(bool) = 0;
70     virtual void setRootCompositingLayer(WebCore::GraphicsLayer*) = 0;
71     virtual void invalidate() = 0;
72
73     virtual void setNonCompositedContentsNeedDisplay(const WebCore::IntRect&) = 0;
74     virtual void scrollNonCompositedContents(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset) = 0;
75     virtual void forceRepaint() = 0;
76     virtual void sizeDidChange(const WebCore::IntSize& newSize) = 0;
77     virtual void deviceScaleFactorDidChange() = 0;
78
79     virtual void didInstallPageOverlay() = 0;
80     virtual void didUninstallPageOverlay() = 0;
81     virtual void setPageOverlayNeedsDisplay(const WebCore::IntRect&) = 0;
82     virtual void setPageOverlayOpacity(float) { }
83     virtual bool pageOverlayShouldApplyFadeWhenPainting() const { return true; }
84
85     virtual void pauseRendering() { }
86     virtual void resumeRendering() { }
87
88 #if USE(UI_SIDE_COMPOSITING)
89     virtual void setVisibleContentsRect(const WebCore::IntRect&, float scale, const WebCore::FloatPoint&) { }
90     virtual void setVisibleContentsRectForLayer(int layerID, const WebCore::IntRect&) { }
91 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
92     virtual void setVisibleContentsRectAndTrajectoryVectorForLayer(int layerID, const WebCore::IntRect&, const WebCore::FloatPoint&) { }
93 #endif
94     virtual void renderNextFrame() { }
95     virtual void purgeBackingStores() { }
96     virtual void didReceiveLayerTreeCoordinatorMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*) = 0;
97
98 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
99     virtual void freePlatformSurface(int layerID, int platformSurfaceId) { }
100     virtual void freePlatformSurfaceByTileID(int tileID) { }
101     virtual void removePlatformSurface(int layerID, int platformSurfaceId) { }
102 #endif
103 #endif
104
105 #if ENABLE(TIZEN_ONESHOT_DRAWING_SYNCHRONIZATION)
106     virtual void setNeedsOneShotDrawingSynchronization() = 0;
107 #endif
108
109 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
110     virtual void addOrUpdateScrollingLayer(WebCore::GraphicsLayer* scrollingLayer, WebCore::GraphicsLayer* contentsLayer, const WebCore::IntSize& scrollSize) { }
111     virtual void removeScrollingLayer(WebCore::GraphicsLayer* scrollingLayer, WebCore::GraphicsLayer* contentsLayer) { }
112 #endif
113
114 #if ENABLE(TIZEN_WEBKIT2)
115     virtual float contentsScaleFactor() const = 0;
116 #endif
117
118 #if ENABLE(TIZEN_LAYER_FLUSH_THROTTLING)
119     virtual void setDeferLayerFlush(bool) { }
120 #endif
121
122 #if PLATFORM(WIN)
123     virtual void scheduleChildWindowGeometryUpdate(const WindowGeometry&) = 0;
124 #endif
125
126 #if PLATFORM(MAC)
127     virtual void setLayerHostingMode(LayerHostingMode) { }
128 #endif
129
130 #if PLATFORM(WIN) && USE(AVFOUNDATION)
131     virtual WebCore::GraphicsDeviceAdapter* graphicsDeviceAdapter() const { return 0; }
132 #endif
133
134 #if USE(UI_SIDE_COMPOSITING)
135     virtual void scheduleAnimation() = 0;
136 #endif
137
138 protected:
139     explicit LayerTreeHost(WebPage*);
140
141     WebPage* m_webPage;
142
143 #if USE(UI_SIDE_COMPOSITING)
144     bool m_waitingForUIProcess;
145 #endif
146 };
147
148 #if !PLATFORM(WIN) && !PLATFORM(QT) && !ENABLE(TIZEN_WEBKIT2_TILED_AC)
149 inline bool LayerTreeHost::supportsAcceleratedCompositing()
150 {
151     return true;
152 }
153 #endif
154
155 } // namespace WebKit
156
157 #endif // LayerTreeHost_h