Index: src/core/SkMatrixPriv.h |
diff --git a/src/core/SkMatrixPriv.h b/src/core/SkMatrixPriv.h |
index 91185f08d148771b21b3e4d14afc8e634defabfb..4c39957922c731a1346d361fa8904f3aaa15d958 100644 |
--- a/src/core/SkMatrixPriv.h |
+++ b/src/core/SkMatrixPriv.h |
@@ -65,6 +65,38 @@ public: |
pts = (SkPoint*)((intptr_t)pts + stride); |
} |
} |
+ |
robertphillips
2016/08/23 19:50:19
Would the mx, rect, quad parameter order be more p
bsalomon
2016/08/23 20:15:40
I'd be in favor of any order that had the two inpu
|
+ static void SetMappedRectFan(const SkMatrix& mx, SkPoint quad[4], const SkRect& rect) { |
+ SkMatrix::TypeMask tm = mx.getType(); |
+ SkScalar l = rect.fLeft; |
+ SkScalar t = rect.fTop; |
+ SkScalar r = rect.fRight; |
+ SkScalar b = rect.fBottom; |
+ if (tm <= (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask)) { |
+ const SkScalar tx = mx.getTranslateX(); |
+ const SkScalar ty = mx.getTranslateY(); |
+ if (tm <= SkMatrix::kTranslate_Mask) { |
+ l += tx; |
+ t += ty; |
+ r += tx; |
+ b += ty; |
+ } else { |
+ const SkScalar sx = mx.getScaleX(); |
+ const SkScalar sy = mx.getScaleY(); |
+ l = sx * l + tx; |
+ t = sy * t + ty; |
+ r = sx * r + tx; |
+ b = sy * b + ty; |
+ } |
+ quad[0].set(l, t); |
+ quad[1].set(l, b); |
+ quad[2].set(r, b); |
+ quad[3].set(r, t); |
+ } else { |
+ quad[0].setRectFan(l, t, r, b); |
+ mx.mapPoints(quad, quad, 4); |
+ } |
+ } |
}; |
#endif |