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

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

Issue 8247009: Explicit animation support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix VS2010 Created 9 years, 2 months 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/base/animation/tween.h ('k') | ui/gfx/compositor/compositor.gyp » ('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 #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/rect.h" 14
15 #if !defined(OS_MACOSX)
16 #include "ui/gfx/interpolated_transform.h"
17 #endif
15 18
16 namespace ui { 19 namespace ui {
17 20
18 // static 21 // static
19 double Tween::CalculateValue(Tween::Type type, double state) { 22 double Tween::CalculateValue(Tween::Type type, double state) {
20 DCHECK_GE(state, 0); 23 DCHECK_GE(state, 0);
21 DCHECK_LE(state, 1); 24 DCHECK_LE(state, 1);
22 25
23 switch (type) { 26 switch (type) {
24 case EASE_IN: 27 case EASE_IN:
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 const gfx::Rect& start_bounds, 79 const gfx::Rect& start_bounds,
77 const gfx::Rect& target_bounds) { 80 const gfx::Rect& target_bounds) {
78 return gfx::Rect(ValueBetween(value, start_bounds.x(), target_bounds.x()), 81 return gfx::Rect(ValueBetween(value, start_bounds.x(), target_bounds.x()),
79 ValueBetween(value, start_bounds.y(), target_bounds.y()), 82 ValueBetween(value, start_bounds.y(), target_bounds.y()),
80 ValueBetween(value, start_bounds.width(), 83 ValueBetween(value, start_bounds.width(),
81 target_bounds.width()), 84 target_bounds.width()),
82 ValueBetween(value, start_bounds.height(), 85 ValueBetween(value, start_bounds.height(),
83 target_bounds.height())); 86 target_bounds.height()));
84 } 87 }
85 88
89 #if !defined(OS_MACOSX)
90 // static
91 Transform Tween::ValueBetween(double value,
92 const Transform& start_transform,
93 const Transform& end_transform) {
94 Transform to_return;
95 gfx::Point start_translation, end_translation;
96 float start_rotation, end_rotation;
97 gfx::Point3f start_scale, end_scale;
98 if (InterpolatedTransform::FactorTRS(start_transform,
99 &start_translation,
100 &start_rotation,
101 &start_scale) &&
102 InterpolatedTransform::FactorTRS(end_transform,
103 &end_translation,
104 &end_rotation,
105 &end_scale)) {
106 to_return.SetScale(ValueBetween(value, start_scale.x(), end_scale.x()),
107 ValueBetween(value, start_scale.y(), end_scale.y()));
108 to_return.ConcatRotate(ValueBetween(value, start_rotation, end_rotation));
109 to_return.ConcatTranslate(
110 ValueBetween(value, start_translation.x(), end_translation.x()),
111 ValueBetween(value, start_translation.y(), end_translation.y()));
112 } else {
113 for (int row = 0; row < 4; ++row) {
114 for (int col = 0; col < 4; ++col) {
115 to_return.matrix().set(row, col,
116 ValueBetween(value,
117 start_transform.matrix().get(row, col),
118 end_transform.matrix().get(row, col)));
119 }
120 }
121 }
122
123 return to_return;
124 }
125 #endif
126
86 } // namespace ui 127 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/animation/tween.h ('k') | ui/gfx/compositor/compositor.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698