summaryrefslogtreecommitdiffstats
path: root/skia/ext
diff options
context:
space:
mode:
Diffstat (limited to 'skia/ext')
-rw-r--r--skia/ext/skia_utils_ios.mm6
1 files changed, 6 insertions, 0 deletions
diff --git a/skia/ext/skia_utils_ios.mm b/skia/ext/skia_utils_ios.mm
index 9d4c14a..a52a998 100644
--- a/skia/ext/skia_utils_ios.mm
+++ b/skia/ext/skia_utils_ios.mm
@@ -47,6 +47,12 @@ SkBitmap UIImageToSkBitmap(UIImage* image, CGSize size, bool is_opaque) {
if (!context)
return bitmap;
+ // We need to invert the y-axis of the canvas so that Core Graphics drawing
+ // happens right-side up. Skia has an upper-left origin and CG has a lower-
+ // left one.
+ CGContextScaleCTM(context, 1.0, -1.0);
+ CGContextTranslateCTM(context, 0, -size.height);
+
// UIGraphicsPushContext be called from the main thread.
// TODO(rohitrao): We can use CG to make this thread safe, but the mac code
// calls setCurrentContext, so it's similarly limited to the main thread.