aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkMatrixPriv.h
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-08-24 04:22:08 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-24 04:22:08 -0700
commit6a88206b2ece8b64534c87fca156e5fe161f884e (patch)
tree340348c99fcd4b8f04153beb00b6645648553da5 /src/core/SkMatrixPriv.h
parent9dc6cf6b8833d36c29a23d2519989b069745fcd5 (diff)
combine setRectFan and mapRect
Diffstat (limited to 'src/core/SkMatrixPriv.h')
-rw-r--r--src/core/SkMatrixPriv.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/core/SkMatrixPriv.h b/src/core/SkMatrixPriv.h
index 91185f08d1..844901c011 100644
--- a/src/core/SkMatrixPriv.h
+++ b/src/core/SkMatrixPriv.h
@@ -65,6 +65,38 @@ public:
pts = (SkPoint*)((intptr_t)pts + stride);
}
}
+
+ static void SetMappedRectFan(const SkMatrix& mx, const SkRect& rect, SkPoint quad[4]) {
+ 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