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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 // The layer's animator is responsible for causing automatic animations when | 101 // The layer's animator is responsible for causing automatic animations when |
102 // properties are set. It also manages a queue of pending animations and | 102 // properties are set. It also manages a queue of pending animations and |
103 // handles blending of animations. The layer takes ownership of the animator. | 103 // handles blending of animations. The layer takes ownership of the animator. |
104 void SetAnimator(LayerAnimator* animator); | 104 void SetAnimator(LayerAnimator* animator); |
105 | 105 |
106 // Returns the layer's animator. Creates a default animator of one has not | 106 // Returns the layer's animator. Creates a default animator of one has not |
107 // been set. Will not return NULL. | 107 // been set. Will not return NULL. |
108 LayerAnimator* GetAnimator(); | 108 LayerAnimator* GetAnimator(); |
109 | 109 |
110 // The transform, relative to the parent. | 110 // The transform, relative to the parent. |
111 void SetTransform(const Transform& transform); | 111 void SetTransform(const gfx::Transform& transform); |
112 const Transform& transform() const { return transform_; } | 112 const gfx::Transform& transform() const { return transform_; } |
113 | 113 |
114 // Return the target transform if animator is running, or the current | 114 // Return the target transform if animator is running, or the current |
115 // transform otherwise. | 115 // transform otherwise. |
116 Transform GetTargetTransform() const; | 116 gfx::Transform GetTargetTransform() const; |
117 | 117 |
118 // The bounds, relative to the parent. | 118 // The bounds, relative to the parent. |
119 void SetBounds(const gfx::Rect& bounds); | 119 void SetBounds(const gfx::Rect& bounds); |
120 const gfx::Rect& bounds() const { return bounds_; } | 120 const gfx::Rect& bounds() const { return bounds_; } |
121 | 121 |
122 // Return the target bounds if animator is running, or the current bounds | 122 // Return the target bounds if animator is running, or the current bounds |
123 // otherwise. | 123 // otherwise. |
124 gfx::Rect GetTargetBounds() const; | 124 gfx::Rect GetTargetBounds() const; |
125 | 125 |
126 // Sets/gets whether or not drawing of child layers should be clipped to the | 126 // Sets/gets whether or not drawing of child layers should be clipped to the |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 | 280 |
281 private: | 281 private: |
282 // Stacks |child| above or below |other|. Helper method for StackAbove() and | 282 // Stacks |child| above or below |other|. Helper method for StackAbove() and |
283 // StackBelow(). | 283 // StackBelow(). |
284 void StackRelativeTo(Layer* child, Layer* other, bool above); | 284 void StackRelativeTo(Layer* child, Layer* other, bool above); |
285 | 285 |
286 bool ConvertPointForAncestor(const Layer* ancestor, gfx::Point* point) const; | 286 bool ConvertPointForAncestor(const Layer* ancestor, gfx::Point* point) const; |
287 bool ConvertPointFromAncestor(const Layer* ancestor, gfx::Point* point) const; | 287 bool ConvertPointFromAncestor(const Layer* ancestor, gfx::Point* point) const; |
288 | 288 |
289 bool GetTransformRelativeTo(const Layer* ancestor, | 289 bool GetTransformRelativeTo(const Layer* ancestor, |
290 Transform* transform) const; | 290 gfx::Transform* transform) const; |
291 | 291 |
292 // The only externally updated layers are ones that get their pixels from | 292 // The only externally updated layers are ones that get their pixels from |
293 // WebKit and WebKit does not produce valid alpha values. All other layers | 293 // WebKit and WebKit does not produce valid alpha values. All other layers |
294 // should have valid alpha. | 294 // should have valid alpha. |
295 bool has_valid_alpha_channel() const { return !layer_updated_externally_; } | 295 bool has_valid_alpha_channel() const { return !layer_updated_externally_; } |
296 | 296 |
297 // Following are invoked from the animation or if no animation exists to | 297 // Following are invoked from the animation or if no animation exists to |
298 // update the values immediately. | 298 // update the values immediately. |
299 void SetBoundsImmediately(const gfx::Rect& bounds); | 299 void SetBoundsImmediately(const gfx::Rect& bounds); |
300 void SetTransformImmediately(const ui::Transform& transform); | 300 void SetTransformImmediately(const gfx::Transform& transform); |
301 void SetOpacityImmediately(float opacity); | 301 void SetOpacityImmediately(float opacity); |
302 void SetVisibilityImmediately(bool visibility); | 302 void SetVisibilityImmediately(bool visibility); |
303 void SetBrightnessImmediately(float brightness); | 303 void SetBrightnessImmediately(float brightness); |
304 void SetGrayscaleImmediately(float grayscale); | 304 void SetGrayscaleImmediately(float grayscale); |
305 void SetColorImmediately(SkColor color); | 305 void SetColorImmediately(SkColor color); |
306 | 306 |
307 // Implementation of LayerAnimatorDelegate | 307 // Implementation of LayerAnimatorDelegate |
308 virtual void SetBoundsFromAnimation(const gfx::Rect& bounds) OVERRIDE; | 308 virtual void SetBoundsFromAnimation(const gfx::Rect& bounds) OVERRIDE; |
309 virtual void SetTransformFromAnimation(const Transform& transform) OVERRIDE; | 309 virtual void SetTransformFromAnimation( |
| 310 const gfx::Transform& transform) OVERRIDE; |
310 virtual void SetOpacityFromAnimation(float opacity) OVERRIDE; | 311 virtual void SetOpacityFromAnimation(float opacity) OVERRIDE; |
311 virtual void SetVisibilityFromAnimation(bool visibility) OVERRIDE; | 312 virtual void SetVisibilityFromAnimation(bool visibility) OVERRIDE; |
312 virtual void SetBrightnessFromAnimation(float brightness) OVERRIDE; | 313 virtual void SetBrightnessFromAnimation(float brightness) OVERRIDE; |
313 virtual void SetGrayscaleFromAnimation(float grayscale) OVERRIDE; | 314 virtual void SetGrayscaleFromAnimation(float grayscale) OVERRIDE; |
314 virtual void SetColorFromAnimation(SkColor color) OVERRIDE; | 315 virtual void SetColorFromAnimation(SkColor color) OVERRIDE; |
315 virtual void ScheduleDrawForAnimation() OVERRIDE; | 316 virtual void ScheduleDrawForAnimation() OVERRIDE; |
316 virtual const gfx::Rect& GetBoundsForAnimation() const OVERRIDE; | 317 virtual const gfx::Rect& GetBoundsForAnimation() const OVERRIDE; |
317 virtual const Transform& GetTransformForAnimation() const OVERRIDE; | 318 virtual const gfx::Transform& GetTransformForAnimation() const OVERRIDE; |
318 virtual float GetOpacityForAnimation() const OVERRIDE; | 319 virtual float GetOpacityForAnimation() const OVERRIDE; |
319 virtual bool GetVisibilityForAnimation() const OVERRIDE; | 320 virtual bool GetVisibilityForAnimation() const OVERRIDE; |
320 virtual float GetBrightnessForAnimation() const OVERRIDE; | 321 virtual float GetBrightnessForAnimation() const OVERRIDE; |
321 virtual float GetGrayscaleForAnimation() const OVERRIDE; | 322 virtual float GetGrayscaleForAnimation() const OVERRIDE; |
322 virtual SkColor GetColorForAnimation() const OVERRIDE; | 323 virtual SkColor GetColorForAnimation() const OVERRIDE; |
323 | 324 |
324 void CreateWebLayer(); | 325 void CreateWebLayer(); |
325 void RecomputeTransform(); | 326 void RecomputeTransform(); |
326 void RecomputeDrawsContentAndUVRect(); | 327 void RecomputeDrawsContentAndUVRect(); |
327 void RecomputeDebugBorderColor(); | 328 void RecomputeDebugBorderColor(); |
328 | 329 |
329 // Set all filters which got applied to the layer. | 330 // Set all filters which got applied to the layer. |
330 void SetLayerFilters(); | 331 void SetLayerFilters(); |
331 | 332 |
332 const LayerType type_; | 333 const LayerType type_; |
333 | 334 |
334 Compositor* compositor_; | 335 Compositor* compositor_; |
335 | 336 |
336 scoped_refptr<ui::Texture> texture_; | 337 scoped_refptr<ui::Texture> texture_; |
337 | 338 |
338 Layer* parent_; | 339 Layer* parent_; |
339 | 340 |
340 // This layer's children, in bottom-to-top stacking order. | 341 // This layer's children, in bottom-to-top stacking order. |
341 std::vector<Layer*> children_; | 342 std::vector<Layer*> children_; |
342 | 343 |
343 ui::Transform transform_; | 344 gfx::Transform transform_; |
344 | 345 |
345 gfx::Rect bounds_; | 346 gfx::Rect bounds_; |
346 | 347 |
347 // Visibility of this layer. See SetVisible/IsDrawn for more details. | 348 // Visibility of this layer. See SetVisible/IsDrawn for more details. |
348 bool visible_; | 349 bool visible_; |
349 | 350 |
350 bool force_render_surface_; | 351 bool force_render_surface_; |
351 | 352 |
352 bool fills_bounds_opaquely_; | 353 bool fills_bounds_opaquely_; |
353 | 354 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 | 397 |
397 // A cached copy of |Compositor::device_scale_factor()|. | 398 // A cached copy of |Compositor::device_scale_factor()|. |
398 float device_scale_factor_; | 399 float device_scale_factor_; |
399 | 400 |
400 DISALLOW_COPY_AND_ASSIGN(Layer); | 401 DISALLOW_COPY_AND_ASSIGN(Layer); |
401 }; | 402 }; |
402 | 403 |
403 } // namespace ui | 404 } // namespace ui |
404 | 405 |
405 #endif // UI_COMPOSITOR_LAYER_H_ | 406 #endif // UI_COMPOSITOR_LAYER_H_ |
OLD | NEW |