2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
26 #ifndef LayerTreeHost_h
27 #define LayerTreeHost_h
29 #include "LayerTreeContext.h"
30 #include <wtf/PassRefPtr.h>
31 #include <wtf/RefCounted.h>
34 class ArgumentDecoder;
45 #if PLATFORM(WIN) && USE(AVFOUNDATION)
46 struct GraphicsDeviceAdapter;
56 struct WindowGeometry;
59 class LayerTreeHost : public RefCounted<LayerTreeHost> {
61 static PassRefPtr<LayerTreeHost> create(WebPage*);
62 virtual ~LayerTreeHost();
64 static bool supportsAcceleratedCompositing();
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;
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;
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; }
85 virtual void pauseRendering() { }
86 virtual void resumeRendering() { }
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&) { }
94 virtual void renderNextFrame() { }
95 virtual void purgeBackingStores() { }
96 virtual void didReceiveLayerTreeCoordinatorMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*) = 0;
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) { }
105 #if ENABLE(TIZEN_ONESHOT_DRAWING_SYNCHRONIZATION)
106 virtual void setNeedsOneShotDrawingSynchronization() = 0;
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) { }
114 #if ENABLE(TIZEN_WEBKIT2)
115 virtual float contentsScaleFactor() const = 0;
118 #if ENABLE(TIZEN_LAYER_FLUSH_THROTTLING)
119 virtual void setDeferLayerFlush(bool) { }
123 virtual void scheduleChildWindowGeometryUpdate(const WindowGeometry&) = 0;
127 virtual void setLayerHostingMode(LayerHostingMode) { }
130 #if PLATFORM(WIN) && USE(AVFOUNDATION)
131 virtual WebCore::GraphicsDeviceAdapter* graphicsDeviceAdapter() const { return 0; }
134 #if USE(UI_SIDE_COMPOSITING)
135 virtual void scheduleAnimation() = 0;
139 explicit LayerTreeHost(WebPage*);
143 #if USE(UI_SIDE_COMPOSITING)
144 bool m_waitingForUIProcess;
148 #if !PLATFORM(WIN) && !PLATFORM(QT) && !ENABLE(TIZEN_WEBKIT2_TILED_AC)
149 inline bool LayerTreeHost::supportsAcceleratedCompositing()
155 } // namespace WebKit
157 #endif // LayerTreeHost_h