diff --git a/include/utils/SkMatrix44.h b/include/utils/SkMatrix44.h index c59aa7560..9926b7992 100644 --- a/include/utils/SkMatrix44.h +++ b/include/utils/SkMatrix44.h @@ -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) { diff --git a/src/utils/SkMatrix44.cpp b/src/utils/SkMatrix44.cpp index f00e39919..4fe82deaf 100644 --- a/src/utils/SkMatrix44.cpp +++ b/src/utils/SkMatrix44.cpp @@ -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 { diff --git a/tests/Matrix44Test.cpp b/tests/Matrix44Test.cpp index 6e70c5f42..906535872 100644 --- a/tests/Matrix44Test.cpp +++ b/tests/Matrix44Test.cpp @@ -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]);