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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 // properties are set. It also manages a queue of pending animations and | 114 // properties are set. It also manages a queue of pending animations and |
115 // handles blending of animations. The layer takes ownership of the animator. | 115 // handles blending of animations. The layer takes ownership of the animator. |
116 void SetAnimator(LayerAnimator* animator); | 116 void SetAnimator(LayerAnimator* animator); |
117 | 117 |
118 // Returns the layer's animator. Creates a default animator of one has not | 118 // Returns the layer's animator. Creates a default animator of one has not |
119 // been set. Will not return NULL. | 119 // been set. Will not return NULL. |
120 LayerAnimator* GetAnimator(); | 120 LayerAnimator* GetAnimator(); |
121 | 121 |
122 // The transform, relative to the parent. | 122 // The transform, relative to the parent. |
123 void SetTransform(const gfx::Transform& transform); | 123 void SetTransform(const gfx::Transform& transform); |
124 const gfx::Transform& transform() const { return transform_; } | 124 gfx::Transform transform() const; |
125 | 125 |
126 // Return the target transform if animator is running, or the current | 126 // Return the target transform if animator is running, or the current |
127 // transform otherwise. | 127 // transform otherwise. |
128 gfx::Transform GetTargetTransform() const; | 128 gfx::Transform GetTargetTransform() const; |
129 | 129 |
130 // The bounds, relative to the parent. | 130 // The bounds, relative to the parent. |
131 void SetBounds(const gfx::Rect& bounds); | 131 void SetBounds(const gfx::Rect& bounds); |
132 const gfx::Rect& bounds() const { return bounds_; } | 132 const gfx::Rect& bounds() const { return bounds_; } |
133 | 133 |
134 // Return the target bounds if animator is running, or the current bounds | 134 // 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... |
219 // and is not completely obscured by a child. | 219 // and is not completely obscured by a child. |
220 bool ShouldDraw() const; | 220 bool ShouldDraw() const; |
221 | 221 |
222 // Converts a point from the coordinates of |source| to the coordinates of | 222 // Converts a point from the coordinates of |source| to the coordinates of |
223 // |target|. Necessarily, |source| and |target| must inhabit the same Layer | 223 // |target|. Necessarily, |source| and |target| must inhabit the same Layer |
224 // tree. | 224 // tree. |
225 static void ConvertPointToLayer(const Layer* source, | 225 static void ConvertPointToLayer(const Layer* source, |
226 const Layer* target, | 226 const Layer* target, |
227 gfx::Point* point); | 227 gfx::Point* point); |
228 | 228 |
| 229 // Converts a ui::Layer's transform to the transform on the corresponding |
| 230 // cc::Layer. |
| 231 static gfx::Transform ConvertTransformToCCTransform( |
| 232 const gfx::Transform& transform, |
| 233 const gfx::Rect& bounds, |
| 234 float device_scale_factor); |
| 235 |
229 // See description in View for details | 236 // See description in View for details |
230 void SetFillsBoundsOpaquely(bool fills_bounds_opaquely); | 237 void SetFillsBoundsOpaquely(bool fills_bounds_opaquely); |
231 bool fills_bounds_opaquely() const { return fills_bounds_opaquely_; } | 238 bool fills_bounds_opaquely() const { return fills_bounds_opaquely_; } |
232 | 239 |
233 const std::string& name() const { return name_; } | 240 const std::string& name() const { return name_; } |
234 void set_name(const std::string& name) { name_ = name; } | 241 void set_name(const std::string& name) { name_ = name; } |
235 | 242 |
236 const ui::Texture* texture() const { return texture_.get(); } | 243 const ui::Texture* texture() const { return texture_.get(); } |
237 | 244 |
238 // Assigns a new external texture. |texture| can be NULL to disable external | 245 // Assigns a new external texture. |texture| can be NULL to disable external |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 virtual void SetBoundsFromAnimation(const gfx::Rect& bounds) OVERRIDE; | 343 virtual void SetBoundsFromAnimation(const gfx::Rect& bounds) OVERRIDE; |
337 virtual void SetTransformFromAnimation( | 344 virtual void SetTransformFromAnimation( |
338 const gfx::Transform& transform) OVERRIDE; | 345 const gfx::Transform& transform) OVERRIDE; |
339 virtual void SetOpacityFromAnimation(float opacity) OVERRIDE; | 346 virtual void SetOpacityFromAnimation(float opacity) OVERRIDE; |
340 virtual void SetVisibilityFromAnimation(bool visibility) OVERRIDE; | 347 virtual void SetVisibilityFromAnimation(bool visibility) OVERRIDE; |
341 virtual void SetBrightnessFromAnimation(float brightness) OVERRIDE; | 348 virtual void SetBrightnessFromAnimation(float brightness) OVERRIDE; |
342 virtual void SetGrayscaleFromAnimation(float grayscale) OVERRIDE; | 349 virtual void SetGrayscaleFromAnimation(float grayscale) OVERRIDE; |
343 virtual void SetColorFromAnimation(SkColor color) OVERRIDE; | 350 virtual void SetColorFromAnimation(SkColor color) OVERRIDE; |
344 virtual void ScheduleDrawForAnimation() OVERRIDE; | 351 virtual void ScheduleDrawForAnimation() OVERRIDE; |
345 virtual const gfx::Rect& GetBoundsForAnimation() const OVERRIDE; | 352 virtual const gfx::Rect& GetBoundsForAnimation() const OVERRIDE; |
346 virtual const gfx::Transform& GetTransformForAnimation() const OVERRIDE; | 353 virtual gfx::Transform GetTransformForAnimation() const OVERRIDE; |
347 virtual float GetOpacityForAnimation() const OVERRIDE; | 354 virtual float GetOpacityForAnimation() const OVERRIDE; |
348 virtual bool GetVisibilityForAnimation() const OVERRIDE; | 355 virtual bool GetVisibilityForAnimation() const OVERRIDE; |
349 virtual float GetBrightnessForAnimation() const OVERRIDE; | 356 virtual float GetBrightnessForAnimation() const OVERRIDE; |
350 virtual float GetGrayscaleForAnimation() const OVERRIDE; | 357 virtual float GetGrayscaleForAnimation() const OVERRIDE; |
351 virtual SkColor GetColorForAnimation() const OVERRIDE; | 358 virtual SkColor GetColorForAnimation() const OVERRIDE; |
| 359 virtual float GetDeviceScaleFactor() const OVERRIDE; |
352 virtual void AddThreadedAnimation( | 360 virtual void AddThreadedAnimation( |
353 scoped_ptr<cc::Animation> animation) OVERRIDE; | 361 scoped_ptr<cc::Animation> animation) OVERRIDE; |
354 virtual void RemoveThreadedAnimation(int animation_id) OVERRIDE; | 362 virtual void RemoveThreadedAnimation(int animation_id) OVERRIDE; |
355 | 363 |
356 void CreateWebLayer(); | 364 void CreateWebLayer(); |
357 void RecomputeTransform(); | 365 void RecomputeCCTransformFromTransform(const gfx::Transform& transform); |
358 void RecomputeDrawsContentAndUVRect(); | 366 void RecomputeDrawsContentAndUVRect(); |
359 | 367 |
360 // Set all filters which got applied to the layer. | 368 // Set all filters which got applied to the layer. |
361 void SetLayerFilters(); | 369 void SetLayerFilters(); |
362 | 370 |
363 // Set all filters which got applied to the layer background. | 371 // Set all filters which got applied to the layer background. |
364 void SetLayerBackgroundFilters(); | 372 void SetLayerBackgroundFilters(); |
365 | 373 |
366 void UpdateIsDrawn(); | 374 void UpdateIsDrawn(); |
367 | 375 |
368 void SwitchToLayer(scoped_refptr<cc::Layer> new_layer); | 376 void SwitchToLayer(scoped_refptr<cc::Layer> new_layer); |
369 | 377 |
370 // We cannot send animations to our cc_layer_ until we have been added to a | 378 // We cannot send animations to our cc_layer_ until we have been added to a |
371 // layer tree. Instead, we hold on to these animations in | 379 // layer tree. Instead, we hold on to these animations in |
372 // pending_threaded_animations_, and expect SendPendingThreadedAnimations to | 380 // pending_threaded_animations_, and expect SendPendingThreadedAnimations to |
373 // be called once we have been added to a tree. | 381 // be called once we have been added to a tree. |
374 void SendPendingThreadedAnimations(); | 382 void SendPendingThreadedAnimations(); |
375 | 383 |
376 const LayerType type_; | 384 const LayerType type_; |
377 | 385 |
378 Compositor* compositor_; | 386 Compositor* compositor_; |
379 | 387 |
380 scoped_refptr<ui::Texture> texture_; | 388 scoped_refptr<ui::Texture> texture_; |
381 | 389 |
382 Layer* parent_; | 390 Layer* parent_; |
383 | 391 |
384 // This layer's children, in bottom-to-top stacking order. | 392 // This layer's children, in bottom-to-top stacking order. |
385 std::vector<Layer*> children_; | 393 std::vector<Layer*> children_; |
386 | 394 |
387 gfx::Transform transform_; | |
388 | |
389 gfx::Rect bounds_; | 395 gfx::Rect bounds_; |
390 | 396 |
391 // Visibility of this layer. See SetVisible/IsDrawn for more details. | 397 // Visibility of this layer. See SetVisible/IsDrawn for more details. |
392 bool visible_; | 398 bool visible_; |
393 | 399 |
394 // Computed based on the visibility of this layer and its ancestors. | 400 // Computed based on the visibility of this layer and its ancestors. |
395 bool is_drawn_; | 401 bool is_drawn_; |
396 | 402 |
397 bool force_render_surface_; | 403 bool force_render_surface_; |
398 | 404 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 // The size of the delegated frame in DIP, set when SetDelegatedFrame was | 467 // The size of the delegated frame in DIP, set when SetDelegatedFrame was |
462 // called. | 468 // called. |
463 gfx::Size delegated_frame_size_in_dip_; | 469 gfx::Size delegated_frame_size_in_dip_; |
464 | 470 |
465 DISALLOW_COPY_AND_ASSIGN(Layer); | 471 DISALLOW_COPY_AND_ASSIGN(Layer); |
466 }; | 472 }; |
467 | 473 |
468 } // namespace ui | 474 } // namespace ui |
469 | 475 |
470 #endif // UI_COMPOSITOR_LAYER_H_ | 476 #endif // UI_COMPOSITOR_LAYER_H_ |
OLD | NEW |