aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-07-05 20:10:42 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-07-05 20:10:42 -0700
commit2dcb615c6f4822352cac1ef4dc20303ebd1ad171 (patch)
tree68323767dfdd1ad42de8ed58d727e19b4f8b5289
parentec7f2ac7285ad9b1ea84e7aa68a741ae2a07a777 (diff)
make setScaleTranslate public
-rw-r--r--include/core/SkMatrix.h49
-rw-r--r--tests/MatrixTest.cpp5
2 files changed, 31 insertions, 23 deletions
diff --git a/include/core/SkMatrix.h b/include/core/SkMatrix.h
index d6d029597f..5b22a77481 100644
--- a/include/core/SkMatrix.h
+++ b/include/core/SkMatrix.h
@@ -710,6 +710,32 @@ public:
this->setTypeMask(kUnknown_Mask);
}
+ /**
+ * Initialize the matrix to be scale + post-translate.
+ */
+ void setScaleTranslate(SkScalar sx, SkScalar sy, SkScalar tx, SkScalar ty) {
+ fMat[kMScaleX] = sx;
+ fMat[kMSkewX] = 0;
+ fMat[kMTransX] = tx;
+
+ fMat[kMSkewY] = 0;
+ fMat[kMScaleY] = sy;
+ fMat[kMTransY] = ty;
+
+ fMat[kMPersp0] = 0;
+ fMat[kMPersp1] = 0;
+ fMat[kMPersp2] = 1;
+
+ unsigned mask = 0;
+ if (sx != 1 || sy != 1) {
+ mask |= kScale_Mask;
+ }
+ if (tx || ty) {
+ mask |= kTranslate_Mask;
+ }
+ this->setTypeMask(mask | kRectStaysRect_Mask);
+ }
+
private:
enum {
/** Set if the matrix will map a rectangle to another rectangle. This
@@ -748,29 +774,6 @@ private:
static void ComputeInv(SkScalar dst[9], const SkScalar src[9], double invDet, bool isPersp);
- void setScaleTranslate(SkScalar sx, SkScalar sy, SkScalar tx, SkScalar ty) {
- fMat[kMScaleX] = sx;
- fMat[kMSkewX] = 0;
- fMat[kMTransX] = tx;
-
- fMat[kMSkewY] = 0;
- fMat[kMScaleY] = sy;
- fMat[kMTransY] = ty;
-
- fMat[kMPersp0] = 0;
- fMat[kMPersp1] = 0;
- fMat[kMPersp2] = 1;
-
- unsigned mask = 0;
- if (sx != 1 || sy != 1) {
- mask |= kScale_Mask;
- }
- if (tx || ty) {
- mask |= kTranslate_Mask;
- }
- this->setTypeMask(mask | kRectStaysRect_Mask);
- }
-
uint8_t computeTypeMask() const;
uint8_t computePerspectiveTypeMask() const;
diff --git a/tests/MatrixTest.cpp b/tests/MatrixTest.cpp
index 01b2ba4e43..c4eb9c7011 100644
--- a/tests/MatrixTest.cpp
+++ b/tests/MatrixTest.cpp
@@ -939,6 +939,11 @@ DEF_TEST(Matrix, reporter) {
test_set9(reporter);
test_decompScale(reporter);
+
+ mat.setScaleTranslate(2, 3, 1, 4);
+ mat2.setScale(2, 3);
+ mat2.postTranslate(1, 4);
+ REPORTER_ASSERT(reporter, mat == mat2);
}
DEF_TEST(Matrix_Concat, r) {