| 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 LayerTreeHostImpl; | 38 class LayerTreeHostImpl; |
| 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> { | 47 class CC_EXPORT Layer : public base::RefCounted<Layer>, public LayerAnimationCon
trollerClient { |
| 48 public: | 48 public: |
| 49 typedef std::vector<scoped_refptr<Layer> > LayerList; | 49 typedef std::vector<scoped_refptr<Layer> > LayerList; |
| 50 | 50 |
| 51 static scoped_refptr<Layer> create(); | 51 static scoped_refptr<Layer> create(); |
| 52 | 52 |
| 53 int id() const; | 53 // LayerAnimationControllerClient implementation |
| 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; |
| 54 | 62 |
| 55 Layer* rootLayer(); | 63 Layer* rootLayer(); |
| 56 Layer* parent() { return m_parent; } | 64 Layer* parent() { return m_parent; } |
| 57 const Layer* parent() const { return m_parent; } | 65 const Layer* parent() const { return m_parent; } |
| 58 void addChild(scoped_refptr<Layer>); | 66 void addChild(scoped_refptr<Layer>); |
| 59 void insertChild(scoped_refptr<Layer>, size_t index); | 67 void insertChild(scoped_refptr<Layer>, size_t index); |
| 60 void replaceChild(Layer* reference, scoped_refptr<Layer> newLayer); | 68 void replaceChild(Layer* reference, scoped_refptr<Layer> newLayer); |
| 61 void removeFromParent(); | 69 void removeFromParent(); |
| 62 void removeAllChildren(); | 70 void removeAllChildren(); |
| 63 void setChildren(const LayerList&); | 71 void setChildren(const LayerList&); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 84 | 92 |
| 85 void setMaskLayer(Layer*); | 93 void setMaskLayer(Layer*); |
| 86 Layer* maskLayer() { return m_maskLayer.get(); } | 94 Layer* maskLayer() { return m_maskLayer.get(); } |
| 87 const Layer* maskLayer() const { return m_maskLayer.get(); } | 95 const Layer* maskLayer() const { return m_maskLayer.get(); } |
| 88 | 96 |
| 89 virtual void setNeedsDisplayRect(const gfx::RectF& dirtyRect); | 97 virtual void setNeedsDisplayRect(const gfx::RectF& dirtyRect); |
| 90 void setNeedsDisplay() { setNeedsDisplayRect(gfx::RectF(gfx::PointF(), bound
s())); } | 98 void setNeedsDisplay() { setNeedsDisplayRect(gfx::RectF(gfx::PointF(), bound
s())); } |
| 91 virtual bool needsDisplay() const; | 99 virtual bool needsDisplay() const; |
| 92 | 100 |
| 93 void setOpacity(float); | 101 void setOpacity(float); |
| 94 float opacity() const; | |
| 95 bool opacityIsAnimating() const; | 102 bool opacityIsAnimating() const; |
| 96 | 103 |
| 97 void setFilters(const WebKit::WebFilterOperations&); | 104 void setFilters(const WebKit::WebFilterOperations&); |
| 98 const WebKit::WebFilterOperations& filters() const { return m_filters; } | 105 const WebKit::WebFilterOperations& filters() const { return m_filters; } |
| 99 | 106 |
| 100 void setFilter(const skia::RefPtr<SkImageFilter>& filter); | 107 void setFilter(const skia::RefPtr<SkImageFilter>& filter); |
| 101 skia::RefPtr<SkImageFilter> filter() const { return m_filter; } | 108 skia::RefPtr<SkImageFilter> filter() const { return m_filter; } |
| 102 | 109 |
| 103 // Background filters are filters applied to what is behind this layer, when
they are viewed through non-opaque | 110 // Background filters are filters applied to what is behind this layer, when
they are viewed through non-opaque |
| 104 // regions in this layer. They are used through the WebLayer interface, and
are not exposed to HTML. | 111 // regions in this layer. They are used through the WebLayer interface, and
are not exposed to HTML. |
| 105 void setBackgroundFilters(const WebKit::WebFilterOperations&); | 112 void setBackgroundFilters(const WebKit::WebFilterOperations&); |
| 106 const WebKit::WebFilterOperations& backgroundFilters() const { return m_back
groundFilters; } | 113 const WebKit::WebFilterOperations& backgroundFilters() const { return m_back
groundFilters; } |
| 107 | 114 |
| 108 virtual void setContentsOpaque(bool); | 115 virtual void setContentsOpaque(bool); |
| 109 bool contentsOpaque() const { return m_contentsOpaque; } | 116 bool contentsOpaque() const { return m_contentsOpaque; } |
| 110 | 117 |
| 111 void setPosition(const gfx::PointF&); | 118 void setPosition(const gfx::PointF&); |
| 112 gfx::PointF position() const { return m_position; } | 119 gfx::PointF position() const { return m_position; } |
| 113 | 120 |
| 114 void setIsContainerForFixedPositionLayers(bool); | 121 void setIsContainerForFixedPositionLayers(bool); |
| 115 bool isContainerForFixedPositionLayers() const { return m_isContainerForFixe
dPositionLayers; } | 122 bool isContainerForFixedPositionLayers() const { return m_isContainerForFixe
dPositionLayers; } |
| 116 | 123 |
| 117 void setFixedToContainerLayer(bool); | 124 void setFixedToContainerLayer(bool); |
| 118 bool fixedToContainerLayer() const { return m_fixedToContainerLayer; } | 125 bool fixedToContainerLayer() const { return m_fixedToContainerLayer; } |
| 119 | 126 |
| 120 void setSublayerTransform(const gfx::Transform&); | 127 void setSublayerTransform(const gfx::Transform&); |
| 121 const gfx::Transform& sublayerTransform() const { return m_sublayerTransform
; } | 128 const gfx::Transform& sublayerTransform() const { return m_sublayerTransform
; } |
| 122 | 129 |
| 123 void setTransform(const gfx::Transform&); | 130 void setTransform(const gfx::Transform&); |
| 124 const gfx::Transform& transform() const; | |
| 125 bool transformIsAnimating() const; | 131 bool transformIsAnimating() const; |
| 126 | 132 |
| 127 DrawProperties<Layer, RenderSurface>& drawProperties() { return m_drawProper
ties; } | 133 DrawProperties<Layer, RenderSurface>& drawProperties() { return m_drawProper
ties; } |
| 128 const DrawProperties<Layer, RenderSurface>& drawProperties() const { return
m_drawProperties; } | 134 const DrawProperties<Layer, RenderSurface>& drawProperties() const { return
m_drawProperties; } |
| 129 | 135 |
| 130 // The following are shortcut accessors to get various information from m_dr
awProperties | 136 // The following are shortcut accessors to get various information from m_dr
awProperties |
| 131 const gfx::Transform& drawTransform() const { return m_drawProperties.target
_space_transform; } | 137 const gfx::Transform& drawTransform() const { return m_drawProperties.target
_space_transform; } |
| 132 const gfx::Transform& screenSpaceTransform() const { return m_drawProperties
.screen_space_transform; } | 138 const gfx::Transform& screenSpaceTransform() const { return m_drawProperties
.screen_space_transform; } |
| 133 float drawOpacity() const { return m_drawProperties.opacity; } | 139 float drawOpacity() const { return m_drawProperties.opacity; } |
| 134 bool drawOpacityIsAnimating() const { return m_drawProperties.opacity_is_ani
mating; } | 140 bool drawOpacityIsAnimating() const { return m_drawProperties.opacity_is_ani
mating; } |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 virtual void setTexturePriorities(const PriorityCalculator&) { } | 260 virtual void setTexturePriorities(const PriorityCalculator&) { } |
| 255 | 261 |
| 256 bool addAnimation(scoped_ptr<ActiveAnimation>); | 262 bool addAnimation(scoped_ptr<ActiveAnimation>); |
| 257 void pauseAnimation(int animationId, double timeOffset); | 263 void pauseAnimation(int animationId, double timeOffset); |
| 258 void removeAnimation(int animationId); | 264 void removeAnimation(int animationId); |
| 259 | 265 |
| 260 void suspendAnimations(double monotonicTime); | 266 void suspendAnimations(double monotonicTime); |
| 261 void resumeAnimations(double monotonicTime); | 267 void resumeAnimations(double monotonicTime); |
| 262 | 268 |
| 263 LayerAnimationController* layerAnimationController() { return m_layerAnimati
onController.get(); } | 269 LayerAnimationController* layerAnimationController() { return m_layerAnimati
onController.get(); } |
| 264 void setLayerAnimationController(scoped_refptr<LayerAnimationController>); | 270 void setLayerAnimationController(scoped_ptr<LayerAnimationController>); |
| 265 scoped_refptr<LayerAnimationController> releaseLayerAnimationController(); | 271 scoped_ptr<LayerAnimationController> releaseLayerAnimationController(); |
| 266 | 272 |
| 267 void setLayerAnimationDelegate(WebKit::WebAnimationDelegate* layerAnimationD
elegate) { m_layerAnimationDelegate = layerAnimationDelegate; } | 273 void setLayerAnimationDelegate(WebKit::WebAnimationDelegate* layerAnimationD
elegate) { m_layerAnimationDelegate = layerAnimationDelegate; } |
| 268 | 274 |
| 269 bool hasActiveAnimation() const; | 275 bool hasActiveAnimation() const; |
| 270 | 276 |
| 271 virtual void notifyAnimationStarted(const AnimationEvent&, double wallClockT
ime); | 277 virtual void notifyAnimationStarted(const AnimationEvent&, double wallClockT
ime); |
| 272 virtual void notifyAnimationFinished(double wallClockTime); | 278 virtual void notifyAnimationFinished(double wallClockTime); |
| 273 | 279 |
| 274 virtual Region visibleContentOpaqueRegion() const; | 280 virtual Region visibleContentOpaqueRegion() const; |
| 275 | 281 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 void removeChild(Layer*); | 332 void removeChild(Layer*); |
| 327 | 333 |
| 328 LayerList m_children; | 334 LayerList m_children; |
| 329 Layer* m_parent; | 335 Layer* m_parent; |
| 330 | 336 |
| 331 // Layer instances have a weak pointer to their LayerTreeHost. | 337 // 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 | 338 // This pointer value is nil when a Layer is not in a tree and is |
| 333 // updated via setLayerTreeHost() if a layer moves between trees. | 339 // updated via setLayerTreeHost() if a layer moves between trees. |
| 334 LayerTreeHost* m_layerTreeHost; | 340 LayerTreeHost* m_layerTreeHost; |
| 335 | 341 |
| 336 scoped_refptr<LayerAnimationController> m_layerAnimationController; | 342 scoped_ptr<LayerAnimationController> m_layerAnimationController; |
| 337 | 343 |
| 338 // Layer properties. | 344 // Layer properties. |
| 339 gfx::Size m_bounds; | 345 gfx::Size m_bounds; |
| 340 | 346 |
| 341 gfx::Vector2d m_scrollOffset; | 347 gfx::Vector2d m_scrollOffset; |
| 342 gfx::Vector2d m_maxScrollOffset; | 348 gfx::Vector2d m_maxScrollOffset; |
| 343 bool m_scrollable; | 349 bool m_scrollable; |
| 344 bool m_shouldScrollOnMainThread; | 350 bool m_shouldScrollOnMainThread; |
| 345 bool m_haveWheelEventHandlers; | 351 bool m_haveWheelEventHandlers; |
| 346 Region m_nonFastScrollableRegion; | 352 Region m_nonFastScrollableRegion; |
| 347 bool m_nonFastScrollableRegionChanged; | 353 bool m_nonFastScrollableRegionChanged; |
| 348 Region m_touchEventHandlerRegion; | 354 Region m_touchEventHandlerRegion; |
| 349 bool m_touchEventHandlerRegionChanged; | 355 bool m_touchEventHandlerRegionChanged; |
| 350 gfx::PointF m_position; | 356 gfx::PointF m_position; |
| 351 gfx::PointF m_anchorPoint; | 357 gfx::PointF m_anchorPoint; |
| 352 SkColor m_backgroundColor; | 358 SkColor m_backgroundColor; |
| 353 std::string m_debugName; | 359 std::string m_debugName; |
| 360 float m_opacity; |
| 354 skia::RefPtr<SkImageFilter> m_filter; | 361 skia::RefPtr<SkImageFilter> m_filter; |
| 355 WebKit::WebFilterOperations m_filters; | 362 WebKit::WebFilterOperations m_filters; |
| 356 WebKit::WebFilterOperations m_backgroundFilters; | 363 WebKit::WebFilterOperations m_backgroundFilters; |
| 357 float m_anchorPointZ; | 364 float m_anchorPointZ; |
| 358 bool m_isContainerForFixedPositionLayers; | 365 bool m_isContainerForFixedPositionLayers; |
| 359 bool m_fixedToContainerLayer; | 366 bool m_fixedToContainerLayer; |
| 360 bool m_isDrawable; | 367 bool m_isDrawable; |
| 361 bool m_masksToBounds; | 368 bool m_masksToBounds; |
| 362 bool m_contentsOpaque; | 369 bool m_contentsOpaque; |
| 363 bool m_doubleSided; | 370 bool m_doubleSided; |
| 364 bool m_useLCDText; | 371 bool m_useLCDText; |
| 365 bool m_preserves3D; | 372 bool m_preserves3D; |
| 366 bool m_useParentBackfaceVisibility; | 373 bool m_useParentBackfaceVisibility; |
| 367 bool m_drawCheckerboardForMissingTiles; | 374 bool m_drawCheckerboardForMissingTiles; |
| 368 bool m_forceRenderSurface; | 375 bool m_forceRenderSurface; |
| 369 | 376 |
| 377 gfx::Transform m_transform; |
| 370 gfx::Transform m_sublayerTransform; | 378 gfx::Transform m_sublayerTransform; |
| 371 | 379 |
| 372 // Replica layer used for reflections. | 380 // Replica layer used for reflections. |
| 373 scoped_refptr<Layer> m_replicaLayer; | 381 scoped_refptr<Layer> m_replicaLayer; |
| 374 | 382 |
| 375 // Transient properties. | 383 // Transient properties. |
| 376 float m_rasterScale; | 384 float m_rasterScale; |
| 377 bool m_automaticallyComputeRasterScale; | 385 bool m_automaticallyComputeRasterScale; |
| 378 bool m_boundsContainPageScale; | 386 bool m_boundsContainPageScale; |
| 379 | 387 |
| 380 gfx::Transform m_implTransform; | 388 gfx::Transform m_implTransform; |
| 381 | 389 |
| 382 WebKit::WebAnimationDelegate* m_layerAnimationDelegate; | 390 WebKit::WebAnimationDelegate* m_layerAnimationDelegate; |
| 383 WebKit::WebLayerScrollClient* m_layerScrollClient; | 391 WebKit::WebLayerScrollClient* m_layerScrollClient; |
| 384 | 392 |
| 385 DrawProperties<Layer, RenderSurface> m_drawProperties; | 393 DrawProperties<Layer, RenderSurface> m_drawProperties; |
| 386 }; | 394 }; |
| 387 | 395 |
| 388 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped
_refptr<Layer> >::iterator, void*); | 396 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped
_refptr<Layer> >::iterator, void*); |
| 389 | 397 |
| 390 } // namespace cc | 398 } // namespace cc |
| 391 | 399 |
| 392 #endif // CC_LAYER_H_ | 400 #endif // CC_LAYER_H_ |
| OLD | NEW |