add explicit mapScalars and mapMScalars entry-points, instead of just map()
authorreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 9 Nov 2012 21:39:48 +0000 (21:39 +0000)
committerreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 9 Nov 2012 21:39:48 +0000 (21:39 +0000)
git-svn-id: http://skia.googlecode.com/svn/trunk@6373 2bbb7eff-a529-9590-31e7-b0007b416f81

include/utils/SkMatrix44.h
src/utils/SkMatrix44.cpp
tests/Matrix44Test.cpp

index c59aa75..9926b79 100644 (file)
@@ -186,9 +186,29 @@ public:
     /** Apply the matrix to the src vector, returning the new vector in dst.
         It is legal for src and dst to point to the same memory.
      */
-    void map(const SkScalar src[4], SkScalar dst[4]) const;
+    void mapScalars(const SkScalar src[4], SkScalar dst[4]) const;
+    void mapScalars(SkScalar vec[4]) const {
+        this->mapScalars(vec, vec);
+    }
+
+    // DEPRECATED: call mapScalars()
+    void map(const SkScalar src[4], SkScalar dst[4]) const {
+        this->mapScalars(src, dst);
+    }
+    // DEPRECATED: call mapScalars()
     void map(SkScalar vec[4]) const {
-        this->map(vec, vec);
+        this->mapScalars(vec, vec);
+    }
+
+#ifdef SK_MSCALAR_IS_DOUBLE
+    void mapMScalars(SkMScalar src[4], SkMScalar dst[4]) const;
+#else
+    void mapMScalars(SkMScalar src[4], SkMScalar dst[4]) const {
+        this->mapScalars(src, dst);
+    }
+#endif
+    void mapMScalars(SkMScalar vec[4]) const {
+        this->mapMScalars(vec, vec);
     }
 
     friend SkVector4 operator*(const SkMatrix44& m, const SkVector4& src) {
index f00e399..4fe82de 100644 (file)
@@ -323,7 +323,7 @@ bool SkMatrix44::invert(SkMatrix44* inverse) const {
 
 ///////////////////////////////////////////////////////////////////////////////
 
-void SkMatrix44::map(const SkScalar src[4], SkScalar dst[4]) const {
+void SkMatrix44::mapScalars(const SkScalar src[4], SkScalar dst[4]) const {
     SkScalar result[4];
     for (int i = 0; i < 4; i++) {
         SkMScalar value = 0;
@@ -335,6 +335,20 @@ void SkMatrix44::map(const SkScalar src[4], SkScalar dst[4]) const {
     memcpy(dst, result, sizeof(result));
 }
 
+#ifdef SK_MSCALAR_IS_DOUBLE
+void SkMatrix44::mapMScalars(const SkMScalar src[4], SkMScalar dst[4]) const {
+    SkMScalar result[4];
+    for (int i = 0; i < 4; i++) {
+        SkMScalar value = 0;
+        for (int j = 0; j < 4; j++) {
+            value += fMat[j][i] * src[j];
+        }
+        result[i] = SkMScalarToScalar(value);
+    }
+    memcpy(dst, result, sizeof(result));
+}
+#endif
+
 ///////////////////////////////////////////////////////////////////////////////
 
 void SkMatrix44::dump() const {
index 6e70c5f..9065358 100644 (file)
@@ -95,7 +95,7 @@ static void test_concat(skiatest::Reporter* reporter) {
     d.preConcat(b);
     REPORTER_ASSERT(reporter, d == c);
     
-    c.map(src, dst); c.map(src + 4, dst + 4);
+    c.mapScalars(src, dst); c.mapScalars(src + 4, dst + 4);
     for (i = 0; i < 3; ++i) {
         REPORTER_ASSERT(reporter, 10 == dst[i]);
         REPORTER_ASSERT(reporter, 12 == dst[i + 4]);
@@ -107,7 +107,7 @@ static void test_concat(skiatest::Reporter* reporter) {
     d.postConcat(b);
     REPORTER_ASSERT(reporter, d == c);
 
-    c.map(src, dst); c.map(src + 4, dst + 4);
+    c.mapScalars(src, dst); c.mapScalars(src + 4, dst + 4);
     for (i = 0; i < 3; ++i) {
         REPORTER_ASSERT(reporter, 20 == dst[i]);
         REPORTER_ASSERT(reporter, 22 == dst[i + 4]);