| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "cc/math_util.h" | 7 #include "cc/math_util.h" |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 numVerticesInClippedQuad++; | 103 numVerticesInClippedQuad++; |
| 104 } | 104 } |
| 105 | 105 |
| 106 gfx::Rect MathUtil::mapClippedRect(const WebTransformationMatrix& transform, con
st gfx::Rect& srcRect) | 106 gfx::Rect MathUtil::mapClippedRect(const WebTransformationMatrix& transform, con
st gfx::Rect& srcRect) |
| 107 { | 107 { |
| 108 return gfx::ToEnclosingRect(mapClippedRect(transform, gfx::RectF(srcRect))); | 108 return gfx::ToEnclosingRect(mapClippedRect(transform, gfx::RectF(srcRect))); |
| 109 } | 109 } |
| 110 | 110 |
| 111 gfx::RectF MathUtil::mapClippedRect(const WebTransformationMatrix& transform, co
nst gfx::RectF& srcRect) | 111 gfx::RectF MathUtil::mapClippedRect(const WebTransformationMatrix& transform, co
nst gfx::RectF& srcRect) |
| 112 { | 112 { |
| 113 if (transform.isIdentityOrTranslation()) { | 113 if (transform.isIdentityOrTranslation()) |
| 114 gfx::RectF mappedRect(srcRect); | 114 return srcRect + gfx::Vector2dF(static_cast<float>(transform.m41()), sta
tic_cast<float>(transform.m42())); |
| 115 mappedRect.Offset(static_cast<float>(transform.m41()), static_cast<float
>(transform.m42())); | |
| 116 return mappedRect; | |
| 117 } | |
| 118 | 115 |
| 119 // Apply the transform, but retain the result in homogeneous coordinates. | 116 // Apply the transform, but retain the result in homogeneous coordinates. |
| 120 gfx::QuadF q = gfx::QuadF(gfx::RectF(srcRect)); | 117 gfx::QuadF q = gfx::QuadF(gfx::RectF(srcRect)); |
| 121 HomogeneousCoordinate h1 = mapHomogeneousPoint(transform, gfx::Point3F(q.p1(
))); | 118 HomogeneousCoordinate h1 = mapHomogeneousPoint(transform, gfx::Point3F(q.p1(
))); |
| 122 HomogeneousCoordinate h2 = mapHomogeneousPoint(transform, gfx::Point3F(q.p2(
))); | 119 HomogeneousCoordinate h2 = mapHomogeneousPoint(transform, gfx::Point3F(q.p2(
))); |
| 123 HomogeneousCoordinate h3 = mapHomogeneousPoint(transform, gfx::Point3F(q.p3(
))); | 120 HomogeneousCoordinate h3 = mapHomogeneousPoint(transform, gfx::Point3F(q.p3(
))); |
| 124 HomogeneousCoordinate h4 = mapHomogeneousPoint(transform, gfx::Point3F(q.p4(
))); | 121 HomogeneousCoordinate h4 = mapHomogeneousPoint(transform, gfx::Point3F(q.p4(
))); |
| 125 | 122 |
| 126 return computeEnclosingClippedRect(h1, h2, h3, h4); | 123 return computeEnclosingClippedRect(h1, h2, h3, h4); |
| 127 } | 124 } |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 return static_cast<float>(Rad2Deg(std::acos(dotProduct))); | 388 return static_cast<float>(Rad2Deg(std::acos(dotProduct))); |
| 392 } | 389 } |
| 393 | 390 |
| 394 gfx::Vector2dF MathUtil::projectVector(gfx::Vector2dF source, gfx::Vector2dF des
tination) | 391 gfx::Vector2dF MathUtil::projectVector(gfx::Vector2dF source, gfx::Vector2dF des
tination) |
| 395 { | 392 { |
| 396 float projectedLength = gfx::DotProduct(source, destination) / destination.L
engthSquared(); | 393 float projectedLength = gfx::DotProduct(source, destination) / destination.L
engthSquared(); |
| 397 return gfx::Vector2dF(projectedLength * destination.x(), projectedLength * d
estination.y()); | 394 return gfx::Vector2dF(projectedLength * destination.x(), projectedLength * d
estination.y()); |
| 398 } | 395 } |
| 399 | 396 |
| 400 } // namespace cc | 397 } // namespace cc |
| OLD | NEW |