Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(866)

Unified Diff: src/core/SkMatrixPriv.h

Issue 2276603002: combine setRectFan and mapRect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rearrange parameter order Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/gpu/GrQuad.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkMatrixPriv.h
diff --git a/src/core/SkMatrixPriv.h b/src/core/SkMatrixPriv.h
index 91185f08d148771b21b3e4d14afc8e634defabfb..844901c011eb5d22b560724c41ed7c56d65ad874 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
« no previous file with comments | « no previous file | src/gpu/GrQuad.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698