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(SkImageFilter* filter); | 98 void setFilter(SkImageFilter* filter); |
106 SkImageFilter* filter() const { return m_filter; } | 99 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 virtual void setTexturePriorities(const PriorityCalculator&) { } | 270 virtual void setTexturePriorities(const PriorityCalculator&) { } |
277 | 271 |
278 bool addAnimation(scoped_ptr<ActiveAnimation>); | 272 bool addAnimation(scoped_ptr<ActiveAnimation>); |
279 void pauseAnimation(int animationId, double timeOffset); | 273 void pauseAnimation(int animationId, double timeOffset); |
280 void removeAnimation(int animationId); | 274 void removeAnimation(int animationId); |
281 | 275 |
282 void suspendAnimations(double monotonicTime); | 276 void suspendAnimations(double monotonicTime); |
283 void resumeAnimations(double monotonicTime); | 277 void resumeAnimations(double monotonicTime); |
284 | 278 |
285 LayerAnimationController* layerAnimationController() { return m_layerAnimati
onController.get(); } | 279 LayerAnimationController* layerAnimationController() { return m_layerAnimati
onController.get(); } |
286 void setLayerAnimationController(scoped_ptr<LayerAnimationController>); | 280 void setLayerAnimationController(scoped_refptr<LayerAnimationController>); |
287 scoped_ptr<LayerAnimationController> releaseLayerAnimationController(); | 281 scoped_refptr<LayerAnimationController> releaseLayerAnimationController(); |
288 | 282 |
289 void setLayerAnimationDelegate(WebKit::WebAnimationDelegate* layerAnimationD
elegate) { m_layerAnimationDelegate = layerAnimationDelegate; } | 283 void setLayerAnimationDelegate(WebKit::WebAnimationDelegate* layerAnimationD
elegate) { m_layerAnimationDelegate = layerAnimationDelegate; } |
290 | 284 |
291 bool hasActiveAnimation() const; | 285 bool hasActiveAnimation() const; |
292 | 286 |
293 virtual void notifyAnimationStarted(const AnimationEvent&, double wallClockT
ime); | 287 virtual void notifyAnimationStarted(const AnimationEvent&, double wallClockT
ime); |
294 virtual void notifyAnimationFinished(double wallClockTime); | 288 virtual void notifyAnimationFinished(double wallClockTime); |
295 | 289 |
296 virtual Region visibleContentOpaqueRegion() const; | 290 virtual Region visibleContentOpaqueRegion() const; |
297 | 291 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 void removeChild(Layer*); | 336 void removeChild(Layer*); |
343 | 337 |
344 LayerList m_children; | 338 LayerList m_children; |
345 Layer* m_parent; | 339 Layer* m_parent; |
346 | 340 |
347 // Layer instances have a weak pointer to their LayerTreeHost. | 341 // Layer instances have a weak pointer to their LayerTreeHost. |
348 // This pointer value is nil when a Layer is not in a tree and is | 342 // This pointer value is nil when a Layer is not in a tree and is |
349 // updated via setLayerTreeHost() if a layer moves between trees. | 343 // updated via setLayerTreeHost() if a layer moves between trees. |
350 LayerTreeHost* m_layerTreeHost; | 344 LayerTreeHost* m_layerTreeHost; |
351 | 345 |
352 scoped_ptr<LayerAnimationController> m_layerAnimationController; | 346 scoped_refptr<LayerAnimationController> m_layerAnimationController; |
353 | 347 |
354 // Layer properties. | 348 // Layer properties. |
355 gfx::Size m_bounds; | 349 gfx::Size m_bounds; |
356 | 350 |
357 // Uses layer's content space. | 351 // Uses layer's content space. |
358 gfx::Rect m_visibleContentRect; | 352 gfx::Rect m_visibleContentRect; |
359 | 353 |
360 gfx::Vector2d m_scrollOffset; | 354 gfx::Vector2d m_scrollOffset; |
361 gfx::Vector2d m_maxScrollOffset; | 355 gfx::Vector2d m_maxScrollOffset; |
362 bool m_scrollable; | 356 bool m_scrollable; |
363 bool m_shouldScrollOnMainThread; | 357 bool m_shouldScrollOnMainThread; |
364 bool m_haveWheelEventHandlers; | 358 bool m_haveWheelEventHandlers; |
365 Region m_nonFastScrollableRegion; | 359 Region m_nonFastScrollableRegion; |
366 bool m_nonFastScrollableRegionChanged; | 360 bool m_nonFastScrollableRegionChanged; |
367 Region m_touchEventHandlerRegion; | 361 Region m_touchEventHandlerRegion; |
368 bool m_touchEventHandlerRegionChanged; | 362 bool m_touchEventHandlerRegionChanged; |
369 gfx::PointF m_position; | 363 gfx::PointF m_position; |
370 gfx::PointF m_anchorPoint; | 364 gfx::PointF m_anchorPoint; |
371 SkColor m_backgroundColor; | 365 SkColor m_backgroundColor; |
372 std::string m_debugName; | 366 std::string m_debugName; |
373 float m_opacity; | 367 float m_opacity; |
| 368 base::TimeTicks m_opacityLastUpdateTime; |
374 SkImageFilter* m_filter; | 369 SkImageFilter* m_filter; |
375 WebKit::WebFilterOperations m_filters; | 370 WebKit::WebFilterOperations m_filters; |
376 WebKit::WebFilterOperations m_backgroundFilters; | 371 WebKit::WebFilterOperations m_backgroundFilters; |
377 float m_anchorPointZ; | 372 float m_anchorPointZ; |
378 bool m_isContainerForFixedPositionLayers; | 373 bool m_isContainerForFixedPositionLayers; |
379 bool m_fixedToContainerLayer; | 374 bool m_fixedToContainerLayer; |
380 bool m_isDrawable; | 375 bool m_isDrawable; |
381 bool m_masksToBounds; | 376 bool m_masksToBounds; |
382 bool m_contentsOpaque; | 377 bool m_contentsOpaque; |
383 bool m_doubleSided; | 378 bool m_doubleSided; |
384 bool m_useLCDText; | 379 bool m_useLCDText; |
385 bool m_preserves3D; | 380 bool m_preserves3D; |
386 bool m_useParentBackfaceVisibility; | 381 bool m_useParentBackfaceVisibility; |
387 bool m_drawCheckerboardForMissingTiles; | 382 bool m_drawCheckerboardForMissingTiles; |
388 bool m_forceRenderSurface; | 383 bool m_forceRenderSurface; |
389 | 384 |
390 gfx::Transform m_transform; | 385 gfx::Transform m_transform; |
| 386 base::TimeTicks m_transformLastUpdateTime; |
391 gfx::Transform m_sublayerTransform; | 387 gfx::Transform m_sublayerTransform; |
392 | 388 |
393 // Replica layer used for reflections. | 389 // Replica layer used for reflections. |
394 scoped_refptr<Layer> m_replicaLayer; | 390 scoped_refptr<Layer> m_replicaLayer; |
395 | 391 |
396 // Transient properties. | 392 // Transient properties. |
397 scoped_ptr<RenderSurface> m_renderSurface; | 393 scoped_ptr<RenderSurface> m_renderSurface; |
398 float m_drawOpacity; | 394 float m_drawOpacity; |
399 bool m_drawOpacityIsAnimating; | 395 bool m_drawOpacityIsAnimating; |
400 | 396 |
(...skipping 19 matching lines...) Expand all Loading... |
420 | 416 |
421 WebKit::WebAnimationDelegate* m_layerAnimationDelegate; | 417 WebKit::WebAnimationDelegate* m_layerAnimationDelegate; |
422 WebKit::WebLayerScrollClient* m_layerScrollClient; | 418 WebKit::WebLayerScrollClient* m_layerScrollClient; |
423 }; | 419 }; |
424 | 420 |
425 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped
_refptr<Layer> >::iterator, void*); | 421 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped
_refptr<Layer> >::iterator, void*); |
426 | 422 |
427 } // namespace cc | 423 } // namespace cc |
428 | 424 |
429 #endif // CC_LAYER_H_ | 425 #endif // CC_LAYER_H_ |
OLD | NEW |