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

Unified Diff: ui/gfx/skia_util.cc

Issue 1497543004: ui/gfx: Add MapRect and ExtractScale skia helper functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 | « ui/gfx/skia_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/skia_util.cc
diff --git a/ui/gfx/skia_util.cc b/ui/gfx/skia_util.cc
index d3a1ac8874c0670717c732dd8d482f9d5c85d21b..db2c8930c38df8deedb7b727945dfd0b80d431d0 100644
--- a/ui/gfx/skia_util.cc
+++ b/ui/gfx/skia_util.cc
@@ -223,4 +223,21 @@ void QuadFToSkPoints(const gfx::QuadF& quad, SkPoint points[4]) {
points[3] = PointFToSkPoint(quad.p4());
}
+bool ExtractScale(const SkMatrix& matrix, SkSize* scale) {
+ *scale = SkSize::Make(matrix.getScaleX(), matrix.getScaleY());
+ if (matrix.getType() & SkMatrix::kAffine_Mask) {
+ if (!matrix.decomposeScale(scale)) {
+ scale->set(1.f, 1.f);
+ return false;
+ }
+ }
+ return true;
+}
+
+SkRect MapRect(const SkMatrix& matrix, const SkRect& src) {
danakj 2015/12/03 00:12:35 I question why you're using an SkMatrix and not a
+ SkRect dst;
+ matrix.mapRect(&dst, src);
+ return dst;
+}
+
} // namespace gfx
« no previous file with comments | « ui/gfx/skia_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698