| 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 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // properties are set. It also manages a queue of pending animations and | 109 // properties are set. It also manages a queue of pending animations and |
| 110 // handles blending of animations. The layer takes ownership of the animator. | 110 // handles blending of animations. The layer takes ownership of the animator. |
| 111 void SetAnimator(LayerAnimator* animator); | 111 void SetAnimator(LayerAnimator* animator); |
| 112 | 112 |
| 113 // Returns the layer's animator. Creates a default animator of one has not | 113 // Returns the layer's animator. Creates a default animator of one has not |
| 114 // been set. Will not return NULL. | 114 // been set. Will not return NULL. |
| 115 LayerAnimator* GetAnimator(); | 115 LayerAnimator* GetAnimator(); |
| 116 | 116 |
| 117 // The transform, relative to the parent. | 117 // The transform, relative to the parent. |
| 118 void SetTransform(const gfx::Transform& transform); | 118 void SetTransform(const gfx::Transform& transform); |
| 119 const gfx::Transform& transform() const { return transform_; } | 119 gfx::Transform transform() const; |
| 120 | 120 |
| 121 // Return the target transform if animator is running, or the current | 121 // Return the target transform if animator is running, or the current |
| 122 // transform otherwise. | 122 // transform otherwise. |
| 123 gfx::Transform GetTargetTransform() const; | 123 gfx::Transform GetTargetTransform() const; |
| 124 | 124 |
| 125 // The bounds, relative to the parent. | 125 // The bounds, relative to the parent. |
| 126 void SetBounds(const gfx::Rect& bounds); | 126 void SetBounds(const gfx::Rect& bounds); |
| 127 const gfx::Rect& bounds() const { return bounds_; } | 127 const gfx::Rect& bounds() const { return bounds_; } |
| 128 | 128 |
| 129 // Return the target bounds if animator is running, or the current bounds | 129 // Return the target bounds if animator is running, or the current bounds |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 // and is not completely obscured by a child. | 214 // and is not completely obscured by a child. |
| 215 bool ShouldDraw() const; | 215 bool ShouldDraw() const; |
| 216 | 216 |
| 217 // Converts a point from the coordinates of |source| to the coordinates of | 217 // Converts a point from the coordinates of |source| to the coordinates of |
| 218 // |target|. Necessarily, |source| and |target| must inhabit the same Layer | 218 // |target|. Necessarily, |source| and |target| must inhabit the same Layer |
| 219 // tree. | 219 // tree. |
| 220 static void ConvertPointToLayer(const Layer* source, | 220 static void ConvertPointToLayer(const Layer* source, |
| 221 const Layer* target, | 221 const Layer* target, |
| 222 gfx::Point* point); | 222 gfx::Point* point); |
| 223 | 223 |
| 224 // Converts a ui::Layer's transform to the transform on the corresponding |
| 225 // cc::Layer. |
| 226 static gfx::Transform ConvertTransformToCCTransform( |
| 227 const gfx::Transform& transform, |
| 228 const gfx::Rect& bounds, |
| 229 float device_scale_factor); |
| 230 |
| 224 // See description in View for details | 231 // See description in View for details |
| 225 void SetFillsBoundsOpaquely(bool fills_bounds_opaquely); | 232 void SetFillsBoundsOpaquely(bool fills_bounds_opaquely); |
| 226 bool fills_bounds_opaquely() const { return fills_bounds_opaquely_; } | 233 bool fills_bounds_opaquely() const { return fills_bounds_opaquely_; } |
| 227 | 234 |
| 228 const std::string& name() const { return name_; } | 235 const std::string& name() const { return name_; } |
| 229 void set_name(const std::string& name) { name_ = name; } | 236 void set_name(const std::string& name) { name_ = name; } |
| 230 | 237 |
| 231 const ui::Texture* texture() const { return texture_.get(); } | 238 const ui::Texture* texture() const { return texture_.get(); } |
| 232 | 239 |
| 233 // Assigns a new external texture. |texture| can be NULL to disable external | 240 // Assigns a new external texture. |texture| can be NULL to disable external |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 virtual void SetBoundsFromAnimation(const gfx::Rect& bounds) OVERRIDE; | 330 virtual void SetBoundsFromAnimation(const gfx::Rect& bounds) OVERRIDE; |
| 324 virtual void SetTransformFromAnimation( | 331 virtual void SetTransformFromAnimation( |
| 325 const gfx::Transform& transform) OVERRIDE; | 332 const gfx::Transform& transform) OVERRIDE; |
| 326 virtual void SetOpacityFromAnimation(float opacity) OVERRIDE; | 333 virtual void SetOpacityFromAnimation(float opacity) OVERRIDE; |
| 327 virtual void SetVisibilityFromAnimation(bool visibility) OVERRIDE; | 334 virtual void SetVisibilityFromAnimation(bool visibility) OVERRIDE; |
| 328 virtual void SetBrightnessFromAnimation(float brightness) OVERRIDE; | 335 virtual void SetBrightnessFromAnimation(float brightness) OVERRIDE; |
| 329 virtual void SetGrayscaleFromAnimation(float grayscale) OVERRIDE; | 336 virtual void SetGrayscaleFromAnimation(float grayscale) OVERRIDE; |
| 330 virtual void SetColorFromAnimation(SkColor color) OVERRIDE; | 337 virtual void SetColorFromAnimation(SkColor color) OVERRIDE; |
| 331 virtual void ScheduleDrawForAnimation() OVERRIDE; | 338 virtual void ScheduleDrawForAnimation() OVERRIDE; |
| 332 virtual const gfx::Rect& GetBoundsForAnimation() const OVERRIDE; | 339 virtual const gfx::Rect& GetBoundsForAnimation() const OVERRIDE; |
| 333 virtual const gfx::Transform& GetTransformForAnimation() const OVERRIDE; | 340 virtual gfx::Transform GetTransformForAnimation() const OVERRIDE; |
| 334 virtual float GetOpacityForAnimation() const OVERRIDE; | 341 virtual float GetOpacityForAnimation() const OVERRIDE; |
| 335 virtual bool GetVisibilityForAnimation() const OVERRIDE; | 342 virtual bool GetVisibilityForAnimation() const OVERRIDE; |
| 336 virtual float GetBrightnessForAnimation() const OVERRIDE; | 343 virtual float GetBrightnessForAnimation() const OVERRIDE; |
| 337 virtual float GetGrayscaleForAnimation() const OVERRIDE; | 344 virtual float GetGrayscaleForAnimation() const OVERRIDE; |
| 338 virtual SkColor GetColorForAnimation() const OVERRIDE; | 345 virtual SkColor GetColorForAnimation() const OVERRIDE; |
| 346 virtual float GetDeviceScaleFactor() const OVERRIDE; |
| 339 virtual void AddThreadedAnimation( | 347 virtual void AddThreadedAnimation( |
| 340 scoped_ptr<cc::Animation> animation) OVERRIDE; | 348 scoped_ptr<cc::Animation> animation) OVERRIDE; |
| 341 virtual void RemoveThreadedAnimation(int animation_id) OVERRIDE; | 349 virtual void RemoveThreadedAnimation(int animation_id) OVERRIDE; |
| 342 | 350 |
| 343 void CreateWebLayer(); | 351 void CreateWebLayer(); |
| 344 void RecomputeTransform(); | 352 void RecomputeCCTransformFromTransform(const gfx::Transform& transform); |
| 345 void RecomputeDrawsContentAndUVRect(); | 353 void RecomputeDrawsContentAndUVRect(); |
| 346 | 354 |
| 347 // Set all filters which got applied to the layer. | 355 // Set all filters which got applied to the layer. |
| 348 void SetLayerFilters(); | 356 void SetLayerFilters(); |
| 349 | 357 |
| 350 // Set all filters which got applied to the layer background. | 358 // Set all filters which got applied to the layer background. |
| 351 void SetLayerBackgroundFilters(); | 359 void SetLayerBackgroundFilters(); |
| 352 | 360 |
| 353 void UpdateIsDrawn(); | 361 void UpdateIsDrawn(); |
| 354 | 362 |
| 355 const LayerType type_; | 363 const LayerType type_; |
| 356 | 364 |
| 357 Compositor* compositor_; | 365 Compositor* compositor_; |
| 358 | 366 |
| 359 scoped_refptr<ui::Texture> texture_; | 367 scoped_refptr<ui::Texture> texture_; |
| 360 | 368 |
| 361 Layer* parent_; | 369 Layer* parent_; |
| 362 | 370 |
| 363 // This layer's children, in bottom-to-top stacking order. | 371 // This layer's children, in bottom-to-top stacking order. |
| 364 std::vector<Layer*> children_; | 372 std::vector<Layer*> children_; |
| 365 | 373 |
| 366 gfx::Transform transform_; | |
| 367 | |
| 368 gfx::Rect bounds_; | 374 gfx::Rect bounds_; |
| 369 | 375 |
| 370 // Visibility of this layer. See SetVisible/IsDrawn for more details. | 376 // Visibility of this layer. See SetVisible/IsDrawn for more details. |
| 371 bool visible_; | 377 bool visible_; |
| 372 | 378 |
| 373 // Computed based on the visibility of this layer and its ancestors. | 379 // Computed based on the visibility of this layer and its ancestors. |
| 374 bool is_drawn_; | 380 bool is_drawn_; |
| 375 | 381 |
| 376 bool force_render_surface_; | 382 bool force_render_surface_; |
| 377 | 383 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 | 438 |
| 433 // A cached copy of |Compositor::device_scale_factor()|. | 439 // A cached copy of |Compositor::device_scale_factor()|. |
| 434 float device_scale_factor_; | 440 float device_scale_factor_; |
| 435 | 441 |
| 436 DISALLOW_COPY_AND_ASSIGN(Layer); | 442 DISALLOW_COPY_AND_ASSIGN(Layer); |
| 437 }; | 443 }; |
| 438 | 444 |
| 439 } // namespace ui | 445 } // namespace ui |
| 440 | 446 |
| 441 #endif // UI_COMPOSITOR_LAYER_H_ | 447 #endif // UI_COMPOSITOR_LAYER_H_ |
| OLD | NEW |