Index: src/core/SkMatrix.cpp |
diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp |
index 5711bd9aef2f169fba19af723be848dbc0cef584..492f3f6ac447fd3575dbcb775b6a7abf4531644b 100644 |
--- a/src/core/SkMatrix.cpp |
+++ b/src/core/SkMatrix.cpp |
@@ -1097,12 +1097,32 @@ void SkMatrix::mapVectors(SkPoint dst[], const SkPoint src[], int count) const { |
} |
} |
+void SkMatrix::mapRectScaleTranslate(SkRect* dst, const SkRect& src) const { |
+ SkASSERT(dst); |
+ SkASSERT(this->isScaleTranslate()); |
+ |
+ SkScalar sx = fMat[kMScaleX]; |
+ SkScalar sy = fMat[kMScaleY]; |
+ SkScalar tx = fMat[kMTransX]; |
+ SkScalar ty = fMat[kMTransY]; |
+ Sk4f scale(sx, sy, sx, sy); |
+ Sk4f trans(tx, ty, tx, ty); |
+ |
+ Sk4f ltrb = Sk4f::Load(&src.fLeft) * scale + trans; |
+ // need to sort so we're not inverted |
+ Sk4f rblt(ltrb[2], ltrb[3], ltrb[0], ltrb[1]); |
+ Sk4f min = Sk4f::Min(ltrb, rblt); |
+ Sk4f max = Sk4f::Max(ltrb, rblt); |
+ // We can extract either pair [0,1] or [2,3] from min and max and be correct, but on |
+ // ARM this sequence generates the fastest (a single instruction). |
+ Sk4f(min[2], min[3], max[0], max[1]).store(&dst->fLeft); |
+} |
+ |
bool SkMatrix::mapRect(SkRect* dst, const SkRect& src) const { |
SkASSERT(dst); |
- if (this->rectStaysRect()) { |
- this->mapPoints((SkPoint*)dst, (const SkPoint*)&src, 2); |
- dst->sort(); |
+ if (this->isScaleTranslate()) { |
+ this->mapRectScaleTranslate(dst, src); |
return true; |
} else { |
SkPoint quad[4]; |