diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-10-04 20:38:08 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-10-04 20:38:08 +0000 |
commit | 761f860a427e9ebb088c4d1e5fba04deb29b5a6f (patch) | |
tree | 3a90988245495b04d8bc2095a017df75c320d642 /src | |
parent | 6b30e457409f37c91c301cd82040e733e2930286 (diff) |
Add perspective support to SkMatrix44 initializers.
I noticed SkMatrix <-> SkMatrix44 conversions were dropping the
perspective values on the floor. As we use SkMatrix44 heavily in
Chromium, I'm concerned this missing code will cause a bug eventually.
It should be correct to simply use the bottom row of the 4x4 matrix
excluding the third column.
BUG=
R=reed@google.com
Author: aelias@chromium.org
Review URL: https://codereview.chromium.org/25484006
git-svn-id: http://skia.googlecode.com/svn/trunk@11622 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/utils/SkMatrix44.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/utils/SkMatrix44.cpp b/src/utils/SkMatrix44.cpp index 1e48f393ac..9803b52095 100644 --- a/src/utils/SkMatrix44.cpp +++ b/src/utils/SkMatrix44.cpp @@ -902,8 +902,6 @@ void SkMatrix44::dump() const { /////////////////////////////////////////////////////////////////////////////// -// TODO: make this support src' perspective elements -// static void initFromMatrix(SkMScalar dst[4][4], const SkMatrix& src) { dst[0][0] = SkScalarToMScalar(src[SkMatrix::kMScaleX]); dst[1][0] = SkScalarToMScalar(src[SkMatrix::kMSkewX]); @@ -917,10 +915,10 @@ static void initFromMatrix(SkMScalar dst[4][4], const SkMatrix& src) { dst[1][2] = 0; dst[2][2] = 1; dst[3][2] = 0; - dst[0][3] = 0; - dst[1][3] = 0; + dst[0][3] = SkScalarToMScalar(src[SkMatrix::kMPersp0]); + dst[1][3] = SkScalarToMScalar(src[SkMatrix::kMPersp1]); dst[2][3] = 0; - dst[3][3] = 1; + dst[3][3] = SkScalarToMScalar(src[SkMatrix::kMPersp2]); } SkMatrix44::SkMatrix44(const SkMatrix& src) { @@ -938,11 +936,8 @@ SkMatrix44& SkMatrix44::operator=(const SkMatrix& src) { return *this; } -// TODO: make this support our perspective elements -// SkMatrix44::operator SkMatrix() const { SkMatrix dst; - dst.reset(); // setup our perspective correctly for identity dst[SkMatrix::kMScaleX] = SkMScalarToScalar(fMat[0][0]); dst[SkMatrix::kMSkewX] = SkMScalarToScalar(fMat[1][0]); @@ -952,5 +947,9 @@ SkMatrix44::operator SkMatrix() const { dst[SkMatrix::kMScaleY] = SkMScalarToScalar(fMat[1][1]); dst[SkMatrix::kMTransY] = SkMScalarToScalar(fMat[3][1]); + dst[SkMatrix::kMPersp0] = SkMScalarToScalar(fMat[0][3]); + dst[SkMatrix::kMPersp1] = SkMScalarToScalar(fMat[1][3]); + dst[SkMatrix::kMPersp2] = SkMScalarToScalar(fMat[3][3]); + return dst; } |