Chromium Code Reviews| Index: skia/ext/skia_utils_mac.mm |
| diff --git a/skia/ext/skia_utils_mac.mm b/skia/ext/skia_utils_mac.mm |
| index 57fb7076ba219c4b5ccefb292200c69b5d644638..bc3039794cb6efc7e039e33508c0fb884529a53d 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::CreatePlatformCanvas( |
| - nullptr, width, height, false, RETURN_NULL_ON_FAILURE)); |
| - 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 bm; |
|
dcheng
2016/12/21 22:37:22
Nit: bitmap
reed1
2016/12/22 13:42:53
Done.
|
| + if (image && SkCreateBitmapFromCGImage(&bm, image)) |
| + return bm; |
| + return SkBitmap(); |
|
dcheng
2016/12/21 22:37:22
This is technically unnecessary, since SkCreateBit
reed1
2016/12/22 13:42:53
It is a convenience if the caller wants to know if
|
| } |
| SkBitmap NSImageToSkBitmapWithColorSpace( |