summaryrefslogtreecommitdiffstats
path: root/cc/base/math_util.h
diff options
context:
space:
mode:
authoraelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-31 14:00:56 +0000
committeraelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-31 14:00:56 +0000
commit5f088535013d0cf033ecea30883ce80b5d3f3a3c (patch)
tree4c45e9f8bcba01631069074970240ae53c055f15 /cc/base/math_util.h
parentbe411ddee1b212652934e5d3495612911736fd4b (diff)
downloadchromium_src-5f088535013d0cf033ecea30883ce80b5d3f3a3c.zip
chromium_src-5f088535013d0cf033ecea30883ce80b5d3f3a3c.tar.gz
chromium_src-5f088535013d0cf033ecea30883ce80b5d3f3a3c.tar.bz2
Use Skia's mapMScalars() for mapping homogeneous points.
Skia provides a point mapping method, so we don't need to roll our own. This deletes some unnecessary code and with any luck compiles to faster code. NOTRY=true BUG=none Review URL: https://chromiumcodereview.appspot.com/21161004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214719 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/base/math_util.h')
-rw-r--r--cc/base/math_util.h40
1 files changed, 23 insertions, 17 deletions
diff --git a/cc/base/math_util.h b/cc/base/math_util.h
index cb158dd..23eb20f 100644
--- a/cc/base/math_util.h
+++ b/cc/base/math_util.h
@@ -29,37 +29,43 @@ class Vector2dF;
namespace cc {
struct HomogeneousCoordinate {
- HomogeneousCoordinate(double new_x, double new_y, double new_z, double new_w)
- : x(new_x), y(new_y), z(new_z), w(new_w) {}
+ HomogeneousCoordinate(SkMScalar x, SkMScalar y, SkMScalar z, SkMScalar w) {
+ vec[0] = x;
+ vec[1] = y;
+ vec[2] = z;
+ vec[3] = w;
+ }
- bool ShouldBeClipped() const { return w <= 0.0; }
+ bool ShouldBeClipped() const { return w() <= 0.0; }
gfx::PointF CartesianPoint2d() const {
- if (w == 1.0)
- return gfx::PointF(x, y);
+ if (w() == 1.0)
+ return gfx::PointF(x(), y());
// For now, because this code is used privately only by MathUtil, it should
// never be called when w == 0, and we do not yet need to handle that case.
- DCHECK(w);
- double inv_w = 1.0 / w;
- return gfx::PointF(x * inv_w, y * inv_w);
+ DCHECK(w());
+ double inv_w = 1.0 / w();
+ return gfx::PointF(x() * inv_w, y() * inv_w);
}
gfx::Point3F CartesianPoint3d() const {
- if (w == 1)
- return gfx::Point3F(x, y, z);
+ if (w() == 1)
+ return gfx::Point3F(x(), y(), z());
// For now, because this code is used privately only by MathUtil, it should
// never be called when w == 0, and we do not yet need to handle that case.
- DCHECK(w);
- double inv_w = 1.0 / w;
- return gfx::Point3F(x * inv_w, y * inv_w, z * inv_w);
+ DCHECK(w());
+ double inv_w = 1.0 / w();
+ return gfx::Point3F(x() * inv_w, y() * inv_w, z() * inv_w);
}
- double x;
- double y;
- double z;
- double w;
+ SkMScalar x() const { return vec[0]; }
+ SkMScalar y() const { return vec[1]; }
+ SkMScalar z() const { return vec[2]; }
+ SkMScalar w() const { return vec[3]; }
+
+ SkMScalar vec[4];
};
class CC_EXPORT MathUtil {