OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 UI_COMPOSITOR_LAYER_H_ | 5 #ifndef UI_COMPOSITOR_LAYER_H_ |
6 #define UI_COMPOSITOR_LAYER_H_ | 6 #define UI_COMPOSITOR_LAYER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
| 15 #include "cc/animation_events.h" |
15 #include "cc/content_layer_client.h" | 16 #include "cc/content_layer_client.h" |
| 17 #include "cc/layer_animation_event_observer.h" |
16 #include "cc/texture_layer_client.h" | 18 #include "cc/texture_layer_client.h" |
17 #include "third_party/skia/include/core/SkColor.h" | 19 #include "third_party/skia/include/core/SkColor.h" |
18 #include "third_party/skia/include/core/SkRegion.h" | 20 #include "third_party/skia/include/core/SkRegion.h" |
19 #include "ui/compositor/compositor.h" | 21 #include "ui/compositor/compositor.h" |
20 #include "ui/compositor/layer_animation_delegate.h" | 22 #include "ui/compositor/layer_animation_delegate.h" |
21 #include "ui/compositor/layer_delegate.h" | 23 #include "ui/compositor/layer_delegate.h" |
22 #include "ui/compositor/layer_type.h" | 24 #include "ui/compositor/layer_type.h" |
23 #include "ui/gfx/rect.h" | 25 #include "ui/gfx/rect.h" |
24 #include "ui/gfx/transform.h" | 26 #include "ui/gfx/transform.h" |
25 | 27 |
(...skipping 19 matching lines...) Expand all Loading... |
45 // nothing and is simply used as a node in a hierarchy of layers. | 47 // nothing and is simply used as a node in a hierarchy of layers. |
46 // Coordinate system used in layers is DIP (Density Independent Pixel) | 48 // Coordinate system used in layers is DIP (Density Independent Pixel) |
47 // coordinates unless explicitly mentioned as pixel coordinates. | 49 // coordinates unless explicitly mentioned as pixel coordinates. |
48 // | 50 // |
49 // NOTE: unlike Views, each Layer does *not* own its children views. If you | 51 // NOTE: unlike Views, each Layer does *not* own its children views. If you |
50 // delete a Layer and it has children, the parent of each child layer is set to | 52 // delete a Layer and it has children, the parent of each child layer is set to |
51 // NULL, but the children are not deleted. | 53 // NULL, but the children are not deleted. |
52 class COMPOSITOR_EXPORT Layer | 54 class COMPOSITOR_EXPORT Layer |
53 : public LayerAnimationDelegate, | 55 : public LayerAnimationDelegate, |
54 NON_EXPORTED_BASE(public cc::ContentLayerClient), | 56 NON_EXPORTED_BASE(public cc::ContentLayerClient), |
55 NON_EXPORTED_BASE(public cc::TextureLayerClient) { | 57 NON_EXPORTED_BASE(public cc::TextureLayerClient), |
| 58 NON_EXPORTED_BASE(public cc::LayerAnimationEventObserver) { |
56 public: | 59 public: |
57 Layer(); | 60 Layer(); |
58 explicit Layer(LayerType type); | 61 explicit Layer(LayerType type); |
59 virtual ~Layer(); | 62 virtual ~Layer(); |
60 | 63 |
61 // Retrieves the Layer's compositor. The Layer will walk up its parent chain | 64 // Retrieves the Layer's compositor. The Layer will walk up its parent chain |
62 // to locate it. Returns NULL if the Layer is not attached to a compositor. | 65 // to locate it. Returns NULL if the Layer is not attached to a compositor. |
63 Compositor* GetCompositor(); | 66 Compositor* GetCompositor(); |
64 | 67 |
65 // Called by the compositor when the Layer is set as its root Layer. This can | 68 // Called by the compositor when the Layer is set as its root Layer. This can |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 // otherwise. | 130 // otherwise. |
128 gfx::Rect GetTargetBounds() const; | 131 gfx::Rect GetTargetBounds() const; |
129 | 132 |
130 // Sets/gets whether or not drawing of child layers should be clipped to the | 133 // Sets/gets whether or not drawing of child layers should be clipped to the |
131 // bounds of this layer. | 134 // bounds of this layer. |
132 void SetMasksToBounds(bool masks_to_bounds); | 135 void SetMasksToBounds(bool masks_to_bounds); |
133 bool GetMasksToBounds() const; | 136 bool GetMasksToBounds() const; |
134 | 137 |
135 // The opacity of the layer. The opacity is applied to each pixel of the | 138 // The opacity of the layer. The opacity is applied to each pixel of the |
136 // texture (resulting alpha = opacity * alpha). | 139 // texture (resulting alpha = opacity * alpha). |
137 float opacity() const { return opacity_; } | 140 float opacity() const; |
138 void SetOpacity(float opacity); | 141 void SetOpacity(float opacity); |
139 | 142 |
140 // Returns the actual opacity, which the opacity of this layer multipled by | 143 // Returns the actual opacity, which the opacity of this layer multipled by |
141 // the combined opacity of the parent. | 144 // the combined opacity of the parent. |
142 float GetCombinedOpacity() const; | 145 float GetCombinedOpacity() const; |
143 | 146 |
144 // Blur pixels by this amount in anything below the layer and visible through | 147 // Blur pixels by this amount in anything below the layer and visible through |
145 // the layer. | 148 // the layer. |
146 int background_blur() const { return background_blur_radius_; } | 149 int background_blur() const { return background_blur_radius_; } |
147 void SetBackgroundBlur(int blur_radius); | 150 void SetBackgroundBlur(int blur_radius); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 virtual unsigned prepareTexture(cc::ResourceUpdateQueue&) OVERRIDE; | 283 virtual unsigned prepareTexture(cc::ResourceUpdateQueue&) OVERRIDE; |
281 virtual WebKit::WebGraphicsContext3D* context() OVERRIDE; | 284 virtual WebKit::WebGraphicsContext3D* context() OVERRIDE; |
282 | 285 |
283 float device_scale_factor() const { return device_scale_factor_; } | 286 float device_scale_factor() const { return device_scale_factor_; } |
284 | 287 |
285 // Forces a render surface to be used on this layer. This has no positive | 288 // Forces a render surface to be used on this layer. This has no positive |
286 // impact, and is only used for benchmarking/testing purpose. | 289 // impact, and is only used for benchmarking/testing purpose. |
287 void SetForceRenderSurface(bool force); | 290 void SetForceRenderSurface(bool force); |
288 bool force_render_surface() const { return force_render_surface_; } | 291 bool force_render_surface() const { return force_render_surface_; } |
289 | 292 |
| 293 // LayerAnimationEventObserver |
| 294 virtual void OnAnimationStarted(const cc::AnimationEvent& event) OVERRIDE; |
| 295 |
290 private: | 296 private: |
291 // Stacks |child| above or below |other|. Helper method for StackAbove() and | 297 // Stacks |child| above or below |other|. Helper method for StackAbove() and |
292 // StackBelow(). | 298 // StackBelow(). |
293 void StackRelativeTo(Layer* child, Layer* other, bool above); | 299 void StackRelativeTo(Layer* child, Layer* other, bool above); |
294 | 300 |
295 bool ConvertPointForAncestor(const Layer* ancestor, gfx::Point* point) const; | 301 bool ConvertPointForAncestor(const Layer* ancestor, gfx::Point* point) const; |
296 bool ConvertPointFromAncestor(const Layer* ancestor, gfx::Point* point) const; | 302 bool ConvertPointFromAncestor(const Layer* ancestor, gfx::Point* point) const; |
297 | 303 |
298 bool GetTargetTransformRelativeTo(const Layer* ancestor, | 304 bool GetTargetTransformRelativeTo(const Layer* ancestor, |
299 gfx::Transform* transform) const; | 305 gfx::Transform* transform) const; |
(...skipping 23 matching lines...) Expand all Loading... |
323 virtual void SetGrayscaleFromAnimation(float grayscale) OVERRIDE; | 329 virtual void SetGrayscaleFromAnimation(float grayscale) OVERRIDE; |
324 virtual void SetColorFromAnimation(SkColor color) OVERRIDE; | 330 virtual void SetColorFromAnimation(SkColor color) OVERRIDE; |
325 virtual void ScheduleDrawForAnimation() OVERRIDE; | 331 virtual void ScheduleDrawForAnimation() OVERRIDE; |
326 virtual const gfx::Rect& GetBoundsForAnimation() const OVERRIDE; | 332 virtual const gfx::Rect& GetBoundsForAnimation() const OVERRIDE; |
327 virtual const gfx::Transform& GetTransformForAnimation() const OVERRIDE; | 333 virtual const gfx::Transform& GetTransformForAnimation() const OVERRIDE; |
328 virtual float GetOpacityForAnimation() const OVERRIDE; | 334 virtual float GetOpacityForAnimation() const OVERRIDE; |
329 virtual bool GetVisibilityForAnimation() const OVERRIDE; | 335 virtual bool GetVisibilityForAnimation() const OVERRIDE; |
330 virtual float GetBrightnessForAnimation() const OVERRIDE; | 336 virtual float GetBrightnessForAnimation() const OVERRIDE; |
331 virtual float GetGrayscaleForAnimation() const OVERRIDE; | 337 virtual float GetGrayscaleForAnimation() const OVERRIDE; |
332 virtual SkColor GetColorForAnimation() const OVERRIDE; | 338 virtual SkColor GetColorForAnimation() const OVERRIDE; |
| 339 virtual void AddThreadedAnimation( |
| 340 scoped_ptr<cc::Animation> animation) OVERRIDE; |
| 341 virtual void RemoveThreadedAnimation(int animation_id) OVERRIDE; |
333 | 342 |
334 void CreateWebLayer(); | 343 void CreateWebLayer(); |
335 void RecomputeTransform(); | 344 void RecomputeTransform(); |
336 void RecomputeDrawsContentAndUVRect(); | 345 void RecomputeDrawsContentAndUVRect(); |
337 | 346 |
338 // Set all filters which got applied to the layer. | 347 // Set all filters which got applied to the layer. |
339 void SetLayerFilters(); | 348 void SetLayerFilters(); |
340 | 349 |
341 // Set all filters which got applied to the layer background. | 350 // Set all filters which got applied to the layer background. |
342 void SetLayerBackgroundFilters(); | 351 void SetLayerBackgroundFilters(); |
(...skipping 25 matching lines...) Expand all Loading... |
368 | 377 |
369 bool fills_bounds_opaquely_; | 378 bool fills_bounds_opaquely_; |
370 | 379 |
371 // If true the layer is always up to date. | 380 // If true the layer is always up to date. |
372 bool layer_updated_externally_; | 381 bool layer_updated_externally_; |
373 | 382 |
374 // Union of damaged rects, in pixel coordinates, to be used when | 383 // Union of damaged rects, in pixel coordinates, to be used when |
375 // compositor is ready to paint the content. | 384 // compositor is ready to paint the content. |
376 SkRegion damaged_region_; | 385 SkRegion damaged_region_; |
377 | 386 |
378 float opacity_; | |
379 int background_blur_radius_; | 387 int background_blur_radius_; |
380 | 388 |
381 // Several variables which will change the visible representation of | 389 // Several variables which will change the visible representation of |
382 // the layer. | 390 // the layer. |
383 float layer_saturation_; | 391 float layer_saturation_; |
384 float layer_brightness_; | 392 float layer_brightness_; |
385 float layer_grayscale_; | 393 float layer_grayscale_; |
386 bool layer_inverted_; | 394 bool layer_inverted_; |
387 | 395 |
388 // The associated mask layer with this layer. | 396 // The associated mask layer with this layer. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 | 432 |
425 // A cached copy of |Compositor::device_scale_factor()|. | 433 // A cached copy of |Compositor::device_scale_factor()|. |
426 float device_scale_factor_; | 434 float device_scale_factor_; |
427 | 435 |
428 DISALLOW_COPY_AND_ASSIGN(Layer); | 436 DISALLOW_COPY_AND_ASSIGN(Layer); |
429 }; | 437 }; |
430 | 438 |
431 } // namespace ui | 439 } // namespace ui |
432 | 440 |
433 #endif // UI_COMPOSITOR_LAYER_H_ | 441 #endif // UI_COMPOSITOR_LAYER_H_ |
OLD | NEW |