Index: cc/base/math_util.cc |
diff --git a/cc/base/math_util.cc b/cc/base/math_util.cc |
index ca6e5711760f8b6a16ccfcb9f3e10c82b1f3ada7..641d6499cd147a759453baa86095101851ab5b6e 100644 |
--- a/cc/base/math_util.cc |
+++ b/cc/base/math_util.cc |
@@ -41,6 +41,15 @@ static HomogeneousCoordinate ProjectHomogeneousPoint( |
return result; |
} |
+static HomogeneousCoordinate ProjectHomogeneousPoint( |
+ const gfx::Transform& transform, |
+ const gfx::PointF& p, |
+ bool* clipped) { |
+ HomogeneousCoordinate h = ProjectHomogeneousPoint(transform, p); |
+ *clipped = h.w() <= 0; |
+ return h; |
+} |
+ |
static HomogeneousCoordinate MapHomogeneousPoint( |
const gfx::Transform& transform, |
const gfx::Point3F& p) { |
@@ -444,28 +453,27 @@ gfx::QuadF MathUtil::ProjectQuad(const gfx::Transform& transform, |
gfx::PointF MathUtil::ProjectPoint(const gfx::Transform& transform, |
const gfx::PointF& p, |
bool* clipped) { |
- HomogeneousCoordinate h = ProjectHomogeneousPoint(transform, p); |
- |
- if (h.w() > 0) { |
- // The cartesian coordinates will be valid in this case. |
- *clipped = false; |
- return h.CartesianPoint2d(); |
- } |
- |
- // The cartesian coordinates will be invalid after dividing by w. |
- *clipped = true; |
- |
+ HomogeneousCoordinate h = ProjectHomogeneousPoint(transform, p, clipped); |
// Avoid dividing by w if w == 0. |
if (!h.w()) |
return gfx::PointF(); |
- // This return value will be invalid because clipped == true, but (1) users of |
+ // This return value will be invalid if clipped == true, but (1) users of |
// this code should be ignoring the return value when clipped == true anyway, |
// and (2) this behavior is more consistent with existing behavior of WebKit |
// transforms if the user really does not ignore the return value. |
return h.CartesianPoint2d(); |
} |
+gfx::Point3F MathUtil::ProjectPoint3D(const gfx::Transform& transform, |
+ const gfx::PointF& p, |
+ bool* clipped) { |
+ HomogeneousCoordinate h = ProjectHomogeneousPoint(transform, p, clipped); |
+ if (!h.w()) |
+ return gfx::Point3F(); |
+ return h.CartesianPoint3d(); |
+} |
+ |
gfx::RectF MathUtil::ScaleRectProportional(const gfx::RectF& input_outer_rect, |
const gfx::RectF& scale_outer_rect, |
const gfx::RectF& scale_inner_rect) { |