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

Unified Diff: skia/ext/skia_utils_mac.mm

Issue 2595113002: use skia cgimage->bitmap routine (Closed)
Patch Set: rebase Created 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/skia_utils_mac.mm
diff --git a/skia/ext/skia_utils_mac.mm b/skia/ext/skia_utils_mac.mm
index e2dbb80d0de31b5a5d6d8ecd660dd04a97bc5b10..a8102cb8af6cd954ad16869ee7e73d2918d010f2 100644
--- a/skia/ext/skia_utils_mac.mm
+++ b/skia/ext/skia_utils_mac.mm
@@ -184,31 +184,10 @@ NSColor* SkColorToSRGBNSColor(SkColor color) {
}
SkBitmap CGImageToSkBitmap(CGImageRef image) {
- if (!image)
- return SkBitmap();
-
- int width = CGImageGetWidth(image);
- int height = CGImageGetHeight(image);
-
- std::unique_ptr<SkCanvas> canvas(
- skia::TryCreateBitmapCanvas(width, height, false));
- ScopedPlatformPaint p(canvas.get());
- CGContextRef context = p.GetNativeDrawingContext();
-
- // 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, -height);
-
- // We want to copy transparent pixels from |image|, instead of blending it
- // onto uninitialized pixels.
- CGContextSetBlendMode(context, kCGBlendModeCopy);
-
- CGRect rect = CGRectMake(0, 0, width, height);
- CGContextDrawImage(context, rect, image);
-
- return skia::ReadPixels(canvas.get());
+ SkBitmap bitmap;
+ if (image && SkCreateBitmapFromCGImage(&bitmap, image))
+ return bitmap;
+ return SkBitmap();
}
SkBitmap NSImageToSkBitmapWithColorSpace(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698