OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_LAYER_IMPL_H_ | 5 #ifndef CC_LAYER_IMPL_H_ |
6 #define CC_LAYER_IMPL_H_ | 6 #define CC_LAYER_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 // LayerAnimationValueObserver implementation. | 61 // LayerAnimationValueObserver implementation. |
62 virtual void OnOpacityAnimated(float) OVERRIDE; | 62 virtual void OnOpacityAnimated(float) OVERRIDE; |
63 virtual void OnTransformAnimated(const gfx::Transform&) OVERRIDE; | 63 virtual void OnTransformAnimated(const gfx::Transform&) OVERRIDE; |
64 virtual bool IsActive() const OVERRIDE; | 64 virtual bool IsActive() const OVERRIDE; |
65 | 65 |
66 // Tree structure. | 66 // Tree structure. |
67 LayerImpl* parent() { return m_parent; } | 67 LayerImpl* parent() { return m_parent; } |
68 const LayerImpl* parent() const { return m_parent; } | 68 const LayerImpl* parent() const { return m_parent; } |
69 const LayerList& children() const { return m_children; } | 69 const LayerList& children() const { return m_children; } |
| 70 LayerList& children() { return m_children; } |
| 71 LayerImpl* childAt(size_t index) const; |
70 void addChild(scoped_ptr<LayerImpl>); | 72 void addChild(scoped_ptr<LayerImpl>); |
71 scoped_ptr<LayerImpl> removeChild(LayerImpl* child); | 73 scoped_ptr<LayerImpl> removeChild(LayerImpl* child); |
72 void removeAllChildren(); | 74 void removeAllChildren(); |
| 75 void setParent(LayerImpl* parent) { m_parent = parent; } |
| 76 void clearChildList(); // Warning: This does not preserve tree structure inv
ariants. |
73 | 77 |
74 void setMaskLayer(scoped_ptr<LayerImpl>); | 78 void setMaskLayer(scoped_ptr<LayerImpl>); |
75 LayerImpl* maskLayer() { return m_maskLayer.get(); } | 79 LayerImpl* maskLayer() { return m_maskLayer.get(); } |
76 const LayerImpl* maskLayer() const { return m_maskLayer.get(); } | 80 const LayerImpl* maskLayer() const { return m_maskLayer.get(); } |
| 81 scoped_ptr<LayerImpl> takeMaskLayer(); |
77 | 82 |
78 void setReplicaLayer(scoped_ptr<LayerImpl>); | 83 void setReplicaLayer(scoped_ptr<LayerImpl>); |
79 LayerImpl* replicaLayer() { return m_replicaLayer.get(); } | 84 LayerImpl* replicaLayer() { return m_replicaLayer.get(); } |
80 const LayerImpl* replicaLayer() const { return m_replicaLayer.get(); } | 85 const LayerImpl* replicaLayer() const { return m_replicaLayer.get(); } |
| 86 scoped_ptr<LayerImpl> takeReplicaLayer(); |
81 | 87 |
82 bool hasMask() const { return m_maskLayer; } | 88 bool hasMask() const { return m_maskLayer; } |
83 bool hasReplica() const { return m_replicaLayer; } | 89 bool hasReplica() const { return m_replicaLayer; } |
84 bool replicaHasMask() const { return m_replicaLayer && (m_maskLayer || m_rep
licaLayer->m_maskLayer); } | 90 bool replicaHasMask() const { return m_replicaLayer && (m_maskLayer || m_rep
licaLayer->m_maskLayer); } |
85 | 91 |
86 LayerTreeImpl* layerTreeImpl() const { return m_layerTreeImpl; } | 92 LayerTreeImpl* layerTreeImpl() const { return m_layerTreeImpl; } |
87 | 93 |
88 scoped_ptr<SharedQuadState> createSharedQuadState() const; | 94 scoped_ptr<SharedQuadState> createSharedQuadState() const; |
89 // willDraw must be called before appendQuads. If willDraw is called, | 95 // willDraw must be called before appendQuads. If willDraw is called, |
90 // didDraw is guaranteed to be called before another willDraw or before | 96 // didDraw is guaranteed to be called before another willDraw or before |
91 // the layer is destroyed. To enforce this, any class that overrides | 97 // the layer is destroyed. To enforce this, any class that overrides |
92 // willDraw/didDraw must call the base class version. | 98 // willDraw/didDraw must call the base class version. |
93 virtual void willDraw(ResourceProvider*); | 99 virtual void willDraw(ResourceProvider*); |
94 virtual void appendQuads(QuadSink&, AppendQuadsData&) { } | 100 virtual void appendQuads(QuadSink&, AppendQuadsData&) { } |
95 virtual void didDraw(ResourceProvider*); | 101 virtual void didDraw(ResourceProvider*); |
96 | 102 |
97 virtual ResourceProvider::ResourceId contentsResourceId() const; | 103 virtual ResourceProvider::ResourceId contentsResourceId() const; |
98 | 104 |
99 virtual bool hasDelegatedContent() const; | 105 virtual bool hasDelegatedContent() const; |
100 virtual bool hasContributingDelegatedRenderPasses() const; | 106 virtual bool hasContributingDelegatedRenderPasses() const; |
101 virtual RenderPass::Id firstContributingRenderPassId() const; | 107 virtual RenderPass::Id firstContributingRenderPassId() const; |
102 virtual RenderPass::Id nextContributingRenderPassId(RenderPass::Id) const; | 108 virtual RenderPass::Id nextContributingRenderPassId(RenderPass::Id) const; |
103 | 109 |
| 110 virtual ScrollbarLayerImpl* toScrollbarLayer(); |
| 111 |
104 // Returns true if this layer has content to draw. | 112 // Returns true if this layer has content to draw. |
105 void setDrawsContent(bool); | 113 void setDrawsContent(bool); |
106 bool drawsContent() const { return m_drawsContent; } | 114 bool drawsContent() const { return m_drawsContent; } |
107 | 115 |
108 bool forceRenderSurface() const { return m_forceRenderSurface; } | 116 bool forceRenderSurface() const { return m_forceRenderSurface; } |
109 void setForceRenderSurface(bool force) { m_forceRenderSurface = force; } | 117 void setForceRenderSurface(bool force) { m_forceRenderSurface = force; } |
110 | 118 |
111 void setAnchorPoint(const gfx::PointF&); | 119 void setAnchorPoint(const gfx::PointF&); |
112 const gfx::PointF& anchorPoint() const { return m_anchorPoint; } | 120 const gfx::PointF& anchorPoint() const { return m_anchorPoint; } |
113 | 121 |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 ScrollbarLayerImpl* verticalScrollbarLayer() { return m_verticalScrollbarLay
er; } | 297 ScrollbarLayerImpl* verticalScrollbarLayer() { return m_verticalScrollbarLay
er; } |
290 | 298 |
291 gfx::Rect layerRectToContentRect(const gfx::RectF& layerRect) const; | 299 gfx::Rect layerRectToContentRect(const gfx::RectF& layerRect) const; |
292 | 300 |
293 virtual skia::RefPtr<SkPicture> getPicture(); | 301 virtual skia::RefPtr<SkPicture> getPicture(); |
294 | 302 |
295 virtual bool canClipSelf() const; | 303 virtual bool canClipSelf() const; |
296 | 304 |
297 virtual bool areVisibleResourcesReady() const; | 305 virtual bool areVisibleResourcesReady() const; |
298 | 306 |
| 307 virtual scoped_ptr<LayerImpl> createLayerImpl(LayerTreeImpl*); |
| 308 virtual void pushPropertiesTo(LayerImpl*); |
| 309 |
299 protected: | 310 protected: |
300 LayerImpl(LayerTreeImpl* layerImpl, int); | 311 LayerImpl(LayerTreeImpl* layerImpl, int); |
301 | 312 |
302 // Get the color and size of the layer's debug border. | 313 // Get the color and size of the layer's debug border. |
303 virtual void getDebugBorderProperties(SkColor*, float* width) const; | 314 virtual void getDebugBorderProperties(SkColor*, float* width) const; |
304 | 315 |
305 void appendDebugBorderQuad(QuadSink&, const SharedQuadState*, AppendQuadsDat
a&) const; | 316 void appendDebugBorderQuad(QuadSink&, const SharedQuadState*, AppendQuadsDat
a&) const; |
306 | 317 |
307 virtual void dumpLayerProperties(std::string*, int indent) const; | 318 virtual void dumpLayerProperties(std::string*, int indent) const; |
308 static std::string indentString(int indent); | 319 static std::string indentString(int indent); |
309 | 320 |
310 private: | 321 private: |
311 scoped_ptr<LayerImpl> takeMaskLayer(); | |
312 scoped_ptr<LayerImpl> takeReplicaLayer(); | |
313 | |
314 void setParent(LayerImpl* parent) { m_parent = parent; } | |
315 friend class TreeSynchronizer; | |
316 void clearChildList(); // Warning: This does not preserve tree structure inv
ariants and so is only exposed to the tree synchronizer. | |
317 | |
318 void updateScrollbarPositions(); | 322 void updateScrollbarPositions(); |
319 | 323 |
320 void noteLayerSurfacePropertyChanged(); | 324 void noteLayerSurfacePropertyChanged(); |
321 void noteLayerPropertyChanged(); | 325 void noteLayerPropertyChanged(); |
322 void noteLayerPropertyChangedForSubtree(); | 326 void noteLayerPropertyChangedForSubtree(); |
323 | 327 |
324 // Note carefully this does not affect the current layer. | 328 // Note carefully this does not affect the current layer. |
325 void noteLayerPropertyChangedForDescendants(); | 329 void noteLayerPropertyChangedForDescendants(); |
326 | 330 |
327 virtual const char* layerTypeAsString() const; | 331 virtual const char* layerTypeAsString() const; |
(...skipping 15 matching lines...) Expand all Loading... |
343 gfx::PointF m_anchorPoint; | 347 gfx::PointF m_anchorPoint; |
344 float m_anchorPointZ; | 348 float m_anchorPointZ; |
345 gfx::Size m_bounds; | 349 gfx::Size m_bounds; |
346 gfx::Vector2d m_scrollOffset; | 350 gfx::Vector2d m_scrollOffset; |
347 bool m_scrollable; | 351 bool m_scrollable; |
348 bool m_shouldScrollOnMainThread; | 352 bool m_shouldScrollOnMainThread; |
349 bool m_haveWheelEventHandlers; | 353 bool m_haveWheelEventHandlers; |
350 Region m_nonFastScrollableRegion; | 354 Region m_nonFastScrollableRegion; |
351 Region m_touchEventHandlerRegion; | 355 Region m_touchEventHandlerRegion; |
352 SkColor m_backgroundColor; | 356 SkColor m_backgroundColor; |
| 357 bool m_stackingOrderChanged; |
353 | 358 |
354 // Whether the "back" of this layer should draw. | 359 // Whether the "back" of this layer should draw. |
355 bool m_doubleSided; | 360 bool m_doubleSided; |
356 | 361 |
357 // Tracks if drawing-related properties have changed since last redraw. | 362 // Tracks if drawing-related properties have changed since last redraw. |
358 bool m_layerPropertyChanged; | 363 bool m_layerPropertyChanged; |
359 | 364 |
360 // Indicates that a property has changed on this layer that would not | 365 // Indicates that a property has changed on this layer that would not |
361 // affect the pixels on its target surface, but would require redrawing | 366 // affect the pixels on its target surface, but would require redrawing |
362 // but would require redrawing the targetSurface onto its ancestor targetSur
face. | 367 // but would require redrawing the targetSurface onto its ancestor targetSur
face. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 // Group of properties that need to be computed based on the layer tree | 426 // Group of properties that need to be computed based on the layer tree |
422 // hierarchy before layers can be drawn. | 427 // hierarchy before layers can be drawn. |
423 DrawProperties<LayerImpl, RenderSurfaceImpl> m_drawProperties; | 428 DrawProperties<LayerImpl, RenderSurfaceImpl> m_drawProperties; |
424 | 429 |
425 DISALLOW_COPY_AND_ASSIGN(LayerImpl); | 430 DISALLOW_COPY_AND_ASSIGN(LayerImpl); |
426 }; | 431 }; |
427 | 432 |
428 } | 433 } |
429 | 434 |
430 #endif // CC_LAYER_IMPL_H_ | 435 #endif // CC_LAYER_IMPL_H_ |
OLD | NEW |