2 * Copyright (C) 2011 Google 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
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.
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef WebLayerTreeView_h
27 #define WebLayerTreeView_h
30 #include "WebCommon.h"
31 #include "WebFloatPoint.h"
32 #include "WebNonCopyable.h"
33 #include "WebPrivateOwnPtr.h"
35 #include "WebTopControlsState.h"
41 class WebCompositeAndReadbackAsyncCallback
;
42 class WebCompositorAnimationTimeline
;
44 class WebLayoutAndPaintAsyncCallback
;
46 struct WebSelectionBound
;
50 class WebLayerTreeView
{
52 virtual ~WebLayerTreeView() { }
54 // Initialization and lifecycle --------------------------------------
56 // Sets the root of the tree. The root is set by way of the constructor.
57 virtual void setRootLayer(const WebLayer
&) { }
58 virtual void clearRootLayer() { }
60 virtual void attachCompositorAnimationTimeline(WebCompositorAnimationTimeline
*) { }
61 virtual void detachCompositorAnimationTimeline(WebCompositorAnimationTimeline
*) { }
63 // View properties ---------------------------------------------------
65 virtual void setViewportSize(const WebSize
& deviceViewportSize
) { }
67 virtual void setDeviceScaleFactor(float) { }
68 virtual float deviceScaleFactor() const { return 0; }
70 // Sets the background color for the viewport.
71 virtual void setBackgroundColor(WebColor
) { }
73 // Sets the background transparency for the viewport. The default is 'false'.
74 virtual void setHasTransparentBackground(bool) { }
76 // Sets whether this view is visible. In threaded mode, a view that is not visible will not
77 // composite or trigger updateAnimations() or layout() calls until it becomes visible.
78 virtual void setVisible(bool) { }
80 // Sets the current page scale factor and minimum / maximum limits. Both limits are initially 1 (no page scale allowed).
81 virtual void setPageScaleFactorAndLimits(float pageScaleFactor
, float minimum
, float maximum
) { }
83 // Starts an animation of the page scale to a target scale factor and scroll offset.
84 // If useAnchor is true, destination is a point on the screen that will remain fixed for the duration of the animation.
85 // If useAnchor is false, destination is the final top-left scroll position.
86 virtual void startPageScaleAnimation(const WebPoint
& destination
, bool useAnchor
, float newPageScale
, double durationSec
) { }
88 virtual void heuristicsForGpuRasterizationUpdated(bool) { }
90 // Sets the amount that the top controls are showing, from 0 (hidden) to 1
92 virtual void setTopControlsShownRatio(float) { }
94 // Update top controls permitted and current states
95 virtual void updateTopControlsState(WebTopControlsState constraints
, WebTopControlsState current
, bool animate
) { }
97 // Set top controls height. If |shrinkViewport| is set to true, then Blink shrunk the viewport clip
98 // layers by the top controls height.
99 virtual void setTopControlsHeight(float height
, bool shrinkViewport
) { }
101 // Sets whether to hide the scrollbars of the inner viewport when we are near the minimum page scale.
102 virtual void setHidePinchScrollbarsNearMinScale(bool) { }
104 // Flow control and scheduling ---------------------------------------
106 // Indicates that an animation needs to be updated.
107 // TODO(skyostil): Remove once all callers have migrated to requesting
108 // begin frames or compositor updates.
109 virtual void setNeedsAnimate() { }
111 // Indicates that blink needs a BeginFrame, but that nothing might actually be dirty.
112 virtual void setNeedsBeginFrame() { setNeedsAnimate(); }
114 // Indicates that blink needs a BeginFrame and to update compositor state.
115 virtual void setNeedsCompositorUpdate() { setNeedsAnimate(); }
117 // Relays the end of a fling animation.
118 virtual void didStopFlinging() { }
120 // Run layout and paint of all pending document changes asynchronously.
121 // The caller is resposible for keeping the WebLayoutAndPaintAsyncCallback object
122 // alive until it is called.
123 virtual void layoutAndPaintAsync(WebLayoutAndPaintAsyncCallback
*) { }
125 // The caller is responsible for keeping the WebCompositeAndReadbackAsyncCallback
126 // object alive until it is called.
127 virtual void compositeAndReadbackAsync(WebCompositeAndReadbackAsyncCallback
*) { }
129 // Prevents updates to layer tree from becoming visible.
130 virtual void setDeferCommits(bool deferCommits
) { }
132 // Take responsiblity for this layer's animations, even if this layer hasn't yet
133 // been added to the tree.
134 virtual void registerForAnimations(WebLayer
* layer
) { }
136 // Identify key layers to the compositor when using the pinch virtual viewport.
137 virtual void registerViewportLayers(
138 const WebLayer
* overscrollElasticityLayer
,
139 const WebLayer
* pageScaleLayer
,
140 const WebLayer
* innerViewportScrollLayer
,
141 const WebLayer
* outerViewportScrollLayer
) { }
142 virtual void clearViewportLayers() { }
144 // Used to update the active selection bounds.
145 virtual void registerSelection(const WebSelection
&) { }
146 virtual void clearSelection() { }
148 // Debugging / dangerous ---------------------------------------------
150 virtual int layerTreeId() const { return 0; }
152 // Toggles the FPS counter in the HUD layer
153 virtual void setShowFPSCounter(bool) { }
155 // Toggles the paint rects in the HUD layer
156 virtual void setShowPaintRects(bool) { }
158 // Toggles the debug borders on layers
159 virtual void setShowDebugBorders(bool) { }
161 // Toggles scroll bottleneck rects on the HUD layer
162 virtual void setShowScrollBottleneckRects(bool) { }
167 #endif // WebLayerTreeView_h