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

Side by Side Diff: cc/animation/transform_operations.cc

Issue 951673002: Revert "Pull chromium at 2c3ffb2355a27c32f45e508ef861416b820c823b" (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « cc/animation/transform_operation.cc ('k') | cc/base/latency_info_swap_promise_monitor.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "cc/animation/transform_operations.h" 5 #include "cc/animation/transform_operations.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ui/gfx/animation/tween.h" 9 #include "ui/gfx/animation/tween.h"
10 #include "ui/gfx/geometry/box_f.h" 10 #include "ui/gfx/geometry/box_f.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 &bounds_for_operation)) 78 &bounds_for_operation))
79 return false; 79 return false;
80 *bounds = bounds_for_operation; 80 *bounds = bounds_for_operation;
81 } 81 }
82 82
83 return true; 83 return true;
84 } 84 }
85 85
86 bool TransformOperations::AffectsScale() const { 86 bool TransformOperations::AffectsScale() const {
87 for (size_t i = 0; i < operations_.size(); ++i) { 87 for (size_t i = 0; i < operations_.size(); ++i) {
88 if (operations_[i].type == TransformOperation::TRANSFORM_OPERATION_SCALE) 88 if (operations_[i].type == TransformOperation::TransformOperationScale)
89 return true; 89 return true;
90 if (operations_[i].type == TransformOperation::TRANSFORM_OPERATION_MATRIX && 90 if (operations_[i].type == TransformOperation::TransformOperationMatrix &&
91 !operations_[i].matrix.IsIdentityOrTranslation()) 91 !operations_[i].matrix.IsIdentityOrTranslation())
92 return true; 92 return true;
93 } 93 }
94 return false; 94 return false;
95 } 95 }
96 96
97 bool TransformOperations::PreservesAxisAlignment() const { 97 bool TransformOperations::PreservesAxisAlignment() const {
98 for (size_t i = 0; i < operations_.size(); ++i) { 98 for (size_t i = 0; i < operations_.size(); ++i) {
99 switch (operations_[i].type) { 99 switch (operations_[i].type) {
100 case TransformOperation::TRANSFORM_OPERATION_IDENTITY: 100 case TransformOperation::TransformOperationIdentity:
101 case TransformOperation::TRANSFORM_OPERATION_TRANSLATE: 101 case TransformOperation::TransformOperationTranslate:
102 case TransformOperation::TRANSFORM_OPERATION_SCALE: 102 case TransformOperation::TransformOperationScale:
103 continue; 103 continue;
104 case TransformOperation::TRANSFORM_OPERATION_MATRIX: 104 case TransformOperation::TransformOperationMatrix:
105 if (!operations_[i].matrix.IsIdentity() && 105 if (!operations_[i].matrix.IsIdentity() &&
106 !operations_[i].matrix.IsScaleOrTranslation()) 106 !operations_[i].matrix.IsScaleOrTranslation())
107 return false; 107 return false;
108 continue; 108 continue;
109 case TransformOperation::TRANSFORM_OPERATION_ROTATE: 109 case TransformOperation::TransformOperationRotate:
110 case TransformOperation::TRANSFORM_OPERATION_SKEW: 110 case TransformOperation::TransformOperationSkew:
111 case TransformOperation::TRANSFORM_OPERATION_PERSPECTIVE: 111 case TransformOperation::TransformOperationPerspective:
112 return false; 112 return false;
113 } 113 }
114 } 114 }
115 return true; 115 return true;
116 } 116 }
117 117
118 bool TransformOperations::IsTranslation() const { 118 bool TransformOperations::IsTranslation() const {
119 for (size_t i = 0; i < operations_.size(); ++i) { 119 for (size_t i = 0; i < operations_.size(); ++i) {
120 switch (operations_[i].type) { 120 switch (operations_[i].type) {
121 case TransformOperation::TRANSFORM_OPERATION_IDENTITY: 121 case TransformOperation::TransformOperationIdentity:
122 case TransformOperation::TRANSFORM_OPERATION_TRANSLATE: 122 case TransformOperation::TransformOperationTranslate:
123 continue; 123 continue;
124 case TransformOperation::TRANSFORM_OPERATION_MATRIX: 124 case TransformOperation::TransformOperationMatrix:
125 if (!operations_[i].matrix.IsIdentityOrTranslation()) 125 if (!operations_[i].matrix.IsIdentityOrTranslation())
126 return false; 126 return false;
127 continue; 127 continue;
128 case TransformOperation::TRANSFORM_OPERATION_ROTATE: 128 case TransformOperation::TransformOperationRotate:
129 case TransformOperation::TRANSFORM_OPERATION_SCALE: 129 case TransformOperation::TransformOperationScale:
130 case TransformOperation::TRANSFORM_OPERATION_SKEW: 130 case TransformOperation::TransformOperationSkew:
131 case TransformOperation::TRANSFORM_OPERATION_PERSPECTIVE: 131 case TransformOperation::TransformOperationPerspective:
132 return false; 132 return false;
133 } 133 }
134 } 134 }
135 return true; 135 return true;
136 } 136 }
137 137
138 bool TransformOperations::ScaleComponent(gfx::Vector3dF* scale) const { 138 bool TransformOperations::ScaleComponent(gfx::Vector3dF* scale) const {
139 *scale = gfx::Vector3dF(1.f, 1.f, 1.f); 139 *scale = gfx::Vector3dF(1.f, 1.f, 1.f);
140 bool has_scale_component = false; 140 bool has_scale_component = false;
141 for (size_t i = 0; i < operations_.size(); ++i) { 141 for (size_t i = 0; i < operations_.size(); ++i) {
142 switch (operations_[i].type) { 142 switch (operations_[i].type) {
143 case TransformOperation::TRANSFORM_OPERATION_IDENTITY: 143 case TransformOperation::TransformOperationIdentity:
144 case TransformOperation::TRANSFORM_OPERATION_TRANSLATE: 144 case TransformOperation::TransformOperationTranslate:
145 continue; 145 continue;
146 case TransformOperation::TRANSFORM_OPERATION_MATRIX: 146 case TransformOperation::TransformOperationMatrix:
147 if (!operations_[i].matrix.IsIdentityOrTranslation()) 147 if (!operations_[i].matrix.IsIdentityOrTranslation())
148 return false; 148 return false;
149 continue; 149 continue;
150 case TransformOperation::TRANSFORM_OPERATION_ROTATE: 150 case TransformOperation::TransformOperationRotate:
151 case TransformOperation::TRANSFORM_OPERATION_SKEW: 151 case TransformOperation::TransformOperationSkew:
152 case TransformOperation::TRANSFORM_OPERATION_PERSPECTIVE: 152 case TransformOperation::TransformOperationPerspective:
153 return false; 153 return false;
154 case TransformOperation::TRANSFORM_OPERATION_SCALE: 154 case TransformOperation::TransformOperationScale:
155 if (has_scale_component) 155 if (has_scale_component)
156 return false; 156 return false;
157 has_scale_component = true; 157 has_scale_component = true;
158 scale->Scale(operations_[i].scale.x, 158 scale->Scale(operations_[i].scale.x,
159 operations_[i].scale.y, 159 operations_[i].scale.y,
160 operations_[i].scale.z); 160 operations_[i].scale.z);
161 } 161 }
162 } 162 }
163 return true; 163 return true;
164 } 164 }
(...skipping 19 matching lines...) Expand all
184 const TransformOperations& other) const { 184 const TransformOperations& other) const {
185 gfx::Transform dummy; 185 gfx::Transform dummy;
186 return BlendInternal(other, 0.5, &dummy); 186 return BlendInternal(other, 0.5, &dummy);
187 } 187 }
188 188
189 void TransformOperations::AppendTranslate(SkMScalar x, 189 void TransformOperations::AppendTranslate(SkMScalar x,
190 SkMScalar y, 190 SkMScalar y,
191 SkMScalar z) { 191 SkMScalar z) {
192 TransformOperation to_add; 192 TransformOperation to_add;
193 to_add.matrix.Translate3d(x, y, z); 193 to_add.matrix.Translate3d(x, y, z);
194 to_add.type = TransformOperation::TRANSFORM_OPERATION_TRANSLATE; 194 to_add.type = TransformOperation::TransformOperationTranslate;
195 to_add.translate.x = x; 195 to_add.translate.x = x;
196 to_add.translate.y = y; 196 to_add.translate.y = y;
197 to_add.translate.z = z; 197 to_add.translate.z = z;
198 operations_.push_back(to_add); 198 operations_.push_back(to_add);
199 decomposed_transform_dirty_ = true; 199 decomposed_transform_dirty_ = true;
200 } 200 }
201 201
202 void TransformOperations::AppendRotate(SkMScalar x, 202 void TransformOperations::AppendRotate(SkMScalar x,
203 SkMScalar y, 203 SkMScalar y,
204 SkMScalar z, 204 SkMScalar z,
205 SkMScalar degrees) { 205 SkMScalar degrees) {
206 TransformOperation to_add; 206 TransformOperation to_add;
207 to_add.matrix.RotateAbout(gfx::Vector3dF(x, y, z), degrees); 207 to_add.matrix.RotateAbout(gfx::Vector3dF(x, y, z), degrees);
208 to_add.type = TransformOperation::TRANSFORM_OPERATION_ROTATE; 208 to_add.type = TransformOperation::TransformOperationRotate;
209 to_add.rotate.axis.x = x; 209 to_add.rotate.axis.x = x;
210 to_add.rotate.axis.y = y; 210 to_add.rotate.axis.y = y;
211 to_add.rotate.axis.z = z; 211 to_add.rotate.axis.z = z;
212 to_add.rotate.angle = degrees; 212 to_add.rotate.angle = degrees;
213 operations_.push_back(to_add); 213 operations_.push_back(to_add);
214 decomposed_transform_dirty_ = true; 214 decomposed_transform_dirty_ = true;
215 } 215 }
216 216
217 void TransformOperations::AppendScale(SkMScalar x, SkMScalar y, SkMScalar z) { 217 void TransformOperations::AppendScale(SkMScalar x, SkMScalar y, SkMScalar z) {
218 TransformOperation to_add; 218 TransformOperation to_add;
219 to_add.matrix.Scale3d(x, y, z); 219 to_add.matrix.Scale3d(x, y, z);
220 to_add.type = TransformOperation::TRANSFORM_OPERATION_SCALE; 220 to_add.type = TransformOperation::TransformOperationScale;
221 to_add.scale.x = x; 221 to_add.scale.x = x;
222 to_add.scale.y = y; 222 to_add.scale.y = y;
223 to_add.scale.z = z; 223 to_add.scale.z = z;
224 operations_.push_back(to_add); 224 operations_.push_back(to_add);
225 decomposed_transform_dirty_ = true; 225 decomposed_transform_dirty_ = true;
226 } 226 }
227 227
228 void TransformOperations::AppendSkew(SkMScalar x, SkMScalar y) { 228 void TransformOperations::AppendSkew(SkMScalar x, SkMScalar y) {
229 TransformOperation to_add; 229 TransformOperation to_add;
230 to_add.matrix.SkewX(x); 230 to_add.matrix.SkewX(x);
231 to_add.matrix.SkewY(y); 231 to_add.matrix.SkewY(y);
232 to_add.type = TransformOperation::TRANSFORM_OPERATION_SKEW; 232 to_add.type = TransformOperation::TransformOperationSkew;
233 to_add.skew.x = x; 233 to_add.skew.x = x;
234 to_add.skew.y = y; 234 to_add.skew.y = y;
235 operations_.push_back(to_add); 235 operations_.push_back(to_add);
236 decomposed_transform_dirty_ = true; 236 decomposed_transform_dirty_ = true;
237 } 237 }
238 238
239 void TransformOperations::AppendPerspective(SkMScalar depth) { 239 void TransformOperations::AppendPerspective(SkMScalar depth) {
240 TransformOperation to_add; 240 TransformOperation to_add;
241 to_add.matrix.ApplyPerspectiveDepth(depth); 241 to_add.matrix.ApplyPerspectiveDepth(depth);
242 to_add.type = TransformOperation::TRANSFORM_OPERATION_PERSPECTIVE; 242 to_add.type = TransformOperation::TransformOperationPerspective;
243 to_add.perspective_depth = depth; 243 to_add.perspective_depth = depth;
244 operations_.push_back(to_add); 244 operations_.push_back(to_add);
245 decomposed_transform_dirty_ = true; 245 decomposed_transform_dirty_ = true;
246 } 246 }
247 247
248 void TransformOperations::AppendMatrix(const gfx::Transform& matrix) { 248 void TransformOperations::AppendMatrix(const gfx::Transform& matrix) {
249 TransformOperation to_add; 249 TransformOperation to_add;
250 to_add.matrix = matrix; 250 to_add.matrix = matrix;
251 to_add.type = TransformOperation::TRANSFORM_OPERATION_MATRIX; 251 to_add.type = TransformOperation::TransformOperationMatrix;
252 operations_.push_back(to_add); 252 operations_.push_back(to_add);
253 decomposed_transform_dirty_ = true; 253 decomposed_transform_dirty_ = true;
254 } 254 }
255 255
256 void TransformOperations::AppendIdentity() { 256 void TransformOperations::AppendIdentity() {
257 operations_.push_back(TransformOperation()); 257 operations_.push_back(TransformOperation());
258 } 258 }
259 259
260 bool TransformOperations::IsIdentity() const { 260 bool TransformOperations::IsIdentity() const {
261 for (size_t i = 0; i < operations_.size(); ++i) { 261 for (size_t i = 0; i < operations_.size(); ++i) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 decomposed_transform_.reset(new gfx::DecomposedTransform()); 310 decomposed_transform_.reset(new gfx::DecomposedTransform());
311 gfx::Transform transform = Apply(); 311 gfx::Transform transform = Apply();
312 if (!gfx::DecomposeTransform(decomposed_transform_.get(), transform)) 312 if (!gfx::DecomposeTransform(decomposed_transform_.get(), transform))
313 return false; 313 return false;
314 decomposed_transform_dirty_ = false; 314 decomposed_transform_dirty_ = false;
315 } 315 }
316 return true; 316 return true;
317 } 317 }
318 318
319 } // namespace cc 319 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/transform_operation.cc ('k') | cc/base/latency_info_swap_promise_monitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698