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

Unified Diff: skia/ext/skia_utils_ios.mm

Issue 10963064: Properly flip the CGContext during UIImage->SkBitmap conversions. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Review. Created 8 years, 3 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 | ui/gfx/image/image_unittest.cc » ('j') | ui/gfx/image/image_unittest_util_ios.mm » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/skia_utils_ios.mm
diff --git a/skia/ext/skia_utils_ios.mm b/skia/ext/skia_utils_ios.mm
index 9d4c14a45f83892c27b86b531ae544854c96ae24..a52a998b7694ef3fafe8667ed83195e2cadb3b14 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.
« no previous file with comments | « no previous file | ui/gfx/image/image_unittest.cc » ('j') | ui/gfx/image/image_unittest_util_ios.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698