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

Unified Diff: ui/gfx/image/image_mac.mm

Issue 16370006: Make the favicons look visually the same after refreshing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | « ui/gfx/image/image.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..0158521d007f97cee5f26e454f5987c660192340 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,23 @@ 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 decoded_color_space_model = CGColorSpaceGetModel(
+ [[ns_image_rep colorSpace] CGColorSpace]);
+ CGColorSpaceModel color_space_model = CGColorSpaceGetModel(color_space);
+ if (decoded_color_space_model == color_space_model) {
+ scoped_nsobject<NSColorSpace> ns_color_space(
+ [[NSColorSpace alloc] initWithCGColorSpace:color_space]);
+ NSBitmapImageRep* ns_retagged_image_rep =
+ [ns_image_rep
+ bitmapImageRepByRetaggingWithColorSpace:ns_color_space];
+ if (ns_retagged_image_rep && ns_retagged_image_rep != ns_image_rep)
+ ns_image_rep.reset([ns_retagged_image_rep retain]);
+ }
+
if (!image.get()) {
float scale = ui::GetScaleFactorScale(image_png_reps[i].scale_factor);
NSSize image_size = NSMakeSize([ns_image_rep pixelsWide] / scale,
« no previous file with comments | « ui/gfx/image/image.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698