Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(664)

Unified Diff: src/utils/SkMatrix44.cpp

Issue 25484006: Add perspective support to SkMatrix44 initializers. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Switch SkMatrix inputs to SkScalar and be more careful about scalar comparisons Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/utils/SkMatrix44.h ('k') | tests/Matrix44Test.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkMatrix44.cpp
diff --git a/src/utils/SkMatrix44.cpp b/src/utils/SkMatrix44.cpp
index 1e48f393ac6fd372faf781cd86af63122eb90466..9803b520950cf80310443613940098fcdb5f665d 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;
}
« no previous file with comments | « include/utils/SkMatrix44.h ('k') | tests/Matrix44Test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698