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"
40 class WebCompositeAndReadbackAsyncCallback;
41 class WebGraphicsContext3D;
45 struct WebRenderingStats;
46 struct WebSelectionBound;
48 class WebLayerTreeView {
50 virtual ~WebLayerTreeView() { }
52 // Initialization and lifecycle --------------------------------------
54 // Indicates that the compositing surface used by this WebLayerTreeView is ready to use.
55 // A WebLayerTreeView may request a context from its client before the surface is ready,
56 // but it won't attempt to use it.
57 virtual void setSurfaceReady() = 0;
59 // Sets the root of the tree. The root is set by way of the constructor.
60 virtual void setRootLayer(const WebLayer&) = 0;
61 virtual void clearRootLayer() = 0;
64 // View properties ---------------------------------------------------
66 virtual void setViewportSize(const WebSize& deviceViewportSize) = 0;
67 // Gives the viewport size in physical device pixels.
68 virtual WebSize deviceViewportSize() const = 0;
70 virtual void setDeviceScaleFactor(float) = 0;
71 virtual float deviceScaleFactor() const = 0;
73 // Sets the background color for the viewport.
74 virtual void setBackgroundColor(WebColor) = 0;
76 // Sets the background transparency for the viewport. The default is 'false'.
77 virtual void setHasTransparentBackground(bool) = 0;
79 // Sets the overhang gutter bitmap.
80 virtual void setOverhangBitmap(const SkBitmap&) { }
82 // Sets whether this view is visible. In threaded mode, a view that is not visible will not
83 // composite or trigger updateAnimations() or layout() calls until it becomes visible.
84 virtual void setVisible(bool) = 0;
86 // Sets the current page scale factor and minimum / maximum limits. Both limits are initially 1 (no page scale allowed).
87 virtual void setPageScaleFactorAndLimits(float pageScaleFactor, float minimum, float maximum) = 0;
89 // Starts an animation of the page scale to a target scale factor and scroll offset.
90 // If useAnchor is true, destination is a point on the screen that will remain fixed for the duration of the animation.
91 // If useAnchor is false, destination is the final top-left scroll position.
92 virtual void startPageScaleAnimation(const WebPoint& destination, bool useAnchor, float newPageScale, double durationSec) = 0;
94 virtual void heuristicsForGpuRasterizationUpdated(bool) { }
97 // Flow control and scheduling ---------------------------------------
99 // Indicates that an animation needs to be updated.
100 virtual void setNeedsAnimate() = 0;
102 // Indicates whether a commit is pending.
103 virtual bool commitRequested() const = 0;
105 // Relays the end of a fling animation.
106 virtual void didStopFlinging() { }
108 // The caller is responsible for keeping the WebCompositeAndReadbackAsyncCallback
109 // object alive until it is called.
110 virtual void compositeAndReadbackAsync(WebCompositeAndReadbackAsyncCallback*) { }
112 // Blocks until the most recently composited frame has finished rendering on the GPU.
113 // This can have a significant performance impact and should be used with care.
114 virtual void finishAllRendering() = 0;
116 // Prevents updates to layer tree from becoming visible.
117 virtual void setDeferCommits(bool deferCommits) { }
119 // Take responsiblity for this layer's animations, even if this layer hasn't yet
120 // been added to the tree.
121 virtual void registerForAnimations(WebLayer* layer) { }
123 // Identify key layers to the compositor when using the pinch virtual viewport.
124 virtual void registerViewportLayers(
125 const WebLayer* pageScaleLayerLayer,
126 const WebLayer* innerViewportScrollLayer,
127 const WebLayer* outerViewportScrollLayer) { }
128 virtual void clearViewportLayers() { }
130 // Used to update the active selection bounds.
131 // If the (empty) selection is an insertion point, |start| and |end| will be identical with type |Caret|.
132 // If the (non-empty) selection has mixed RTL/LTR text, |start| and |end| may share the same type,
133 // |SelectionLeft| or |SelectionRight|.
134 virtual void registerSelection(const WebSelectionBound& start, const WebSelectionBound& end) { }
135 virtual void clearSelection() { }
137 // Debugging / dangerous ---------------------------------------------
139 // Toggles the FPS counter in the HUD layer
140 virtual void setShowFPSCounter(bool) { }
142 // Toggles the paint rects in the HUD layer
143 virtual void setShowPaintRects(bool) { }
145 // Toggles the debug borders on layers
146 virtual void setShowDebugBorders(bool) { }
148 // Toggles continuous painting
149 virtual void setContinuousPaintingEnabled(bool) { }
151 // Toggles scroll bottleneck rects on the HUD layer
152 virtual void setShowScrollBottleneckRects(bool) { }
157 #endif // WebLayerTreeView_h