Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: ui/gfx/compositor/layer.h

Issue 8400059: Revert 107715 - Enable the new layer animation framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/compositor/dummy_layer_animation_delegate.cc ('k') | ui/gfx/compositor/layer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_GFX_COMPOSITOR_LAYER_H_ 5 #ifndef UI_GFX_COMPOSITOR_LAYER_H_
6 #define UI_GFX_COMPOSITOR_LAYER_H_ 6 #define UI_GFX_COMPOSITOR_LAYER_H_
7 #pragma once 7 #pragma once
8 8
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 "third_party/WebKit/Source/WebKit/chromium/public/WebContentLayerClient .h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContentLayerClient .h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebLayer.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebLayer.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebLayerClient.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebLayerClient.h"
18 #include "ui/gfx/rect.h" 18 #include "ui/gfx/rect.h"
19 #include "ui/gfx/transform.h" 19 #include "ui/gfx/transform.h"
20 #include "ui/gfx/compositor/compositor.h" 20 #include "ui/gfx/compositor/compositor.h"
21 #include "ui/gfx/compositor/layer_animation_manager.h"
21 #include "ui/gfx/compositor/layer_animator_delegate.h" 22 #include "ui/gfx/compositor/layer_animator_delegate.h"
22 #include "ui/gfx/compositor/layer_delegate.h" 23 #include "ui/gfx/compositor/layer_delegate.h"
23 24
24 class SkCanvas; 25 class SkCanvas;
25 26
26 namespace ui { 27 namespace ui {
27 28
29 class Animation;
28 class Compositor; 30 class Compositor;
29 class LayerAnimator;
30 class LayerAnimationSequence;
31 class Texture; 31 class Texture;
32 32
33 // Layer manages a texture, transform and a set of child Layers. Any View that 33 // Layer manages a texture, transform and a set of child Layers. Any View that
34 // has enabled layers ends up creating a Layer to manage the texture. 34 // has enabled layers ends up creating a Layer to manage the texture.
35 // A Layer can also be created without a texture, in which case it renders 35 // A Layer can also be created without a texture, in which case it renders
36 // nothing and is simply used as a node in a hierarchy of layers. 36 // nothing and is simply used as a node in a hierarchy of layers.
37 // 37 //
38 // NOTE: unlike Views, each Layer does *not* own its children views. If you 38 // NOTE: unlike Views, each Layer does *not* own its children views. If you
39 // delete a Layer and it has children, the parent of each child layer is set to 39 // delete a Layer and it has children, the parent of each child layer is set to
40 // NULL, but the children are not deleted. 40 // NULL, but the children are not deleted.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // Returns the child Layers. 77 // Returns the child Layers.
78 const std::vector<Layer*>& children() const { return children_; } 78 const std::vector<Layer*>& children() const { return children_; }
79 79
80 // The parent. 80 // The parent.
81 const Layer* parent() const { return parent_; } 81 const Layer* parent() const { return parent_; }
82 Layer* parent() { return parent_; } 82 Layer* parent() { return parent_; }
83 83
84 // Returns true if this Layer contains |other| somewhere in its children. 84 // Returns true if this Layer contains |other| somewhere in its children.
85 bool Contains(const Layer* other) const; 85 bool Contains(const Layer* other) const;
86 86
87 // The layer's animator is responsible for causing automatic animations when 87 // Sets the animation to use for changes to opacity, position or transform.
88 // properties are set. It also manages a queue of pending animations and 88 // That is, if you invoke this with non-NULL |animation| is started and any
89 // handles blending of animations. The layer takes ownership of the animator. 89 // changes to opacity, position or transform are animated between the current
90 void SetAnimator(LayerAnimator* animator); 90 // value and target value. If the current animation is NULL or completed,
91 91 // changes are immediate. If the opacity, transform or bounds are changed
92 // Returns the layer's animator. Creates a default animator of one has not 92 // and the animation is part way through, the animation is canceled and
93 // been set. Will not return NULL. 93 // the bounds, opacity and transfrom and set to the target value.
94 LayerAnimator* GetAnimator(); 94 // Layer takes ownership of |animation| and installs it's own delegate on the
95 // animation.
96 void SetAnimation(Animation* animation);
97 bool has_animation() const { return animator_.get() != NULL; }
95 98
96 // The transform, relative to the parent. 99 // The transform, relative to the parent.
97 void SetTransform(const Transform& transform); 100 void SetTransform(const ui::Transform& transform);
98 const Transform& transform() const { return transform_; } 101 const ui::Transform& transform() const { return transform_; }
99
100 // Return the target transform if animator is running, or the current
101 // transform otherwise.
102 Transform GetTargetTransform() const;
103 102
104 // The bounds, relative to the parent. 103 // The bounds, relative to the parent.
105 void SetBounds(const gfx::Rect& bounds); 104 void SetBounds(const gfx::Rect& bounds);
106 const gfx::Rect& bounds() const { return bounds_; } 105 const gfx::Rect& bounds() const { return bounds_; }
107 106
108 // Return the target bounds if animator is running, or the current bounds 107 // Return the target bounds if animator is running, or the current bounds
109 // otherwise. 108 // otherwise.
110 gfx::Rect GetTargetBounds() const; 109 gfx::Rect GetTargetBounds() const;
111 110
112 // The opacity of the layer. The opacity is applied to each pixel of the 111 // The opacity of the layer. The opacity is applied to each pixel of the
113 // texture (resulting alpha = opacity * alpha). 112 // texture (resulting alpha = opacity * alpha).
114 float opacity() const { return opacity_; } 113 float opacity() const { return opacity_; }
115 void SetOpacity(float opacity); 114 void SetOpacity(float opacity);
116 115
117 // Return the target opacity if animator is running, or the current bounds
118 // otherwise.
119 float GetTargetOpacity() const;
120
121 // Sets the visibility of the Layer. A Layer may be visible but not 116 // Sets the visibility of the Layer. A Layer may be visible but not
122 // drawn. This happens if any ancestor of a Layer is not visible. 117 // drawn. This happens if any ancestor of a Layer is not visible.
123 void SetVisible(bool visible); 118 void SetVisible(bool visible);
124 bool visible() const { return visible_; } 119 bool visible() const { return visible_; }
125 120
126 // Returns true if this Layer is drawn. A Layer is drawn only if all ancestors 121 // Returns true if this Layer is drawn. A Layer is drawn only if all ancestors
127 // are visible. 122 // are visible.
128 bool IsDrawn() const; 123 bool IsDrawn() const;
129 124
130 // Returns true if this layer can have a texture (has_texture_ is true) 125 // Returns true if this layer can have a texture (has_texture_ is true)
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 bool ConvertPointFromAncestor(const Layer* ancestor, gfx::Point* point) const; 255 bool ConvertPointFromAncestor(const Layer* ancestor, gfx::Point* point) const;
261 256
262 bool GetTransformRelativeTo(const Layer* ancestor, 257 bool GetTransformRelativeTo(const Layer* ancestor,
263 Transform* transform) const; 258 Transform* transform) const;
264 259
265 // The only externally updated layers are ones that get their pixels from 260 // The only externally updated layers are ones that get their pixels from
266 // WebKit and WebKit does not produce valid alpha values. All other layers 261 // WebKit and WebKit does not produce valid alpha values. All other layers
267 // should have valid alpha. 262 // should have valid alpha.
268 bool has_valid_alpha_channel() const { return !layer_updated_externally_; } 263 bool has_valid_alpha_channel() const { return !layer_updated_externally_; }
269 264
265 // If the animation is running and has progressed, it is stopped and all
266 // properties that are animated (except |property|) are immediately set to
267 // their target value.
268 void StopAnimatingIfNecessary(
269 LayerAnimationManager::AnimationProperty property);
270
270 // Following are invoked from the animation or if no animation exists to 271 // Following are invoked from the animation or if no animation exists to
271 // update the values immediately. 272 // update the values immediately.
272 void SetBoundsImmediately(const gfx::Rect& bounds); 273 void SetBoundsImmediately(const gfx::Rect& bounds);
273 void SetTransformImmediately(const ui::Transform& transform); 274 void SetTransformImmediately(const ui::Transform& transform);
274 void SetOpacityImmediately(float opacity); 275 void SetOpacityImmediately(float opacity);
275 276
276 // Implementation of LayerAnimatorDelegate 277 // LayerAnimatorDelegate overrides:
277 virtual void SetBoundsFromAnimation(const gfx::Rect& bounds) OVERRIDE; 278 virtual void SetBoundsFromAnimator(const gfx::Rect& bounds) OVERRIDE;
278 virtual void SetTransformFromAnimation(const Transform& transform) OVERRIDE; 279 virtual void SetTransformFromAnimator(const Transform& transform) OVERRIDE;
279 virtual void SetOpacityFromAnimation(float opacity) OVERRIDE; 280 virtual void SetOpacityFromAnimator(float opacity) OVERRIDE;
280 virtual void ScheduleDrawForAnimation() OVERRIDE;
281 virtual const gfx::Rect& GetBoundsForAnimation() const OVERRIDE;
282 virtual const Transform& GetTransformForAnimation() const OVERRIDE;
283 virtual float GetOpacityForAnimation() const OVERRIDE;
284 virtual void OnLayerAnimationEnded(LayerAnimationSequence* sequence) OVERRIDE;
285 281
286 #if defined(USE_WEBKIT_COMPOSITOR) 282 #if defined(USE_WEBKIT_COMPOSITOR)
287 void CreateWebLayer(); 283 void CreateWebLayer();
288 void RecomputeTransform(); 284 void RecomputeTransform();
289 void RecomputeDrawsContent(); 285 void RecomputeDrawsContent();
290 #endif 286 #endif
291 287
292 const LayerType type_; 288 const LayerType type_;
293 289
294 Compositor* compositor_; 290 Compositor* compositor_;
(...skipping 19 matching lines...) Expand all
314 310
315 gfx::Rect invalid_rect_; 311 gfx::Rect invalid_rect_;
316 312
317 // If true the layer is always up to date. 313 // If true the layer is always up to date.
318 bool layer_updated_externally_; 314 bool layer_updated_externally_;
319 315
320 float opacity_; 316 float opacity_;
321 317
322 LayerDelegate* delegate_; 318 LayerDelegate* delegate_;
323 319
324 scoped_ptr<LayerAnimator> animator_; 320 scoped_ptr<LayerAnimationManager> animator_;
325 321
326 #if defined(USE_WEBKIT_COMPOSITOR) 322 #if defined(USE_WEBKIT_COMPOSITOR)
327 WebKit::WebLayer web_layer_; 323 WebKit::WebLayer web_layer_;
328 bool web_layer_is_accelerated_; 324 bool web_layer_is_accelerated_;
329 #endif 325 #endif
330 326
331 DISALLOW_COPY_AND_ASSIGN(Layer); 327 DISALLOW_COPY_AND_ASSIGN(Layer);
332 }; 328 };
333 329
334 } // namespace ui 330 } // namespace ui
335 331
336 #endif // UI_GFX_COMPOSITOR_LAYER_H_ 332 #endif // UI_GFX_COMPOSITOR_LAYER_H_
OLDNEW
« no previous file with comments | « ui/gfx/compositor/dummy_layer_animation_delegate.cc ('k') | ui/gfx/compositor/layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698