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

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

Issue 8362006: Reland r107720 - Enable the new layer animation framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge 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
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_ANIMATION_ELEMENT_H_ 5 #ifndef UI_GFX_COMPOSITOR_LAYER_ANIMATION_ELEMENT_H_
6 #define UI_GFX_COMPOSITOR_LAYER_ANIMATION_ELEMENT_H_ 6 #define UI_GFX_COMPOSITOR_LAYER_ANIMATION_ELEMENT_H_
7 #pragma once 7 #pragma once
8 8
9 #include <set> 9 #include <set>
10 10
11 #include "base/time.h" 11 #include "base/time.h"
12 #include "ui/gfx/compositor/compositor_export.h" 12 #include "ui/gfx/compositor/compositor_export.h"
13 13 #include "ui/gfx/rect.h"
14 namespace gfx { 14 #include "ui/gfx/transform.h"
15 class Rect;
16 } // gfx
17 15
18 namespace ui { 16 namespace ui {
19 17
20 class LayerAnimationDelegate; 18 class LayerAnimationDelegate;
21 class Transform; 19 class Transform;
22 20
23 // LayerAnimationElements represent one segment of an animation between two 21 // LayerAnimationElements represent one segment of an animation between two
24 // keyframes. They know how to update a LayerAnimationDelegate given a value 22 // keyframes. They know how to update a LayerAnimationDelegate given a value
25 // between 0 and 1 (0 for initial, and 1 for final). 23 // between 0 and 1 (0 for initial, and 1 for final).
26 class COMPOSITOR_EXPORT LayerAnimationElement { 24 class COMPOSITOR_EXPORT LayerAnimationElement {
27 public: 25 public:
28 enum AnimatableProperty { 26 enum AnimatableProperty {
29 TRANSFORM = 0, 27 TRANSFORM = 0,
30 BOUNDS, 28 BOUNDS,
31 OPACITY 29 OPACITY
32 }; 30 };
33 31
32 struct TargetValue {
33 public:
34 TargetValue();
35 gfx::Rect bounds;
36 Transform transform;
37 float opacity;
38 };
39
34 typedef std::set<AnimatableProperty> AnimatableProperties; 40 typedef std::set<AnimatableProperty> AnimatableProperties;
35 41
36 LayerAnimationElement(const AnimatableProperties& properties, 42 LayerAnimationElement(const AnimatableProperties& properties,
37 base::TimeDelta duration); 43 base::TimeDelta duration);
38 virtual ~LayerAnimationElement(); 44 virtual ~LayerAnimationElement();
39 45
40 // Creates an element that transitions to the given transform. The caller owns 46 // Creates an element that transitions to the given transform. The caller owns
41 // the return value. 47 // the return value.
42 static LayerAnimationElement* CreateTransformElement( 48 static LayerAnimationElement* CreateTransformElement(
43 const Transform& transform, 49 const Transform& transform,
(...skipping 20 matching lines...) Expand all
64 // Updates the delegate to the appropriate value for |t|, which is in the 70 // Updates the delegate to the appropriate value for |t|, which is in the
65 // range [0, 1] (0 for initial, and 1 for final). If the animation is not 71 // range [0, 1] (0 for initial, and 1 for final). If the animation is not
66 // aborted, it is guaranteed that Progress will eventually be called with 72 // aborted, it is guaranteed that Progress will eventually be called with
67 // t = 1.0. 73 // t = 1.0.
68 void Progress(double t, LayerAnimationDelegate* delegate); 74 void Progress(double t, LayerAnimationDelegate* delegate);
69 75
70 // Called if the animation is not allowed to complete. This may be called 76 // Called if the animation is not allowed to complete. This may be called
71 // before OnStarted or Progress. 77 // before OnStarted or Progress.
72 void Abort(); 78 void Abort();
73 79
80 // Assigns the target value to |target|.
81 void GetTargetValue(TargetValue* target) const;
82
74 // The properties that the element modifies. 83 // The properties that the element modifies.
75 const AnimatableProperties& properties() const { return properties_; } 84 const AnimatableProperties& properties() const { return properties_; }
76 85
77 // The duration of the animation 86 // The duration of the animation
78 base::TimeDelta duration() const { return duration_; } 87 base::TimeDelta duration() const { return duration_; }
79 88
80 protected: 89 protected:
81 // Called once each time the animation element is run before any call to 90 // Called once each time the animation element is run before any call to
82 // OnProgress. 91 // OnProgress.
83 virtual void OnStart(LayerAnimationDelegate* delegate) = 0; 92 virtual void OnStart(LayerAnimationDelegate* delegate) = 0;
84 virtual void OnProgress(double t, LayerAnimationDelegate* delegate) = 0; 93 virtual void OnProgress(double t, LayerAnimationDelegate* delegate) = 0;
94 virtual void OnGetTarget(TargetValue* target) const = 0;
85 virtual void OnAbort() = 0; 95 virtual void OnAbort() = 0;
86 96
87 private: 97 private:
88 bool first_frame_; 98 bool first_frame_;
89 const AnimatableProperties properties_; 99 const AnimatableProperties properties_;
90 const base::TimeDelta duration_; 100 const base::TimeDelta duration_;
91 101
92 DISALLOW_COPY_AND_ASSIGN(LayerAnimationElement); 102 DISALLOW_COPY_AND_ASSIGN(LayerAnimationElement);
93 }; 103 };
94 104
95 } // namespace ui 105 } // namespace ui
96 106
97 #endif // UI_GFX_COMPOSITOR_LAYER_ANIMATION_ELEMENT_H_ 107 #endif // UI_GFX_COMPOSITOR_LAYER_ANIMATION_ELEMENT_H_
OLDNEW
« no previous file with comments | « ui/gfx/compositor/layer_animation_delegate.h ('k') | ui/gfx/compositor/layer_animation_element.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698