add SkMatrix::decomposeScale

BUG=skia:

Review URL: https://codereview.chromium.org/1006173005
diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp
index 9658177..753c4dc 100644
--- a/src/core/SkMatrix.cpp
+++ b/src/core/SkMatrix.cpp
@@ -1603,6 +1603,28 @@
     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 {