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

Unified Diff: include/core/SkRSXform.h

Issue 1269563006: add helper to create RSXform w/ anchorPt (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: don't post-translate by anchor Created 5 years, 5 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 | samplecode/SampleAtlas.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkRSXform.h
diff --git a/include/core/SkRSXform.h b/include/core/SkRSXform.h
index 5dffdc25d954d00c42b4020c459a1f7a76c959f5..7af6e67c128d514396c6f91a84e4e99dd76cb99d 100644
--- a/include/core/SkRSXform.h
+++ b/include/core/SkRSXform.h
@@ -18,10 +18,28 @@
* [ 0 0 1 ]
*/
struct SkRSXform {
- SkScalar fSCos;
- SkScalar fSSin;
- SkScalar fTx;
- SkScalar fTy;
+ static SkRSXform Make(SkScalar scos, SkScalar ssin, SkScalar tx, SkScalar ty) {
+ SkRSXform xform = { scos, ssin, tx, ty };
+ return xform;
+ }
+
+ /*
+ * Initialize a new xform based on the scale, rotation (in radians), final tx,ty location
+ * and anchor-point ax,ay within the src quad.
+ *
+ * Note: the anchor point is not normalized (e.g. 0...1) but is in pixels of the src image.
+ */
+ static SkRSXform MakeFromRadians(SkScalar scale, SkScalar radians, SkScalar tx, SkScalar ty,
+ SkScalar ax, SkScalar ay) {
+ const SkScalar s = SkScalarSin(radians) * scale;
+ const SkScalar c = SkScalarCos(radians) * scale;
+ return Make(c, s, tx + -c * ax + s * ay, ty + -s * ax - c * ay);
+ }
+
+ SkScalar fSCos;
+ SkScalar fSSin;
+ SkScalar fTx;
+ SkScalar fTy;
bool rectStaysRect() const {
return 0 == fSCos || 0 == fSSin;
« no previous file with comments | « no previous file | samplecode/SampleAtlas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698