[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 1 | // Copyright 2010 The Chromium Authors. All rights reserved. |
[email protected] | 0fb2500 | 2012-10-12 07:20:02 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 4 | |
[email protected] | 8fcbaa37 | 2012-11-05 04:12:41 | [diff] [blame] | 5 | #ifndef CC_LAYER_H_ |
| 6 | #define CC_LAYER_H_ |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 7 | |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 8 | #include <public/WebFilterOperations.h> |
| 9 | #include <string> |
| 10 | #include <vector> |
| 11 | |
[email protected] | a8461d8 | 2012-10-16 21:11:14 | [diff] [blame] | 12 | #include "base/memory/ref_counted.h" |
[email protected] | 52347c84 | 2012-11-02 21:06:20 | [diff] [blame] | 13 | #include "cc/cc_export.h" |
[email protected] | d76806f8 | 2012-12-05 21:41:50 | [diff] [blame^] | 14 | #include "cc/draw_properties.h" |
[email protected] | d50c686 | 2012-10-23 02:08:31 | [diff] [blame] | 15 | #include "cc/layer_animation_controller.h" |
[email protected] | 55a124d0 | 2012-10-22 03:07:13 | [diff] [blame] | 16 | #include "cc/occlusion_tracker.h" |
[email protected] | ac7c7f5 | 2012-11-08 06:26:50 | [diff] [blame] | 17 | #include "cc/region.h" |
[email protected] | a8461d8 | 2012-10-16 21:11:14 | [diff] [blame] | 18 | #include "cc/render_surface.h" |
[email protected] | 1940c4e | 2012-12-04 05:08:15 | [diff] [blame] | 19 | #include "skia/ext/refptr.h" |
[email protected] | ddf9df8 | 2012-10-16 06:52:46 | [diff] [blame] | 20 | #include "third_party/skia/include/core/SkColor.h" |
[email protected] | 1940c4e | 2012-12-04 05:08:15 | [diff] [blame] | 21 | #include "third_party/skia/include/core/SkImageFilter.h" |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 22 | #include "ui/gfx/rect.h" |
| 23 | #include "ui/gfx/rect_f.h" |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 24 | #include "ui/gfx/transform.h" |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 25 | |
| 26 | namespace WebKit { |
| 27 | class WebAnimationDelegate; |
| 28 | class WebLayerScrollClient; |
| 29 | } |
| 30 | |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 31 | namespace cc { |
| 32 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 33 | class ActiveAnimation; |
| 34 | struct AnimationEvent; |
| 35 | class LayerAnimationDelegate; |
| 36 | class LayerImpl; |
| 37 | class LayerTreeHost; |
| 38 | class PriorityCalculator; |
[email protected] | b4da203 | 2012-10-25 21:22:55 | [diff] [blame] | 39 | class ResourceUpdateQueue; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 40 | class ScrollbarLayer; |
| 41 | struct AnimationEvent; |
| 42 | struct RenderingStats; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 43 | |
| 44 | // Base class for composited layers. Special layer types are derived from |
| 45 | // this class. |
[email protected] | 52347c84 | 2012-11-02 21:06:20 | [diff] [blame] | 46 | class CC_EXPORT Layer : public base::RefCounted<Layer>, public LayerAnimationControllerClient { |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 47 | public: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 48 | typedef std::vector<scoped_refptr<Layer> > LayerList; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 49 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 50 | static scoped_refptr<Layer> create(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 51 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 52 | // LayerAnimationControllerClient implementation |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 53 | virtual int id() const OVERRIDE; |
| 54 | virtual void setOpacityFromAnimation(float) OVERRIDE; |
| 55 | virtual float opacity() const OVERRIDE; |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 56 | virtual void setTransformFromAnimation(const gfx::Transform&) OVERRIDE; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 57 | // A layer's transform operates layer space. That is, entirely in logical, |
| 58 | // non-page-scaled pixels (that is, they have page zoom baked in, but not page scale). |
| 59 | // The root layer is a special case -- it operates in physical pixels. |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 60 | virtual const gfx::Transform& transform() const OVERRIDE; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 61 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 62 | Layer* rootLayer(); |
[email protected] | da3a295 | 2012-11-21 04:19:52 | [diff] [blame] | 63 | Layer* parent() { return m_parent; } |
| 64 | const Layer* parent() const { return m_parent; } |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 65 | void addChild(scoped_refptr<Layer>); |
| 66 | void insertChild(scoped_refptr<Layer>, size_t index); |
| 67 | void replaceChild(Layer* reference, scoped_refptr<Layer> newLayer); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 68 | void removeFromParent(); |
| 69 | void removeAllChildren(); |
| 70 | void setChildren(const LayerList&); |
| 71 | |
| 72 | const LayerList& children() const { return m_children; } |
| 73 | |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 74 | void setAnchorPoint(const gfx::PointF&); |
| 75 | gfx::PointF anchorPoint() const { return m_anchorPoint; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 76 | |
| 77 | void setAnchorPointZ(float); |
| 78 | float anchorPointZ() const { return m_anchorPointZ; } |
| 79 | |
[email protected] | c3e0e71 | 2012-11-08 17:49:16 | [diff] [blame] | 80 | virtual void setBackgroundColor(SkColor); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 81 | SkColor backgroundColor() const { return m_backgroundColor; } |
| 82 | |
| 83 | // A layer's bounds are in logical, non-page-scaled pixels (however, the |
| 84 | // root layer's bounds are in physical pixels). |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 85 | void setBounds(const gfx::Size&); |
| 86 | const gfx::Size& bounds() const { return m_bounds; } |
| 87 | virtual gfx::Size contentBounds() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 88 | |
| 89 | void setMasksToBounds(bool); |
| 90 | bool masksToBounds() const { return m_masksToBounds; } |
| 91 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 92 | void setMaskLayer(Layer*); |
[email protected] | da3a295 | 2012-11-21 04:19:52 | [diff] [blame] | 93 | Layer* maskLayer() { return m_maskLayer.get(); } |
| 94 | const Layer* maskLayer() const { return m_maskLayer.get(); } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 95 | |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 96 | virtual void setNeedsDisplayRect(const gfx::RectF& dirtyRect); |
| 97 | void setNeedsDisplay() { setNeedsDisplayRect(gfx::RectF(gfx::PointF(), bounds())); } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 98 | virtual bool needsDisplay() const; |
| 99 | |
| 100 | void setOpacity(float); |
| 101 | bool opacityIsAnimating() const; |
| 102 | |
| 103 | void setFilters(const WebKit::WebFilterOperations&); |
| 104 | const WebKit::WebFilterOperations& filters() const { return m_filters; } |
| 105 | |
[email protected] | 1940c4e | 2012-12-04 05:08:15 | [diff] [blame] | 106 | void setFilter(const skia::RefPtr<SkImageFilter>& filter); |
| 107 | skia::RefPtr<SkImageFilter> filter() const { return m_filter; } |
[email protected] | 4000abf | 2012-10-23 04:45:45 | [diff] [blame] | 108 | |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 109 | // Background filters are filters applied to what is behind this layer, when they are viewed through non-opaque |
| 110 | // regions in this layer. They are used through the WebLayer interface, and are not exposed to HTML. |
| 111 | void setBackgroundFilters(const WebKit::WebFilterOperations&); |
| 112 | const WebKit::WebFilterOperations& backgroundFilters() const { return m_backgroundFilters; } |
| 113 | |
| 114 | virtual void setContentsOpaque(bool); |
| 115 | bool contentsOpaque() const { return m_contentsOpaque; } |
| 116 | |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 117 | void setPosition(const gfx::PointF&); |
| 118 | gfx::PointF position() const { return m_position; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 119 | |
| 120 | void setIsContainerForFixedPositionLayers(bool); |
| 121 | bool isContainerForFixedPositionLayers() const { return m_isContainerForFixedPositionLayers; } |
| 122 | |
| 123 | void setFixedToContainerLayer(bool); |
| 124 | bool fixedToContainerLayer() const { return m_fixedToContainerLayer; } |
| 125 | |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 126 | void setSublayerTransform(const gfx::Transform&); |
| 127 | const gfx::Transform& sublayerTransform() const { return m_sublayerTransform; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 128 | |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 129 | void setTransform(const gfx::Transform&); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 130 | bool transformIsAnimating() const; |
| 131 | |
[email protected] | d76806f8 | 2012-12-05 21:41:50 | [diff] [blame^] | 132 | DrawProperties<Layer, RenderSurface>& drawProperties() { return m_drawProperties; } |
| 133 | const DrawProperties<Layer, RenderSurface>& drawProperties() const { return m_drawProperties; } |
| 134 | |
| 135 | // The following are shortcut accessors to get various information from m_drawProperties |
| 136 | const gfx::Transform& drawTransform() const { return m_drawProperties.target_space_transform; } |
| 137 | const gfx::Transform& screenSpaceTransform() const { return m_drawProperties.screen_space_transform; } |
| 138 | float drawOpacity() const { return m_drawProperties.opacity; } |
| 139 | bool drawOpacityIsAnimating() const { return m_drawProperties.opacity_is_animating; } |
| 140 | bool drawTransformIsAnimating() const { return m_drawProperties.target_space_transform_is_animating; } |
| 141 | bool screenSpaceTransformIsAnimating() const { return m_drawProperties.screen_space_transform_is_animating; } |
| 142 | bool isClipped() const { return m_drawProperties.is_clipped; } |
| 143 | const gfx::Rect& clipRect() const { return m_drawProperties.clip_rect; } |
| 144 | const gfx::Rect& drawableContentRect() const { return m_drawProperties.drawable_content_rect; } |
| 145 | const gfx::Rect& visibleContentRect() const { return m_drawProperties.visible_content_rect; } |
| 146 | Layer* renderTarget() { DCHECK(!m_drawProperties.render_target || m_drawProperties.render_target->renderSurface()); return m_drawProperties.render_target; } |
| 147 | const Layer* renderTarget() const { DCHECK(!m_drawProperties.render_target || m_drawProperties.render_target->renderSurface()); return m_drawProperties.render_target; } |
| 148 | RenderSurface* renderSurface() const { return m_drawProperties.render_surface.get(); } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 149 | |
[email protected] | c9c1ebe | 2012-11-05 20:46:13 | [diff] [blame] | 150 | void setScrollOffset(gfx::Vector2d); |
| 151 | gfx::Vector2d scrollOffset() const { return m_scrollOffset; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 152 | |
[email protected] | c9c1ebe | 2012-11-05 20:46:13 | [diff] [blame] | 153 | void setMaxScrollOffset(gfx::Vector2d); |
| 154 | gfx::Vector2d maxScrollOffset() const { return m_maxScrollOffset; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 155 | |
| 156 | void setScrollable(bool); |
| 157 | bool scrollable() const { return m_scrollable; } |
| 158 | |
| 159 | void setShouldScrollOnMainThread(bool); |
| 160 | bool shouldScrollOnMainThread() const { return m_shouldScrollOnMainThread; } |
| 161 | |
| 162 | void setHaveWheelEventHandlers(bool); |
| 163 | bool haveWheelEventHandlers() const { return m_haveWheelEventHandlers; } |
| 164 | |
| 165 | void setNonFastScrollableRegion(const Region&); |
| 166 | void setNonFastScrollableRegionChanged() { m_nonFastScrollableRegionChanged = true; } |
| 167 | const Region& nonFastScrollableRegion() const { return m_nonFastScrollableRegion; } |
| 168 | |
[email protected] | 23d56be | 2012-11-08 00:33:34 | [diff] [blame] | 169 | void setTouchEventHandlerRegion(const Region&); |
| 170 | void setTouchEventHandlerRegionChanged() { m_touchEventHandlerRegionChanged = true; } |
| 171 | const Region& touchEventHandlerRegion() const { return m_touchEventHandlerRegion; } |
| 172 | |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 173 | void setLayerScrollClient(WebKit::WebLayerScrollClient* layerScrollClient) { m_layerScrollClient = layerScrollClient; } |
| 174 | |
| 175 | void setDrawCheckerboardForMissingTiles(bool); |
| 176 | bool drawCheckerboardForMissingTiles() const { return m_drawCheckerboardForMissingTiles; } |
| 177 | |
| 178 | bool forceRenderSurface() const { return m_forceRenderSurface; } |
| 179 | void setForceRenderSurface(bool); |
| 180 | |
[email protected] | c9c1ebe | 2012-11-05 20:46:13 | [diff] [blame] | 181 | gfx::Vector2d scrollDelta() const { return gfx::Vector2d(); } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 182 | |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 183 | void setImplTransform(const gfx::Transform&); |
| 184 | const gfx::Transform& implTransform() const { return m_implTransform; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 185 | |
| 186 | void setDoubleSided(bool); |
| 187 | bool doubleSided() const { return m_doubleSided; } |
| 188 | |
| 189 | void setPreserves3D(bool preserve3D) { m_preserves3D = preserve3D; } |
| 190 | bool preserves3D() const { return m_preserves3D; } |
| 191 | |
| 192 | void setUseParentBackfaceVisibility(bool useParentBackfaceVisibility) { m_useParentBackfaceVisibility = useParentBackfaceVisibility; } |
| 193 | bool useParentBackfaceVisibility() const { return m_useParentBackfaceVisibility; } |
| 194 | |
[email protected] | ed22978e | 2012-11-15 05:37:44 | [diff] [blame] | 195 | void setUseLCDText(bool); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 196 | bool useLCDText() const { return m_useLCDText; } |
| 197 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 198 | virtual void setLayerTreeHost(LayerTreeHost*); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 199 | |
| 200 | bool hasContributingDelegatedRenderPasses() const { return false; } |
| 201 | |
| 202 | void setIsDrawable(bool); |
| 203 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 204 | void setReplicaLayer(Layer*); |
[email protected] | da3a295 | 2012-11-21 04:19:52 | [diff] [blame] | 205 | Layer* replicaLayer() { return m_replicaLayer.get(); } |
| 206 | const Layer* replicaLayer() const { return m_replicaLayer.get(); } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 207 | |
[email protected] | ec05af5 | 2012-11-21 23:07:00 | [diff] [blame] | 208 | bool hasMask() const { return !!m_maskLayer; } |
| 209 | bool hasReplica() const { return !!m_replicaLayer; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 210 | bool replicaHasMask() const { return m_replicaLayer && (m_maskLayer || m_replicaLayer->m_maskLayer); } |
| 211 | |
| 212 | // These methods typically need to be overwritten by derived classes. |
| 213 | virtual bool drawsContent() const; |
[email protected] | b4da203 | 2012-10-25 21:22:55 | [diff] [blame] | 214 | virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats&) { } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 215 | virtual bool needMoreUpdates(); |
| 216 | virtual void setIsMask(bool) { } |
| 217 | virtual void bindContentsTexture() { } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 218 | |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 219 | void setDebugName(const std::string&); |
| 220 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 221 | virtual void pushPropertiesTo(LayerImpl*); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 222 | |
[email protected] | d76806f8 | 2012-12-05 21:41:50 | [diff] [blame^] | 223 | void clearRenderSurface() { m_drawProperties.render_surface.reset(); } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 224 | void createRenderSurface(); |
| 225 | |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 226 | // The contentsScale converts from logical, non-page-scaled pixels to target pixels. |
| 227 | // The contentsScale is 1 for the root layer as it is already in physical pixels. |
[email protected] | 904e913 | 2012-11-01 00:12:47 | [diff] [blame] | 228 | // By default contentsScale is forced to be 1 except for subclasses of ContentsScalingLayer. |
| 229 | virtual float contentsScaleX() const; |
| 230 | virtual float contentsScaleY() const; |
| 231 | virtual void setContentsScale(float contentsScale) { } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 232 | |
[email protected] | 518ee58 | 2012-10-24 18:29:44 | [diff] [blame] | 233 | // The scale at which contents should be rastered, to match the scale at |
| 234 | // which they will drawn to the screen. This scale is a component of the |
| 235 | // contentsScale() but does not include page/device scale factors. |
| 236 | float rasterScale() const { return m_rasterScale; } |
| 237 | void setRasterScale(float scale); |
| 238 | |
| 239 | // When true, the rasterScale() will be set by the compositor. If false, it |
| 240 | // will use whatever value is given to it by the embedder. |
| 241 | bool automaticallyComputeRasterScale() { return m_automaticallyComputeRasterScale; } |
| 242 | void setAutomaticallyComputeRasterScale(bool); |
| 243 | |
| 244 | void forceAutomaticRasterScaleToBeRecomputed(); |
| 245 | |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 246 | // When true, the layer's contents are not scaled by the current page scale factor. |
| 247 | // setBoundsContainPageScale recursively sets the value on all child layers. |
| 248 | void setBoundsContainPageScale(bool); |
| 249 | bool boundsContainPageScale() const { return m_boundsContainPageScale; } |
| 250 | |
[email protected] | 498ec6e0e | 2012-11-30 18:24:57 | [diff] [blame] | 251 | // Returns 0 if none of the layer's descendants has content to draw, |
| 252 | // 1 if exactly one descendant has content to draw, or a number >1 |
| 253 | // (but necessary the exact number of descendants) otherwise. |
| 254 | int descendantsDrawContent(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 255 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 256 | LayerTreeHost* layerTreeHost() const { return m_layerTreeHost; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 257 | |
| 258 | // Set the priority of all desired textures in this layer. |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 259 | virtual void setTexturePriorities(const PriorityCalculator&) { } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 260 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 261 | bool addAnimation(scoped_ptr<ActiveAnimation>); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 262 | void pauseAnimation(int animationId, double timeOffset); |
| 263 | void removeAnimation(int animationId); |
| 264 | |
| 265 | void suspendAnimations(double monotonicTime); |
| 266 | void resumeAnimations(double monotonicTime); |
| 267 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 268 | LayerAnimationController* layerAnimationController() { return m_layerAnimationController.get(); } |
| 269 | void setLayerAnimationController(scoped_ptr<LayerAnimationController>); |
| 270 | scoped_ptr<LayerAnimationController> releaseLayerAnimationController(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 271 | |
| 272 | void setLayerAnimationDelegate(WebKit::WebAnimationDelegate* layerAnimationDelegate) { m_layerAnimationDelegate = layerAnimationDelegate; } |
| 273 | |
| 274 | bool hasActiveAnimation() const; |
| 275 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 276 | virtual void notifyAnimationStarted(const AnimationEvent&, double wallClockTime); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 277 | virtual void notifyAnimationFinished(double wallClockTime); |
| 278 | |
| 279 | virtual Region visibleContentOpaqueRegion() const; |
| 280 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 281 | virtual ScrollbarLayer* toScrollbarLayer(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 282 | |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 283 | gfx::Rect layerRectToContentRect(const gfx::RectF& layerRect) const; |
[email protected] | 904e913 | 2012-11-01 00:12:47 | [diff] [blame] | 284 | |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 285 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 286 | friend class LayerImpl; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 287 | friend class TreeSynchronizer; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 288 | virtual ~Layer(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 289 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 290 | Layer(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 291 | |
| 292 | void setNeedsCommit(); |
[email protected] | 0bf94724 | 2012-12-04 04:25:11 | [diff] [blame] | 293 | void setNeedsFullTreeSync(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 294 | |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 295 | // This flag is set when layer need repainting/updating. |
| 296 | bool m_needsDisplay; |
| 297 | |
| 298 | // Tracks whether this layer may have changed stacking order with its siblings. |
| 299 | bool m_stackingOrderChanged; |
| 300 | |
| 301 | // The update rect is the region of the compositor resource that was actually updated by the compositor. |
| 302 | // For layers that may do updating outside the compositor's control (i.e. plugin layers), this information |
| 303 | // is not available and the update rect will remain empty. |
| 304 | // Note this rect is in layer space (not content space). |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 305 | gfx::RectF m_updateRect; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 306 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 307 | scoped_refptr<Layer> m_maskLayer; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 308 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 309 | // Constructs a LayerImpl of the correct runtime type for this Layer type. |
| 310 | virtual scoped_ptr<LayerImpl> createLayerImpl(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 311 | int m_layerId; |
| 312 | |
| 313 | private: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 314 | friend class base::RefCounted<Layer>; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 315 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 316 | void setParent(Layer*); |
| 317 | bool hasAncestor(Layer*) const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 318 | bool descendantIsFixedToContainerLayer() const; |
| 319 | |
| 320 | size_t numChildren() const { return m_children.size(); } |
| 321 | |
| 322 | // Returns the index of the child or -1 if not found. |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 323 | int indexOfChild(const Layer*); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 324 | |
| 325 | // This should only be called from removeFromParent. |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 326 | void removeChild(Layer*); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 327 | |
| 328 | LayerList m_children; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 329 | Layer* m_parent; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 330 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 331 | // Layer instances have a weak pointer to their LayerTreeHost. |
| 332 | // This pointer value is nil when a Layer is not in a tree and is |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 333 | // updated via setLayerTreeHost() if a layer moves between trees. |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 334 | LayerTreeHost* m_layerTreeHost; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 335 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 336 | scoped_ptr<LayerAnimationController> m_layerAnimationController; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 337 | |
| 338 | // Layer properties. |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 339 | gfx::Size m_bounds; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 340 | |
[email protected] | c9c1ebe | 2012-11-05 20:46:13 | [diff] [blame] | 341 | gfx::Vector2d m_scrollOffset; |
| 342 | gfx::Vector2d m_maxScrollOffset; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 343 | bool m_scrollable; |
| 344 | bool m_shouldScrollOnMainThread; |
| 345 | bool m_haveWheelEventHandlers; |
| 346 | Region m_nonFastScrollableRegion; |
| 347 | bool m_nonFastScrollableRegionChanged; |
[email protected] | 23d56be | 2012-11-08 00:33:34 | [diff] [blame] | 348 | Region m_touchEventHandlerRegion; |
| 349 | bool m_touchEventHandlerRegionChanged; |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 350 | gfx::PointF m_position; |
| 351 | gfx::PointF m_anchorPoint; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 352 | SkColor m_backgroundColor; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 353 | std::string m_debugName; |
| 354 | float m_opacity; |
[email protected] | 1940c4e | 2012-12-04 05:08:15 | [diff] [blame] | 355 | skia::RefPtr<SkImageFilter> m_filter; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 356 | WebKit::WebFilterOperations m_filters; |
| 357 | WebKit::WebFilterOperations m_backgroundFilters; |
| 358 | float m_anchorPointZ; |
| 359 | bool m_isContainerForFixedPositionLayers; |
| 360 | bool m_fixedToContainerLayer; |
| 361 | bool m_isDrawable; |
| 362 | bool m_masksToBounds; |
| 363 | bool m_contentsOpaque; |
| 364 | bool m_doubleSided; |
| 365 | bool m_useLCDText; |
| 366 | bool m_preserves3D; |
| 367 | bool m_useParentBackfaceVisibility; |
| 368 | bool m_drawCheckerboardForMissingTiles; |
| 369 | bool m_forceRenderSurface; |
| 370 | |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 371 | gfx::Transform m_transform; |
| 372 | gfx::Transform m_sublayerTransform; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 373 | |
| 374 | // Replica layer used for reflections. |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 375 | scoped_refptr<Layer> m_replicaLayer; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 376 | |
| 377 | // Transient properties. |
[email protected] | 518ee58 | 2012-10-24 18:29:44 | [diff] [blame] | 378 | float m_rasterScale; |
| 379 | bool m_automaticallyComputeRasterScale; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 380 | bool m_boundsContainPageScale; |
| 381 | |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 382 | gfx::Transform m_implTransform; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 383 | |
| 384 | WebKit::WebAnimationDelegate* m_layerAnimationDelegate; |
| 385 | WebKit::WebLayerScrollClient* m_layerScrollClient; |
[email protected] | d76806f8 | 2012-12-05 21:41:50 | [diff] [blame^] | 386 | |
| 387 | DrawProperties<Layer, RenderSurface> m_drawProperties; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 388 | }; |
| 389 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 390 | void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped_refptr<Layer> >::iterator, void*); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 391 | |
[email protected] | ddf9df8 | 2012-10-16 06:52:46 | [diff] [blame] | 392 | } // namespace cc |
| 393 | |
[email protected] | 8fcbaa37 | 2012-11-05 04:12:41 | [diff] [blame] | 394 | #endif // CC_LAYER_H_ |