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

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..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,
« 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