Chromium Code Reviews| Index: src/core/SkMatrix.cpp |
| diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp |
| index 9658177ec913e3b3e091104d31224e798532df70..0c7f110b13dc16cd9e549e59af7261c1b6a46df5 100644 |
| --- a/src/core/SkMatrix.cpp |
| +++ b/src/core/SkMatrix.cpp |
| @@ -1603,6 +1603,27 @@ 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()); |
|
robertphillips
2015/03/19 18:10:34
Should this check be a little fuzzy? We are going
reed1
2015/03/19 20:13:39
Done.
|
| + if (0 == sx || 0 == 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 { |