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

Side by Side Diff: ui/base/animation/tween.cc

Issue 11418040: gfx::Transform API clean-up (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years 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/aura/window_unittest.cc ('k') | ui/base/events/event.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) 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 #include "ui/base/animation/tween.h" 5 #include "ui/base/animation/tween.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <float.h> 10 #include <float.h>
11 #endif 11 #endif
12 12
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "ui/gfx/interpolated_transform.h"
15 14
16 namespace ui { 15 namespace ui {
17 16
18 // static 17 // static
19 double Tween::CalculateValue(Tween::Type type, double state) { 18 double Tween::CalculateValue(Tween::Type type, double state) {
20 DCHECK_GE(state, 0); 19 DCHECK_GE(state, 0);
21 DCHECK_LE(state, 1); 20 DCHECK_LE(state, 1);
22 21
23 switch (type) { 22 switch (type) {
24 case EASE_IN: 23 case EASE_IN:
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 return gfx::Rect(ValueBetween(value, start_bounds.x(), target_bounds.x()), 89 return gfx::Rect(ValueBetween(value, start_bounds.x(), target_bounds.x()),
91 ValueBetween(value, start_bounds.y(), target_bounds.y()), 90 ValueBetween(value, start_bounds.y(), target_bounds.y()),
92 ValueBetween(value, start_bounds.width(), 91 ValueBetween(value, start_bounds.width(),
93 target_bounds.width()), 92 target_bounds.width()),
94 ValueBetween(value, start_bounds.height(), 93 ValueBetween(value, start_bounds.height(),
95 target_bounds.height())); 94 target_bounds.height()));
96 } 95 }
97 96
98 // static 97 // static
99 gfx::Transform Tween::ValueBetween(double value, 98 gfx::Transform Tween::ValueBetween(double value,
100 const gfx::Transform& start_transform, 99 const gfx::Transform& start_transform,
101 const gfx::Transform& end_transform) { 100 const gfx::Transform& end_transform) {
102 if (value >= 1.0) 101 if (value >= 1.0)
103 return end_transform; 102 return end_transform;
104 if (value <= 0.0) 103 if (value <= 0.0)
105 return start_transform; 104 return start_transform;
106 105
107 gfx::Transform to_return; 106 gfx::Transform to_return = end_transform;
108 gfx::Point start_translation, end_translation; 107 to_return.Blend(start_transform, value);
109 float start_rotation, end_rotation;
110 gfx::Point3F start_scale, end_scale;
111 if (InterpolatedTransform::FactorTRS(start_transform,
112 &start_translation,
113 &start_rotation,
114 &start_scale) &&
115 InterpolatedTransform::FactorTRS(end_transform,
116 &end_translation,
117 &end_rotation,
118 &end_scale)) {
119 to_return.SetScale(ValueBetween(value, start_scale.x(), end_scale.x()),
120 ValueBetween(value, start_scale.y(), end_scale.y()));
121 to_return.ConcatRotate(ValueBetween(value, start_rotation, end_rotation));
122 to_return.ConcatTranslate(
123 ValueBetween(value, start_translation.x(), end_translation.x()),
124 ValueBetween(value, start_translation.y(), end_translation.y()));
125 } else {
126 for (int row = 0; row < 4; ++row) {
127 for (int col = 0; col < 4; ++col) {
128 to_return.matrix().set(row, col,
129 ValueBetween(value,
130 start_transform.matrix().get(row, col),
131 end_transform.matrix().get(row, col)));
132 }
133 }
134 }
135 108
136 return to_return; 109 return to_return;
137 } 110 }
138 111
139 } // namespace ui 112 } // namespace ui
OLDNEW
« no previous file with comments | « ui/aura/window_unittest.cc ('k') | ui/base/events/event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698