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