| 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> |
| 11 | 11 |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 14 #include "ui/gfx/box_f.h" |
| 14 #include "ui/gfx/point.h" | 15 #include "ui/gfx/point.h" |
| 15 #include "ui/gfx/point3_f.h" | 16 #include "ui/gfx/point3_f.h" |
| 16 #include "ui/gfx/rect.h" | 17 #include "ui/gfx/rect.h" |
| 17 #include "ui/gfx/safe_integer_conversions.h" | 18 #include "ui/gfx/safe_integer_conversions.h" |
| 18 #include "ui/gfx/skia_util.h" | 19 #include "ui/gfx/skia_util.h" |
| 19 #include "ui/gfx/transform_util.h" | 20 #include "ui/gfx/transform_util.h" |
| 20 #include "ui/gfx/vector3d_f.h" | 21 #include "ui/gfx/vector3d_f.h" |
| 21 | 22 |
| 22 namespace gfx { | 23 namespace gfx { |
| 23 | 24 |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 if (!matrix_.invert(&inverse)) | 422 if (!matrix_.invert(&inverse)) |
| 422 return false; | 423 return false; |
| 423 | 424 |
| 424 const SkMatrix& matrix = inverse; | 425 const SkMatrix& matrix = inverse; |
| 425 SkRect src = RectFToSkRect(*rect); | 426 SkRect src = RectFToSkRect(*rect); |
| 426 matrix.mapRect(&src); | 427 matrix.mapRect(&src); |
| 427 *rect = SkRectToRectF(src); | 428 *rect = SkRectToRectF(src); |
| 428 return true; | 429 return true; |
| 429 } | 430 } |
| 430 | 431 |
| 432 void Transform::TransformBox(BoxF* box) const { |
| 433 BoxF bounds; |
| 434 bool first_point = true; |
| 435 for (int corner = 0; corner < 8; ++corner) { |
| 436 gfx::Point3F point = box->origin(); |
| 437 point += gfx::Vector3dF(corner & 1 ? box->width() : 0.f, |
| 438 corner & 2 ? box->height() : 0.f, |
| 439 corner & 4 ? box->depth() : 0.f); |
| 440 TransformPoint(&point); |
| 441 if (first_point) { |
| 442 bounds.set_origin(point); |
| 443 first_point = false; |
| 444 } else { |
| 445 bounds.ExpandTo(point); |
| 446 } |
| 447 } |
| 448 *box = bounds; |
| 449 } |
| 450 |
| 451 bool Transform::TransformBoxReverse(BoxF* box) const { |
| 452 gfx::Transform inverse = *this; |
| 453 if (!GetInverse(&inverse)) |
| 454 return false; |
| 455 inverse.TransformBox(box); |
| 456 return true; |
| 457 } |
| 458 |
| 431 bool Transform::Blend(const Transform& from, double progress) { | 459 bool Transform::Blend(const Transform& from, double progress) { |
| 432 DecomposedTransform to_decomp; | 460 DecomposedTransform to_decomp; |
| 433 DecomposedTransform from_decomp; | 461 DecomposedTransform from_decomp; |
| 434 if (!DecomposeTransform(&to_decomp, *this) || | 462 if (!DecomposeTransform(&to_decomp, *this) || |
| 435 !DecomposeTransform(&from_decomp, from)) | 463 !DecomposeTransform(&from_decomp, from)) |
| 436 return false; | 464 return false; |
| 437 | 465 |
| 438 if (!BlendDecomposedTransforms(&to_decomp, to_decomp, from_decomp, progress)) | 466 if (!BlendDecomposedTransforms(&to_decomp, to_decomp, from_decomp, progress)) |
| 439 return false; | 467 return false; |
| 440 | 468 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 matrix_.get(2, 1), | 518 matrix_.get(2, 1), |
| 491 matrix_.get(2, 2), | 519 matrix_.get(2, 2), |
| 492 matrix_.get(2, 3), | 520 matrix_.get(2, 3), |
| 493 matrix_.get(3, 0), | 521 matrix_.get(3, 0), |
| 494 matrix_.get(3, 1), | 522 matrix_.get(3, 1), |
| 495 matrix_.get(3, 2), | 523 matrix_.get(3, 2), |
| 496 matrix_.get(3, 3)); | 524 matrix_.get(3, 3)); |
| 497 } | 525 } |
| 498 | 526 |
| 499 } // namespace gfx | 527 } // namespace gfx |
| OLD | NEW |