| OLD | NEW |
| 1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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_H_ | 5 #ifndef CC_LAYER_H_ |
| 6 #define CC_LAYER_H_ | 6 #define CC_LAYER_H_ |
| 7 | 7 |
| 8 #include <public/WebFilterOperations.h> | 8 #include <public/WebFilterOperations.h> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 class LayerTreeHost; | 37 class LayerTreeHost; |
| 38 class LayerTreeImpl; | 38 class LayerTreeImpl; |
| 39 class PriorityCalculator; | 39 class PriorityCalculator; |
| 40 class ResourceUpdateQueue; | 40 class ResourceUpdateQueue; |
| 41 class ScrollbarLayer; | 41 class ScrollbarLayer; |
| 42 struct AnimationEvent; | 42 struct AnimationEvent; |
| 43 struct RenderingStats; | 43 struct RenderingStats; |
| 44 | 44 |
| 45 // Base class for composited layers. Special layer types are derived from | 45 // Base class for composited layers. Special layer types are derived from |
| 46 // this class. | 46 // this class. |
| 47 class CC_EXPORT Layer : public base::RefCounted<Layer>, public LayerAnimationCon
trollerClient { | 47 class CC_EXPORT Layer : public base::RefCounted<Layer>, |
| 48 public LayerAnimationControllerObserver { |
| 48 public: | 49 public: |
| 49 typedef std::vector<scoped_refptr<Layer> > LayerList; | 50 typedef std::vector<scoped_refptr<Layer> > LayerList; |
| 50 | 51 |
| 51 static scoped_refptr<Layer> create(); | 52 static scoped_refptr<Layer> create(); |
| 52 | 53 |
| 53 // LayerAnimationControllerClient implementation | 54 int id() const; |
| 54 virtual int id() const OVERRIDE; | |
| 55 virtual void setOpacityFromAnimation(float) OVERRIDE; | |
| 56 virtual float opacity() const OVERRIDE; | |
| 57 virtual void setTransformFromAnimation(const gfx::Transform&) OVERRIDE; | |
| 58 // A layer's transform operates layer space. That is, entirely in logical, | |
| 59 // non-page-scaled pixels (that is, they have page zoom baked in, but not pa
ge scale). | |
| 60 // The root layer is a special case -- it operates in physical pixels. | |
| 61 virtual const gfx::Transform& transform() const OVERRIDE; | |
| 62 | 55 |
| 63 Layer* rootLayer(); | 56 Layer* rootLayer(); |
| 64 Layer* parent() { return m_parent; } | 57 Layer* parent() { return m_parent; } |
| 65 const Layer* parent() const { return m_parent; } | 58 const Layer* parent() const { return m_parent; } |
| 66 void addChild(scoped_refptr<Layer>); | 59 void addChild(scoped_refptr<Layer>); |
| 67 void insertChild(scoped_refptr<Layer>, size_t index); | 60 void insertChild(scoped_refptr<Layer>, size_t index); |
| 68 void replaceChild(Layer* reference, scoped_refptr<Layer> newLayer); | 61 void replaceChild(Layer* reference, scoped_refptr<Layer> newLayer); |
| 69 void removeFromParent(); | 62 void removeFromParent(); |
| 70 void removeAllChildren(); | 63 void removeAllChildren(); |
| 71 void setChildren(const LayerList&); | 64 void setChildren(const LayerList&); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 93 | 86 |
| 94 void setMaskLayer(Layer*); | 87 void setMaskLayer(Layer*); |
| 95 Layer* maskLayer() { return m_maskLayer.get(); } | 88 Layer* maskLayer() { return m_maskLayer.get(); } |
| 96 const Layer* maskLayer() const { return m_maskLayer.get(); } | 89 const Layer* maskLayer() const { return m_maskLayer.get(); } |
| 97 | 90 |
| 98 virtual void setNeedsDisplayRect(const gfx::RectF& dirtyRect); | 91 virtual void setNeedsDisplayRect(const gfx::RectF& dirtyRect); |
| 99 void setNeedsDisplay() { setNeedsDisplayRect(gfx::RectF(gfx::PointF(), bound
s())); } | 92 void setNeedsDisplay() { setNeedsDisplayRect(gfx::RectF(gfx::PointF(), bound
s())); } |
| 100 virtual bool needsDisplay() const; | 93 virtual bool needsDisplay() const; |
| 101 | 94 |
| 102 void setOpacity(float); | 95 void setOpacity(float); |
| 96 float opacity() const; |
| 103 bool opacityIsAnimating() const; | 97 bool opacityIsAnimating() const; |
| 104 | 98 |
| 105 void setFilters(const WebKit::WebFilterOperations&); | 99 void setFilters(const WebKit::WebFilterOperations&); |
| 106 const WebKit::WebFilterOperations& filters() const { return m_filters; } | 100 const WebKit::WebFilterOperations& filters() const { return m_filters; } |
| 107 | 101 |
| 108 void setFilter(const skia::RefPtr<SkImageFilter>& filter); | 102 void setFilter(const skia::RefPtr<SkImageFilter>& filter); |
| 109 skia::RefPtr<SkImageFilter> filter() const { return m_filter; } | 103 skia::RefPtr<SkImageFilter> filter() const { return m_filter; } |
| 110 | 104 |
| 111 // Background filters are filters applied to what is behind this layer, when
they are viewed through non-opaque | 105 // Background filters are filters applied to what is behind this layer, when
they are viewed through non-opaque |
| 112 // regions in this layer. They are used through the WebLayer interface, and
are not exposed to HTML. | 106 // regions in this layer. They are used through the WebLayer interface, and
are not exposed to HTML. |
| 113 void setBackgroundFilters(const WebKit::WebFilterOperations&); | 107 void setBackgroundFilters(const WebKit::WebFilterOperations&); |
| 114 const WebKit::WebFilterOperations& backgroundFilters() const { return m_back
groundFilters; } | 108 const WebKit::WebFilterOperations& backgroundFilters() const { return m_back
groundFilters; } |
| 115 | 109 |
| 116 virtual void setContentsOpaque(bool); | 110 virtual void setContentsOpaque(bool); |
| 117 bool contentsOpaque() const { return m_contentsOpaque; } | 111 bool contentsOpaque() const { return m_contentsOpaque; } |
| 118 | 112 |
| 119 void setPosition(const gfx::PointF&); | 113 void setPosition(const gfx::PointF&); |
| 120 gfx::PointF position() const { return m_position; } | 114 gfx::PointF position() const { return m_position; } |
| 121 | 115 |
| 122 void setIsContainerForFixedPositionLayers(bool); | 116 void setIsContainerForFixedPositionLayers(bool); |
| 123 bool isContainerForFixedPositionLayers() const { return m_isContainerForFixe
dPositionLayers; } | 117 bool isContainerForFixedPositionLayers() const { return m_isContainerForFixe
dPositionLayers; } |
| 124 | 118 |
| 125 void setFixedToContainerLayer(bool); | 119 void setFixedToContainerLayer(bool); |
| 126 bool fixedToContainerLayer() const { return m_fixedToContainerLayer; } | 120 bool fixedToContainerLayer() const { return m_fixedToContainerLayer; } |
| 127 | 121 |
| 128 void setSublayerTransform(const gfx::Transform&); | 122 void setSublayerTransform(const gfx::Transform&); |
| 129 const gfx::Transform& sublayerTransform() const { return m_sublayerTransform
; } | 123 const gfx::Transform& sublayerTransform() const { return m_sublayerTransform
; } |
| 130 | 124 |
| 131 void setTransform(const gfx::Transform&); | 125 void setTransform(const gfx::Transform&); |
| 126 const gfx::Transform& transform() const; |
| 132 bool transformIsAnimating() const; | 127 bool transformIsAnimating() const; |
| 133 | 128 |
| 134 DrawProperties<Layer, RenderSurface>& drawProperties() { return m_drawProper
ties; } | 129 DrawProperties<Layer, RenderSurface>& drawProperties() { return m_drawProper
ties; } |
| 135 const DrawProperties<Layer, RenderSurface>& drawProperties() const { return
m_drawProperties; } | 130 const DrawProperties<Layer, RenderSurface>& drawProperties() const { return
m_drawProperties; } |
| 136 | 131 |
| 137 // The following are shortcut accessors to get various information from m_dr
awProperties | 132 // The following are shortcut accessors to get various information from m_dr
awProperties |
| 138 const gfx::Transform& drawTransform() const { return m_drawProperties.target
_space_transform; } | 133 const gfx::Transform& drawTransform() const { return m_drawProperties.target
_space_transform; } |
| 139 const gfx::Transform& screenSpaceTransform() const { return m_drawProperties
.screen_space_transform; } | 134 const gfx::Transform& screenSpaceTransform() const { return m_drawProperties
.screen_space_transform; } |
| 140 float drawOpacity() const { return m_drawProperties.opacity; } | 135 float drawOpacity() const { return m_drawProperties.opacity; } |
| 141 bool drawOpacityIsAnimating() const { return m_drawProperties.opacity_is_ani
mating; } | 136 bool drawOpacityIsAnimating() const { return m_drawProperties.opacity_is_ani
mating; } |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 virtual void setTexturePriorities(const PriorityCalculator&) { } | 255 virtual void setTexturePriorities(const PriorityCalculator&) { } |
| 261 | 256 |
| 262 bool addAnimation(scoped_ptr<ActiveAnimation>); | 257 bool addAnimation(scoped_ptr<ActiveAnimation>); |
| 263 void pauseAnimation(int animationId, double timeOffset); | 258 void pauseAnimation(int animationId, double timeOffset); |
| 264 void removeAnimation(int animationId); | 259 void removeAnimation(int animationId); |
| 265 | 260 |
| 266 void suspendAnimations(double monotonicTime); | 261 void suspendAnimations(double monotonicTime); |
| 267 void resumeAnimations(double monotonicTime); | 262 void resumeAnimations(double monotonicTime); |
| 268 | 263 |
| 269 LayerAnimationController* layerAnimationController() { return m_layerAnimati
onController.get(); } | 264 LayerAnimationController* layerAnimationController() { return m_layerAnimati
onController.get(); } |
| 270 void setLayerAnimationController(scoped_ptr<LayerAnimationController>); | 265 void setLayerAnimationController(scoped_refptr<LayerAnimationController>); |
| 271 scoped_ptr<LayerAnimationController> releaseLayerAnimationController(); | 266 scoped_refptr<LayerAnimationController> releaseLayerAnimationController(); |
| 272 | 267 |
| 273 void setLayerAnimationDelegate(WebKit::WebAnimationDelegate* layerAnimationD
elegate) { m_layerAnimationDelegate = layerAnimationDelegate; } | 268 void setLayerAnimationDelegate(WebKit::WebAnimationDelegate* layerAnimationD
elegate) { m_layerAnimationDelegate = layerAnimationDelegate; } |
| 274 | 269 |
| 275 bool hasActiveAnimation() const; | 270 bool hasActiveAnimation() const; |
| 276 | 271 |
| 277 virtual void notifyAnimationStarted(const AnimationEvent&, double wallClockT
ime); | 272 virtual void notifyAnimationStarted(const AnimationEvent&, double wallClockT
ime); |
| 278 virtual void notifyAnimationFinished(double wallClockTime); | 273 virtual void notifyAnimationFinished(double wallClockTime); |
| 279 | 274 |
| 280 virtual Region visibleContentOpaqueRegion() const; | 275 virtual Region visibleContentOpaqueRegion() const; |
| 281 | 276 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 bool descendantIsFixedToContainerLayer() const; | 319 bool descendantIsFixedToContainerLayer() const; |
| 325 | 320 |
| 326 size_t numChildren() const { return m_children.size(); } | 321 size_t numChildren() const { return m_children.size(); } |
| 327 | 322 |
| 328 // Returns the index of the child or -1 if not found. | 323 // Returns the index of the child or -1 if not found. |
| 329 int indexOfChild(const Layer*); | 324 int indexOfChild(const Layer*); |
| 330 | 325 |
| 331 // This should only be called from removeFromParent. | 326 // This should only be called from removeFromParent. |
| 332 void removeChild(Layer*); | 327 void removeChild(Layer*); |
| 333 | 328 |
| 329 // LayerAnimationControllerObserver implementation. |
| 330 virtual void OnOpacityAnimated(float) OVERRIDE; |
| 331 virtual void OnTransformAnimated(const gfx::Transform&) OVERRIDE; |
| 332 |
| 334 LayerList m_children; | 333 LayerList m_children; |
| 335 Layer* m_parent; | 334 Layer* m_parent; |
| 336 | 335 |
| 337 // Layer instances have a weak pointer to their LayerTreeHost. | 336 // Layer instances have a weak pointer to their LayerTreeHost. |
| 338 // This pointer value is nil when a Layer is not in a tree and is | 337 // This pointer value is nil when a Layer is not in a tree and is |
| 339 // updated via setLayerTreeHost() if a layer moves between trees. | 338 // updated via setLayerTreeHost() if a layer moves between trees. |
| 340 LayerTreeHost* m_layerTreeHost; | 339 LayerTreeHost* m_layerTreeHost; |
| 341 | 340 |
| 342 scoped_ptr<LayerAnimationController> m_layerAnimationController; | 341 scoped_refptr<LayerAnimationController> m_layerAnimationController; |
| 343 | 342 |
| 344 // Layer properties. | 343 // Layer properties. |
| 345 gfx::Size m_bounds; | 344 gfx::Size m_bounds; |
| 346 | 345 |
| 347 gfx::Vector2d m_scrollOffset; | 346 gfx::Vector2d m_scrollOffset; |
| 348 gfx::Vector2d m_maxScrollOffset; | 347 gfx::Vector2d m_maxScrollOffset; |
| 349 bool m_scrollable; | 348 bool m_scrollable; |
| 350 bool m_shouldScrollOnMainThread; | 349 bool m_shouldScrollOnMainThread; |
| 351 bool m_haveWheelEventHandlers; | 350 bool m_haveWheelEventHandlers; |
| 352 Region m_nonFastScrollableRegion; | 351 Region m_nonFastScrollableRegion; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 WebKit::WebLayerScrollClient* m_layerScrollClient; | 389 WebKit::WebLayerScrollClient* m_layerScrollClient; |
| 391 | 390 |
| 392 DrawProperties<Layer, RenderSurface> m_drawProperties; | 391 DrawProperties<Layer, RenderSurface> m_drawProperties; |
| 393 }; | 392 }; |
| 394 | 393 |
| 395 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped
_refptr<Layer> >::iterator, void*); | 394 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped
_refptr<Layer> >::iterator, void*); |
| 396 | 395 |
| 397 } // namespace cc | 396 } // namespace cc |
| 398 | 397 |
| 399 #endif // CC_LAYER_H_ | 398 #endif // CC_LAYER_H_ |
| OLD | NEW |