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

Side by Side Diff: ui/gfx/interpolated_transform.h

Issue 11418040: gfx::Transform API clean-up (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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) 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_GFX_INTERPOLATED_TRANSFORM_H_ 5 #ifndef UI_GFX_INTERPOLATED_TRANSFORM_H_
6 #define UI_GFX_INTERPOLATED_TRANSFORM_H_ 6 #define UI_GFX_INTERPOLATED_TRANSFORM_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "ui/gfx/point.h" 10 #include "ui/gfx/point.h"
11 #include "ui/gfx/point3_f.h" 11 #include "ui/gfx/point3_f.h"
12 #include "ui/gfx/transform.h" 12 #include "ui/gfx/transform.h"
13 #include "ui/gfx/transform_util.h"
14 #include "ui/gfx/vector3d_f.h"
13 15
14 namespace ui { 16 namespace ui {
15 17
16 /////////////////////////////////////////////////////////////////////////////// 18 ///////////////////////////////////////////////////////////////////////////////
17 // class InterpolatedTransform 19 // class InterpolatedTransform
18 // 20 //
19 // Abstract base class for transforms that animate over time. These 21 // Abstract base class for transforms that animate over time. These
20 // interpolated transforms can be combined to allow for more sophisticated 22 // interpolated transforms can be combined to allow for more sophisticated
21 // animations. For example, you might combine a rotation of 90 degrees between 23 // animations. For example, you might combine a rotation of 90 degrees between
22 // times 0 and 1, with a scale from 1 to 0.3 between times 0 and 0.25 and a 24 // times 0 and 1, with a scale from 1 to 0.3 between times 0 and 0.25 and a
(...skipping 16 matching lines...) Expand all
39 // and our child's transform at time t (if we have one). 41 // and our child's transform at time t (if we have one).
40 // 42 //
41 // This function takes ownership of the passed InterpolatedTransform. 43 // This function takes ownership of the passed InterpolatedTransform.
42 void SetChild(InterpolatedTransform* child); 44 void SetChild(InterpolatedTransform* child);
43 45
44 // If the interpolated transform is reversed, Interpolate(t) will return 46 // If the interpolated transform is reversed, Interpolate(t) will return
45 // Interpolate(1 - t) 47 // Interpolate(1 - t)
46 void SetReversed(bool reversed) { reversed_ = reversed; } 48 void SetReversed(bool reversed) { reversed_ = reversed; }
47 bool Reversed() const { return reversed_; } 49 bool Reversed() const { return reversed_; }
48 50
49 // NOTE: this function is soon to be deprecated.
50 static bool FactorTRS(const gfx::Transform& transform,
51 gfx::Point* translation,
52 float* rotation,
53 gfx::Point3F* scale);
54
55 protected: 51 protected:
56 // Calculates the interpolated transform without considering our child. 52 // Calculates the interpolated transform without considering our child.
57 virtual gfx::Transform InterpolateButDoNotCompose(float t) const = 0; 53 virtual gfx::Transform InterpolateButDoNotCompose(float t) const = 0;
58 54
59 // If time in (start_time_, end_time_], this function linearly interpolates 55 // If time in (start_time_, end_time_], this function linearly interpolates
60 // between start_value and end_value. More precisely it returns 56 // between start_value and end_value. More precisely it returns
61 // (1 - t) * start_value + t * end_value where 57 // (1 - t) * start_value + t * end_value where
62 // t = (start_time_ - time) / (end_time_ - start_time_). 58 // t = (start_time_ - time) / (end_time_ - start_time_).
63 // If time < start_time_ it returns start_value, and if time >= end_time_ 59 // If time < start_time_ it returns start_value, and if time >= end_time_
64 // it returns end_value. 60 // it returns end_value.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 }; 104 };
109 105
110 /////////////////////////////////////////////////////////////////////////////// 106 ///////////////////////////////////////////////////////////////////////////////
111 // class InterpolatedAxisAngleRotation 107 // class InterpolatedAxisAngleRotation
112 // 108 //
113 // Represents an animated rotation. 109 // Represents an animated rotation.
114 // 110 //
115 /////////////////////////////////////////////////////////////////////////////// 111 ///////////////////////////////////////////////////////////////////////////////
116 class UI_EXPORT InterpolatedAxisAngleRotation : public InterpolatedTransform { 112 class UI_EXPORT InterpolatedAxisAngleRotation : public InterpolatedTransform {
117 public: 113 public:
118 InterpolatedAxisAngleRotation(gfx::Point3F axis, 114 InterpolatedAxisAngleRotation(gfx::Vector3dF axis,
danakj 2012/11/16 19:46:12 const& to match ui/gfx style.
119 float start_degrees, 115 float start_degrees,
120 float end_degrees); 116 float end_degrees);
121 InterpolatedAxisAngleRotation(gfx::Point3F axis, 117 InterpolatedAxisAngleRotation(gfx::Vector3dF axis,
danakj 2012/11/16 19:46:12 const&
122 float start_degrees, 118 float start_degrees,
123 float end_degrees, 119 float end_degrees,
124 float start_time, 120 float start_time,
125 float end_time); 121 float end_time);
126 virtual ~InterpolatedAxisAngleRotation(); 122 virtual ~InterpolatedAxisAngleRotation();
127 123
128 protected: 124 protected:
129 virtual gfx::Transform InterpolateButDoNotCompose(float t) const OVERRIDE; 125 virtual gfx::Transform InterpolateButDoNotCompose(float t) const OVERRIDE;
130 126
131 private: 127 private:
132 gfx::Point3F axis_; 128 gfx::Vector3dF axis_;
133 const float start_degrees_; 129 const float start_degrees_;
134 const float end_degrees_; 130 const float end_degrees_;
135 131
136 DISALLOW_COPY_AND_ASSIGN(InterpolatedAxisAngleRotation); 132 DISALLOW_COPY_AND_ASSIGN(InterpolatedAxisAngleRotation);
137 }; 133 };
138 134
139 /////////////////////////////////////////////////////////////////////////////// 135 ///////////////////////////////////////////////////////////////////////////////
140 // class InterpolatedScale 136 // class InterpolatedScale
141 // 137 //
142 // Represents an animated scale. 138 // Represents an animated scale.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 virtual gfx::Transform InterpolateButDoNotCompose(float t) const OVERRIDE; 229 virtual gfx::Transform InterpolateButDoNotCompose(float t) const OVERRIDE;
234 230
235 private: 231 private:
236 void Init(const gfx::Point& pivot, InterpolatedTransform* transform); 232 void Init(const gfx::Point& pivot, InterpolatedTransform* transform);
237 233
238 scoped_ptr<InterpolatedTransform> transform_; 234 scoped_ptr<InterpolatedTransform> transform_;
239 235
240 DISALLOW_COPY_AND_ASSIGN(InterpolatedTransformAboutPivot); 236 DISALLOW_COPY_AND_ASSIGN(InterpolatedTransformAboutPivot);
241 }; 237 };
242 238
243 class UI_EXPORT InterpolatedTRSTransform : public InterpolatedTransform { 239 class UI_EXPORT InterpolatedMatrixTransform : public InterpolatedTransform {
244 public: 240 public:
245 InterpolatedTRSTransform(const gfx::Transform& start_transform, 241 InterpolatedMatrixTransform(const gfx::Transform& start_transform,
246 const gfx::Transform& end_transform); 242 const gfx::Transform& end_transform);
247 243
248 InterpolatedTRSTransform(const gfx::Transform& start_transform, 244 InterpolatedMatrixTransform(const gfx::Transform& start_transform,
249 const gfx::Transform& end_transform, 245 const gfx::Transform& end_transform,
250 float start_time, 246 float start_time,
251 float end_time); 247 float end_time);
252 248
253 virtual ~InterpolatedTRSTransform(); 249 virtual ~InterpolatedMatrixTransform();
254 250
255 protected: 251 protected:
256 virtual gfx::Transform InterpolateButDoNotCompose(float t) const OVERRIDE; 252 virtual gfx::Transform InterpolateButDoNotCompose(float t) const OVERRIDE;
257 253
258 private: 254 private:
259 void Init(const gfx::Transform& start_transform, 255 void Init(const gfx::Transform& start_transform,
260 const gfx::Transform& end_transform); 256 const gfx::Transform& end_transform);
261 257
262 scoped_ptr<InterpolatedTransform> transform_; 258 gfx::DecomposedTransform start_decomp_;
259 gfx::DecomposedTransform end_decomp_;
263 }; 260 };
264 261
265 } // namespace ui 262 } // namespace ui
266 263
267 #endif // UI_GFX_INTERPOLATED_TRANSFORM_H_ 264 #endif // UI_GFX_INTERPOLATED_TRANSFORM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698