Index: src/core/SkMatrix.cpp |
diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp |
index fb0c69d7c7287d8428e9de233c85e38280374a69..a05ae0a177670a298b4945e870a534d7c584183f 100644 |
--- a/src/core/SkMatrix.cpp |
+++ b/src/core/SkMatrix.cpp |
@@ -1102,6 +1102,15 @@ void SkMatrix::mapVectors(SkPoint dst[], const SkPoint src[], int count) const { |
} |
} |
+static Sk4f sort_as_rect(const Sk4f& ltrb) { |
+ 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). |
+ return Sk4f(min[2], min[3], max[0], max[1]); |
+} |
+ |
void SkMatrix::mapRectScaleTranslate(SkRect* dst, const SkRect& src) const { |
SkASSERT(dst); |
SkASSERT(this->isScaleTranslate()); |
@@ -1112,20 +1121,19 @@ void SkMatrix::mapRectScaleTranslate(SkRect* dst, const SkRect& src) const { |
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); |
+ sort_as_rect(Sk4f::Load(&src.fLeft) * scale + trans).store(&dst->fLeft); |
} |
bool SkMatrix::mapRect(SkRect* dst, const SkRect& src) const { |
SkASSERT(dst); |
+ if (this->getType() <= kTranslate_Mask) { |
+ SkScalar tx = fMat[kMTransX]; |
+ SkScalar ty = fMat[kMTransY]; |
+ Sk4f trans(tx, ty, tx, ty); |
+ sort_as_rect(Sk4f::Load(&src.fLeft) + trans).store(&dst->fLeft); |
+ return true; |
+ } |
if (this->isScaleTranslate()) { |
this->mapRectScaleTranslate(dst, src); |
return true; |