diff options
author | msarett <msarett@google.com> | 2016-06-23 12:42:29 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-06-23 12:42:29 -0700 |
commit | c1a3e24918f99fc0b975111afb39dca38c50eb5c (patch) | |
tree | 8bfaaff83d9fac23c532f2a1dcff1ed804b8453d /include/core/SkMatrix44.h | |
parent | ac5fcea9c3ec32a87bfd8cb96531e82097a1d861 (diff) |
SkMatrix44 clarifications and clean-ups
Fixed row/col major bug and added comments to the
header.
Made SkMatrix::I() thread safe using constexpr.
Added a test set3x3RowMajorf().
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2098583002
Review-Url: https://codereview.chromium.org/2098583002
Diffstat (limited to 'include/core/SkMatrix44.h')
-rw-r--r-- | include/core/SkMatrix44.h | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/include/core/SkMatrix44.h b/include/core/SkMatrix44.h index 715ee782c8..6b5e65d072 100644 --- a/include/core/SkMatrix44.h +++ b/include/core/SkMatrix44.h @@ -136,8 +136,15 @@ public: kIdentity_Constructor }; - SkMatrix44(Uninitialized_Constructor) { } - SkMatrix44(Identity_Constructor) { this->setIdentity(); } + SkMatrix44(Uninitialized_Constructor) {} + + constexpr SkMatrix44(Identity_Constructor) + : fMat{{ 1, 0, 0, 0, }, + { 0, 1, 0, 0, }, + { 0, 0, 1, 0, }, + { 0, 0, 0, 1, }} + , fTypeMask(kIdentity_Mask) + {} SK_ATTR_DEPRECATED("use the constructors that take an enum") SkMatrix44() { this->setIdentity(); } @@ -281,6 +288,10 @@ public: * array. The given array must have room for exactly 16 entries. Whenever * possible, they will try to use memcpy rather than an entry-by-entry * copy. + * + * Col major indicates that consecutive elements of columns will be stored + * contiguously in memory. Row major indicates that consecutive elements + * of rows will be stored contiguously in memory. */ void asColMajorf(float[]) const; void asColMajord(double[]) const; @@ -291,6 +302,11 @@ public: * array. The given array must have room for exactly 16 entries. Whenever * possible, they will try to use memcpy rather than an entry-by-entry * copy. + * + * Col major indicates that input memory will be treated as if consecutive + * elements of columns are stored contiguously in memory. Row major + * indicates that input memory will be treated as if consecutive elements + * of rows are stored contiguously in memory. */ void setColMajorf(const float[]); void setColMajord(const double[]); @@ -306,11 +322,12 @@ public: #endif /* This sets the top-left of the matrix and clears the translation and - * perspective components (with [3][3] set to 1). */ + * perspective components (with [3][3] set to 1). mXY is interpreted + * as the matrix entry at col = X, row = Y. */ void set3x3(SkMScalar m00, SkMScalar m01, SkMScalar m02, SkMScalar m10, SkMScalar m11, SkMScalar m12, SkMScalar m20, SkMScalar m21, SkMScalar m22); - void set3x3ColMajorf(const float[]); + void set3x3RowMajorf(const float[]); void setTranslate(SkMScalar dx, SkMScalar dy, SkMScalar dz); void preTranslate(SkMScalar dx, SkMScalar dy, SkMScalar dz); @@ -430,6 +447,7 @@ public: double determinant() const; private: + /* This is indexed by [col][row]. */ SkMScalar fMat[4][4]; mutable unsigned fTypeMask; @@ -439,13 +457,7 @@ private: kAllPublic_Masks = 0xF }; - /** Efficiently reads 12 matrix entries, ignoring the last col. - * This is typically useful when we know the last col is (0, 0, 0, 1). - */ void as4x3ColMajorf(float[]) const; - - /* This sets the top-left of the matrix and clears the - * perspective components (with [3][3] set to 1). */ void set4x3ColMajorf(const float[]); SkMScalar transX() const { return fMat[3][0]; } |