| 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 214 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 | 428 |
| 420 // A cached copy of |Compositor::device_scale_factor()|. | 429 // A cached copy of |Compositor::device_scale_factor()|. |
| 421 float device_scale_factor_; | 430 float device_scale_factor_; |
| 422 | 431 |
| 423 DISALLOW_COPY_AND_ASSIGN(Layer); | 432 DISALLOW_COPY_AND_ASSIGN(Layer); |
| 424 }; | 433 }; |
| 425 | 434 |
| 426 } // namespace ui | 435 } // namespace ui |
| 427 | 436 |
| 428 #endif // UI_COMPOSITOR_LAYER_H_ | 437 #endif // UI_COMPOSITOR_LAYER_H_ |
| OLD | NEW |