Chromium Code Reviews| Index: ui/gfx/image/image_mac.mm |
| diff --git a/ui/gfx/image/image_mac.mm b/ui/gfx/image/image_mac.mm |
| index c79100c408592f48e0029fdf13b0c30553aea42d..6c139f38010ff38efab9f46f3345812c7275c461 100644 |
| --- a/ui/gfx/image/image_mac.mm |
| +++ b/ui/gfx/image/image_mac.mm |
| @@ -48,7 +48,8 @@ scoped_refptr<base::RefCountedMemory> Get1xPNGBytesFromNSImage( |
| return refcounted_bytes; |
| } |
| -NSImage* NSImageFromPNG(const std::vector<gfx::ImagePNGRep>& image_png_reps) { |
| +NSImage* NSImageFromPNG(const std::vector<gfx::ImagePNGRep>& image_png_reps, |
| + CGColorSpaceRef color_space) { |
| if (image_png_reps.empty()) { |
| LOG(ERROR) << "Unable to decode PNG."; |
| return GetErrorNSImage(); |
| @@ -69,6 +70,26 @@ NSImage* NSImageFromPNG(const std::vector<gfx::ImagePNGRep>& image_png_reps) { |
| return GetErrorNSImage(); |
| } |
| + // PNGCodec ignores colorspace related ancillary chunks (sRGB, iCCP). Ignore |
| + // colorspace information when decoding directly from PNG to an NSImage so |
| + // that the conversions: PNG -> SkBitmap -> NSImage and PNG -> NSImage |
| + // produce visually similar results. |
| + CGColorSpaceModel color_space_model = CGColorSpaceGetModel( |
| + [[ns_image_rep colorSpace] CGColorSpace]); |
| + CGColorSpaceModel decoded_color_space_model = |
| + CGColorSpaceGetModel(color_space); |
| + if (color_space_model == decoded_color_space_model) { |
| + scoped_nsobject<NSColorSpace> ns_color_space( |
| + [[NSColorSpace alloc] initWithCGColorSpace: color_space]); |
|
Avi (use Gerrit)
2013/06/12 01:35:29
drive by: no space after the colon
|
| + NSBitmapImageRep* ns_retagged_image_rep = |
| + [ns_image_rep |
| + bitmapImageRepByRetaggingWithColorSpace: ns_color_space]; |
|
Avi (use Gerrit)
2013/06/12 01:35:29
drive by: no space after the colon
|
| + if (ns_retagged_image_rep && ns_retagged_image_rep != ns_image_rep) { |
| + [ns_retagged_image_rep retain]; |
|
pkotwicz
2013/06/12 01:26:19
I am confused why I need to retain |ns_retagged_im
Avi (use Gerrit)
2013/06/12 01:35:29
It comes from -bitmapImageRepByRetaggingWithColorS
|
| + ns_image_rep.reset(ns_retagged_image_rep); |
| + } |
| + } |
| + |
| if (!image.get()) { |
| float scale = ui::GetScaleFactorScale(image_png_reps[i].scale_factor); |
| NSSize image_size = NSMakeSize([ns_image_rep pixelsWide] / scale, |