OLD | NEW |
---|---|
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 // MSVC++ requires this to be set before any other includes to get M_PI. | 5 // MSVC++ requires this to be set before any other includes to get M_PI. |
6 #define _USE_MATH_DEFINES | 6 #define _USE_MATH_DEFINES |
7 | 7 |
8 #include "ui/gfx/transform.h" | 8 #include "ui/gfx/transform.h" |
9 | 9 |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
358 return false; | 358 return false; |
359 | 359 |
360 const SkMatrix& matrix = inverse; | 360 const SkMatrix& matrix = inverse; |
361 SkRect src = RectFToSkRect(*rect); | 361 SkRect src = RectFToSkRect(*rect); |
362 matrix.mapRect(&src); | 362 matrix.mapRect(&src); |
363 *rect = SkRectToRectF(src); | 363 *rect = SkRectToRectF(src); |
364 return true; | 364 return true; |
365 } | 365 } |
366 | 366 |
367 bool Transform::Blend(const Transform& from, double progress) { | 367 bool Transform::Blend(const Transform& from, double progress) { |
368 if (progress <= 0.0) { | |
369 *this = from; | |
370 return true; | |
371 } | |
372 | |
373 if (progress >= 1.0) | |
374 return true; | |
375 | |
ajuma
2013/06/01 14:54:12
Please add a gfx::Transform unit test for this tha
| |
376 DecomposedTransform to_decomp; | 368 DecomposedTransform to_decomp; |
377 DecomposedTransform from_decomp; | 369 DecomposedTransform from_decomp; |
378 if (!DecomposeTransform(&to_decomp, *this) || | 370 if (!DecomposeTransform(&to_decomp, *this) || |
379 !DecomposeTransform(&from_decomp, from)) | 371 !DecomposeTransform(&from_decomp, from)) |
380 return false; | 372 return false; |
381 | 373 |
382 if (!BlendDecomposedTransforms(&to_decomp, to_decomp, from_decomp, progress)) | 374 if (!BlendDecomposedTransforms(&to_decomp, to_decomp, from_decomp, progress)) |
383 return false; | 375 return false; |
384 | 376 |
385 matrix_ = ComposeTransform(to_decomp).matrix(); | 377 matrix_ = ComposeTransform(to_decomp).matrix(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
442 matrix_.getDouble(2, 1), | 434 matrix_.getDouble(2, 1), |
443 matrix_.getDouble(2, 2), | 435 matrix_.getDouble(2, 2), |
444 matrix_.getDouble(2, 3), | 436 matrix_.getDouble(2, 3), |
445 matrix_.getDouble(3, 0), | 437 matrix_.getDouble(3, 0), |
446 matrix_.getDouble(3, 1), | 438 matrix_.getDouble(3, 1), |
447 matrix_.getDouble(3, 2), | 439 matrix_.getDouble(3, 2), |
448 matrix_.getDouble(3, 3)); | 440 matrix_.getDouble(3, 3)); |
449 } | 441 } |
450 | 442 |
451 } // namespace gfx | 443 } // namespace gfx |
OLD | NEW |