diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-12 19:08:26 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-12 19:08:26 +0000 |
commit | f86b491c0bc369e574c0e77613d402a1f84b0160 (patch) | |
tree | 0826a828df743a4da0ada439ee46f772df4a1d0c /skia | |
parent | 08bd655dc754babdc8787720b89566092f7dc06d (diff) | |
download | chromium_src-f86b491c0bc369e574c0e77613d402a1f84b0160.zip chromium_src-f86b491c0bc369e574c0e77613d402a1f84b0160.tar.gz chromium_src-f86b491c0bc369e574c0e77613d402a1f84b0160.tar.bz2 |
Mac: Explicitly set the colorspace on SkBitmap -> CGImageRef conversions.
The color space was hardcoded as "generic rgb" in skia. This is not always correct, also skia is changing this color space around a lot currently. To protect us from their unreliable default, hardcode "generic rgb" as default on our side for now, but make it possible for clients to provide their own color space.
Use this to let tabpose and the favicon code pass in the device colorspace.
BUG=24267,50307
TEST=Open tabpose. Delayed thumbnails should look like backing-store backed thumbnails. The colors of favicons should now match other browsers.
Review URL: http://codereview.chromium.org/6117006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71208 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia')
-rw-r--r-- | skia/ext/skia_utils_mac.h | 8 | ||||
-rw-r--r-- | skia/ext/skia_utils_mac.mm | 12 |
2 files changed, 17 insertions, 3 deletions
diff --git a/skia/ext/skia_utils_mac.h b/skia/ext/skia_utils_mac.h index 9a1636e..0551643 100644 --- a/skia/ext/skia_utils_mac.h +++ b/skia/ext/skia_utils_mac.h @@ -64,7 +64,13 @@ SkBitmap CGImageToSkBitmap(CGImageRef image); // Draws an NSImage with a given size into a SkBitmap. SkBitmap NSImageToSkBitmap(NSImage* image, NSSize size, bool is_opaque); -// Given an SkBitmap, return an autoreleased NSImage. +// Given an SkBitmap and a color space, return an autoreleased NSImage. +NSImage* SkBitmapToNSImageWithColorSpace(const SkBitmap& icon, + CGColorSpaceRef colorSpace); + +// Given an SkBitmap, return an autoreleased NSImage in the generic color space. +// DEPRECATED, use SkBitmapToNSImageWithColorSpace() instead. +// TODO(thakis): Remove this -- http://crbug.com/69432 NSImage* SkBitmapToNSImage(const SkBitmap& icon); // Returns |[NSImage imageNamed:@"NSApplicationIcon"]| as SkBitmap. diff --git a/skia/ext/skia_utils_mac.mm b/skia/ext/skia_utils_mac.mm index f52709b..171d329 100644 --- a/skia/ext/skia_utils_mac.mm +++ b/skia/ext/skia_utils_mac.mm @@ -167,12 +167,14 @@ SkBitmap NSImageToSkBitmap(NSImage* image, NSSize size, bool is_opaque) { return bitmap; } -NSImage* SkBitmapToNSImage(const SkBitmap& skiaBitmap) { +NSImage* SkBitmapToNSImageWithColorSpace(const SkBitmap& skiaBitmap, + CGColorSpaceRef colorSpace) { if (skiaBitmap.isNull()) return nil; // First convert SkBitmap to CGImageRef. - CGImageRef cgimage = SkCreateCGImageRef(skiaBitmap); + CGImageRef cgimage = + SkCreateCGImageRefWithColorspace(skiaBitmap, colorSpace); // Now convert to NSImage. NSBitmapImageRep* bitmap = [[[NSBitmapImageRep alloc] @@ -184,6 +186,12 @@ NSImage* SkBitmapToNSImage(const SkBitmap& skiaBitmap) { return image; } +NSImage* SkBitmapToNSImage(const SkBitmap& skiaBitmap) { + base::mac::ScopedCFTypeRef<CGColorSpaceRef> colorSpace( + CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB)); + return SkBitmapToNSImageWithColorSpace(skiaBitmap, colorSpace.get()); +} + SkBitmap AppplicationIconAtSize(int size) { NSImage* image = [NSImage imageNamed:@"NSApplicationIcon"]; return NSImageToSkBitmap(image, NSMakeSize(size, size), /* is_opaque=*/true); |