aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkMatrix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/SkMatrix.cpp')
-rw-r--r--src/core/SkMatrix.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp
index 9658177ec9..753c4dc61e 100644
--- a/src/core/SkMatrix.cpp
+++ b/src/core/SkMatrix.cpp
@@ -1603,6 +1603,28 @@ const SkMatrix& SkMatrix::InvalidMatrix() {
return invalid.asSkMatrix();
}
+bool SkMatrix::decomposeScale(SkSize* scale, SkMatrix* remaining) const {
+ if (this->hasPerspective()) {
+ return false;
+ }
+
+ const SkScalar sx = SkVector::Length(this->getScaleX(), this->getSkewY());
+ const SkScalar sy = SkVector::Length(this->getSkewX(), this->getScaleY());
+ if (!SkScalarIsFinite(sx) || !SkScalarIsFinite(sy) ||
+ SkScalarNearlyZero(sx) || SkScalarNearlyZero(sy)) {
+ return false;
+ }
+
+ if (scale) {
+ scale->set(sx, sy);
+ }
+ if (remaining) {
+ *remaining = *this;
+ remaining->postScale(SkScalarInvert(sx), SkScalarInvert(sy));
+ }
+ return true;
+}
+
///////////////////////////////////////////////////////////////////////////////
size_t SkMatrix::writeToMemory(void* buffer) const {