| 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 24 matching lines...) Expand all Loading... |
| 35 class LayerImpl; | 35 class LayerImpl; |
| 36 class LayerTreeHost; | 36 class LayerTreeHost; |
| 37 class PriorityCalculator; | 37 class PriorityCalculator; |
| 38 class ResourceUpdateQueue; | 38 class ResourceUpdateQueue; |
| 39 class ScrollbarLayer; | 39 class ScrollbarLayer; |
| 40 struct AnimationEvent; | 40 struct AnimationEvent; |
| 41 struct RenderingStats; | 41 struct RenderingStats; |
| 42 | 42 |
| 43 // Base class for composited layers. Special layer types are derived from | 43 // Base class for composited layers. Special layer types are derived from |
| 44 // this class. | 44 // this class. |
| 45 class CC_EXPORT Layer : public base::RefCounted<Layer>, public LayerAnimationCon
trollerClient { | 45 class CC_EXPORT Layer : public base::RefCounted<Layer> { |
| 46 public: | 46 public: |
| 47 typedef std::vector<scoped_refptr<Layer> > LayerList; | 47 typedef std::vector<scoped_refptr<Layer> > LayerList; |
| 48 | 48 |
| 49 static scoped_refptr<Layer> create(); | 49 static scoped_refptr<Layer> create(); |
| 50 | 50 |
| 51 // LayerAnimationControllerClient implementation | 51 int id() const; |
| 52 virtual int id() const OVERRIDE; | |
| 53 virtual void setOpacityFromAnimation(float) OVERRIDE; | |
| 54 virtual float opacity() const OVERRIDE; | |
| 55 virtual void setTransformFromAnimation(const gfx::Transform&) OVERRIDE; | |
| 56 // A layer's transform operates layer space. That is, entirely in logical, | |
| 57 // non-page-scaled pixels (that is, they have page zoom baked in, but not pa
ge scale). | |
| 58 // The root layer is a special case -- it operates in physical pixels. | |
| 59 virtual const gfx::Transform& transform() const OVERRIDE; | |
| 60 | 52 |
| 61 Layer* rootLayer(); | 53 Layer* rootLayer(); |
| 62 Layer* parent() { return m_parent; } | 54 Layer* parent() { return m_parent; } |
| 63 const Layer* parent() const { return m_parent; } | 55 const Layer* parent() const { return m_parent; } |
| 64 void addChild(scoped_refptr<Layer>); | 56 void addChild(scoped_refptr<Layer>); |
| 65 void insertChild(scoped_refptr<Layer>, size_t index); | 57 void insertChild(scoped_refptr<Layer>, size_t index); |
| 66 void replaceChild(Layer* reference, scoped_refptr<Layer> newLayer); | 58 void replaceChild(Layer* reference, scoped_refptr<Layer> newLayer); |
| 67 void removeFromParent(); | 59 void removeFromParent(); |
| 68 void removeAllChildren(); | 60 void removeAllChildren(); |
| 69 void setChildren(const LayerList&); | 61 void setChildren(const LayerList&); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 90 | 82 |
| 91 void setMaskLayer(Layer*); | 83 void setMaskLayer(Layer*); |
| 92 Layer* maskLayer() { return m_maskLayer.get(); } | 84 Layer* maskLayer() { return m_maskLayer.get(); } |
| 93 const Layer* maskLayer() const { return m_maskLayer.get(); } | 85 const Layer* maskLayer() const { return m_maskLayer.get(); } |
| 94 | 86 |
| 95 virtual void setNeedsDisplayRect(const gfx::RectF& dirtyRect); | 87 virtual void setNeedsDisplayRect(const gfx::RectF& dirtyRect); |
| 96 void setNeedsDisplay() { setNeedsDisplayRect(gfx::RectF(gfx::PointF(), bound
s())); } | 88 void setNeedsDisplay() { setNeedsDisplayRect(gfx::RectF(gfx::PointF(), bound
s())); } |
| 97 virtual bool needsDisplay() const; | 89 virtual bool needsDisplay() const; |
| 98 | 90 |
| 99 void setOpacity(float); | 91 void setOpacity(float); |
| 92 float opacity() const; |
| 100 bool opacityIsAnimating() const; | 93 bool opacityIsAnimating() const; |
| 101 | 94 |
| 102 void setFilters(const WebKit::WebFilterOperations&); | 95 void setFilters(const WebKit::WebFilterOperations&); |
| 103 const WebKit::WebFilterOperations& filters() const { return m_filters; } | 96 const WebKit::WebFilterOperations& filters() const { return m_filters; } |
| 104 | 97 |
| 105 void setFilter(const skia::RefPtr<SkImageFilter>& filter); | 98 void setFilter(const skia::RefPtr<SkImageFilter>& filter); |
| 106 skia::RefPtr<SkImageFilter> filter() const { return m_filter; } | 99 skia::RefPtr<SkImageFilter> filter() const { return m_filter; } |
| 107 | 100 |
| 108 // Background filters are filters applied to what is behind this layer, when
they are viewed through non-opaque | 101 // Background filters are filters applied to what is behind this layer, when
they are viewed through non-opaque |
| 109 // regions in this layer. They are used through the WebLayer interface, and
are not exposed to HTML. | 102 // regions in this layer. They are used through the WebLayer interface, and
are not exposed to HTML. |
| 110 void setBackgroundFilters(const WebKit::WebFilterOperations&); | 103 void setBackgroundFilters(const WebKit::WebFilterOperations&); |
| 111 const WebKit::WebFilterOperations& backgroundFilters() const { return m_back
groundFilters; } | 104 const WebKit::WebFilterOperations& backgroundFilters() const { return m_back
groundFilters; } |
| 112 | 105 |
| 113 virtual void setContentsOpaque(bool); | 106 virtual void setContentsOpaque(bool); |
| 114 bool contentsOpaque() const { return m_contentsOpaque; } | 107 bool contentsOpaque() const { return m_contentsOpaque; } |
| 115 | 108 |
| 116 void setPosition(const gfx::PointF&); | 109 void setPosition(const gfx::PointF&); |
| 117 gfx::PointF position() const { return m_position; } | 110 gfx::PointF position() const { return m_position; } |
| 118 | 111 |
| 119 void setIsContainerForFixedPositionLayers(bool); | 112 void setIsContainerForFixedPositionLayers(bool); |
| 120 bool isContainerForFixedPositionLayers() const { return m_isContainerForFixe
dPositionLayers; } | 113 bool isContainerForFixedPositionLayers() const { return m_isContainerForFixe
dPositionLayers; } |
| 121 | 114 |
| 122 void setFixedToContainerLayer(bool); | 115 void setFixedToContainerLayer(bool); |
| 123 bool fixedToContainerLayer() const { return m_fixedToContainerLayer; } | 116 bool fixedToContainerLayer() const { return m_fixedToContainerLayer; } |
| 124 | 117 |
| 125 void setSublayerTransform(const gfx::Transform&); | 118 void setSublayerTransform(const gfx::Transform&); |
| 126 const gfx::Transform& sublayerTransform() const { return m_sublayerTransform
; } | 119 const gfx::Transform& sublayerTransform() const { return m_sublayerTransform
; } |
| 127 | 120 |
| 128 void setTransform(const gfx::Transform&); | 121 void setTransform(const gfx::Transform&); |
| 122 const gfx::Transform& transform() const; |
| 129 bool transformIsAnimating() const; | 123 bool transformIsAnimating() const; |
| 130 | 124 |
| 131 const gfx::Rect& visibleContentRect() const { return m_visibleContentRect; } | 125 const gfx::Rect& visibleContentRect() const { return m_visibleContentRect; } |
| 132 void setVisibleContentRect(const gfx::Rect& visibleContentRect) { m_visibleC
ontentRect = visibleContentRect; } | 126 void setVisibleContentRect(const gfx::Rect& visibleContentRect) { m_visibleC
ontentRect = visibleContentRect; } |
| 133 | 127 |
| 134 void setScrollOffset(gfx::Vector2d); | 128 void setScrollOffset(gfx::Vector2d); |
| 135 gfx::Vector2d scrollOffset() const { return m_scrollOffset; } | 129 gfx::Vector2d scrollOffset() const { return m_scrollOffset; } |
| 136 | 130 |
| 137 void setMaxScrollOffset(gfx::Vector2d); | 131 void setMaxScrollOffset(gfx::Vector2d); |
| 138 gfx::Vector2d maxScrollOffset() const { return m_maxScrollOffset; } | 132 gfx::Vector2d maxScrollOffset() const { return m_maxScrollOffset; } |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 virtual void setTexturePriorities(const PriorityCalculator&) { } | 272 virtual void setTexturePriorities(const PriorityCalculator&) { } |
| 279 | 273 |
| 280 bool addAnimation(scoped_ptr<ActiveAnimation>); | 274 bool addAnimation(scoped_ptr<ActiveAnimation>); |
| 281 void pauseAnimation(int animationId, double timeOffset); | 275 void pauseAnimation(int animationId, double timeOffset); |
| 282 void removeAnimation(int animationId); | 276 void removeAnimation(int animationId); |
| 283 | 277 |
| 284 void suspendAnimations(double monotonicTime); | 278 void suspendAnimations(double monotonicTime); |
| 285 void resumeAnimations(double monotonicTime); | 279 void resumeAnimations(double monotonicTime); |
| 286 | 280 |
| 287 LayerAnimationController* layerAnimationController() { return m_layerAnimati
onController.get(); } | 281 LayerAnimationController* layerAnimationController() { return m_layerAnimati
onController.get(); } |
| 288 void setLayerAnimationController(scoped_ptr<LayerAnimationController>); | 282 void setLayerAnimationController(scoped_refptr<LayerAnimationController>); |
| 289 scoped_ptr<LayerAnimationController> releaseLayerAnimationController(); | 283 scoped_refptr<LayerAnimationController> releaseLayerAnimationController(); |
| 290 | 284 |
| 291 void setLayerAnimationDelegate(WebKit::WebAnimationDelegate* layerAnimationD
elegate) { m_layerAnimationDelegate = layerAnimationDelegate; } | 285 void setLayerAnimationDelegate(WebKit::WebAnimationDelegate* layerAnimationD
elegate) { m_layerAnimationDelegate = layerAnimationDelegate; } |
| 292 | 286 |
| 293 bool hasActiveAnimation() const; | 287 bool hasActiveAnimation() const; |
| 294 | 288 |
| 295 virtual void notifyAnimationStarted(const AnimationEvent&, double wallClockT
ime); | 289 virtual void notifyAnimationStarted(const AnimationEvent&, double wallClockT
ime); |
| 296 virtual void notifyAnimationFinished(double wallClockTime); | 290 virtual void notifyAnimationFinished(double wallClockTime); |
| 297 | 291 |
| 298 virtual Region visibleContentOpaqueRegion() const; | 292 virtual Region visibleContentOpaqueRegion() const; |
| 299 | 293 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 void removeChild(Layer*); | 339 void removeChild(Layer*); |
| 346 | 340 |
| 347 LayerList m_children; | 341 LayerList m_children; |
| 348 Layer* m_parent; | 342 Layer* m_parent; |
| 349 | 343 |
| 350 // Layer instances have a weak pointer to their LayerTreeHost. | 344 // Layer instances have a weak pointer to their LayerTreeHost. |
| 351 // This pointer value is nil when a Layer is not in a tree and is | 345 // This pointer value is nil when a Layer is not in a tree and is |
| 352 // updated via setLayerTreeHost() if a layer moves between trees. | 346 // updated via setLayerTreeHost() if a layer moves between trees. |
| 353 LayerTreeHost* m_layerTreeHost; | 347 LayerTreeHost* m_layerTreeHost; |
| 354 | 348 |
| 355 scoped_ptr<LayerAnimationController> m_layerAnimationController; | 349 scoped_refptr<LayerAnimationController> m_layerAnimationController; |
| 356 | 350 |
| 357 // Layer properties. | 351 // Layer properties. |
| 358 gfx::Size m_bounds; | 352 gfx::Size m_bounds; |
| 359 | 353 |
| 360 // Uses layer's content space. | 354 // Uses layer's content space. |
| 361 gfx::Rect m_visibleContentRect; | 355 gfx::Rect m_visibleContentRect; |
| 362 | 356 |
| 363 gfx::Vector2d m_scrollOffset; | 357 gfx::Vector2d m_scrollOffset; |
| 364 gfx::Vector2d m_maxScrollOffset; | 358 gfx::Vector2d m_maxScrollOffset; |
| 365 bool m_scrollable; | 359 bool m_scrollable; |
| 366 bool m_shouldScrollOnMainThread; | 360 bool m_shouldScrollOnMainThread; |
| 367 bool m_haveWheelEventHandlers; | 361 bool m_haveWheelEventHandlers; |
| 368 Region m_nonFastScrollableRegion; | 362 Region m_nonFastScrollableRegion; |
| 369 bool m_nonFastScrollableRegionChanged; | 363 bool m_nonFastScrollableRegionChanged; |
| 370 Region m_touchEventHandlerRegion; | 364 Region m_touchEventHandlerRegion; |
| 371 bool m_touchEventHandlerRegionChanged; | 365 bool m_touchEventHandlerRegionChanged; |
| 372 gfx::PointF m_position; | 366 gfx::PointF m_position; |
| 373 gfx::PointF m_anchorPoint; | 367 gfx::PointF m_anchorPoint; |
| 374 SkColor m_backgroundColor; | 368 SkColor m_backgroundColor; |
| 375 std::string m_debugName; | 369 std::string m_debugName; |
| 376 float m_opacity; | |
| 377 skia::RefPtr<SkImageFilter> m_filter; | 370 skia::RefPtr<SkImageFilter> m_filter; |
| 378 WebKit::WebFilterOperations m_filters; | 371 WebKit::WebFilterOperations m_filters; |
| 379 WebKit::WebFilterOperations m_backgroundFilters; | 372 WebKit::WebFilterOperations m_backgroundFilters; |
| 380 float m_anchorPointZ; | 373 float m_anchorPointZ; |
| 381 bool m_isContainerForFixedPositionLayers; | 374 bool m_isContainerForFixedPositionLayers; |
| 382 bool m_fixedToContainerLayer; | 375 bool m_fixedToContainerLayer; |
| 383 bool m_isDrawable; | 376 bool m_isDrawable; |
| 384 bool m_masksToBounds; | 377 bool m_masksToBounds; |
| 385 bool m_contentsOpaque; | 378 bool m_contentsOpaque; |
| 386 bool m_doubleSided; | 379 bool m_doubleSided; |
| 387 bool m_useLCDText; | 380 bool m_useLCDText; |
| 388 bool m_preserves3D; | 381 bool m_preserves3D; |
| 389 bool m_useParentBackfaceVisibility; | 382 bool m_useParentBackfaceVisibility; |
| 390 bool m_drawCheckerboardForMissingTiles; | 383 bool m_drawCheckerboardForMissingTiles; |
| 391 bool m_forceRenderSurface; | 384 bool m_forceRenderSurface; |
| 392 | 385 |
| 393 gfx::Transform m_transform; | |
| 394 gfx::Transform m_sublayerTransform; | 386 gfx::Transform m_sublayerTransform; |
| 395 | 387 |
| 396 // Replica layer used for reflections. | 388 // Replica layer used for reflections. |
| 397 scoped_refptr<Layer> m_replicaLayer; | 389 scoped_refptr<Layer> m_replicaLayer; |
| 398 | 390 |
| 399 // Transient properties. | 391 // Transient properties. |
| 400 scoped_ptr<RenderSurface> m_renderSurface; | 392 scoped_ptr<RenderSurface> m_renderSurface; |
| 401 float m_drawOpacity; | 393 float m_drawOpacity; |
| 402 bool m_drawOpacityIsAnimating; | 394 bool m_drawOpacityIsAnimating; |
| 403 | 395 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 423 | 415 |
| 424 WebKit::WebAnimationDelegate* m_layerAnimationDelegate; | 416 WebKit::WebAnimationDelegate* m_layerAnimationDelegate; |
| 425 WebKit::WebLayerScrollClient* m_layerScrollClient; | 417 WebKit::WebLayerScrollClient* m_layerScrollClient; |
| 426 }; | 418 }; |
| 427 | 419 |
| 428 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped
_refptr<Layer> >::iterator, void*); | 420 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped
_refptr<Layer> >::iterator, void*); |
| 429 | 421 |
| 430 } // namespace cc | 422 } // namespace cc |
| 431 | 423 |
| 432 #endif // CC_LAYER_H_ | 424 #endif // CC_LAYER_H_ |
| OLD | NEW |