summaryrefslogtreecommitdiffstats
path: root/skia/ext
diff options
context:
space:
mode:
authortapted@chromium.org <tapted@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-28 05:27:43 +0000
committertapted@chromium.org <tapted@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-28 05:27:43 +0000
commite5f893a16258bbb919678ab7d46f5951d727996a (patch)
tree644203e4f0a97a77d68065d6f6a5fc67fc3454ec /skia/ext
parent7439a2a660cef336fe5e57abc73607fdf1d2e794 (diff)
downloadchromium_src-e5f893a16258bbb919678ab7d46f5951d727996a.zip
chromium_src-e5f893a16258bbb919678ab7d46f5951d727996a.tar.gz
chromium_src-e5f893a16258bbb919678ab7d46f5951d727996a.tar.bz2
Add SkColorToSRGBNSColor to skia_mac_utils
When WCS is enabled, the sRGB color space is the default color space for Windows [1] and for CSS3 rgb values [2]. Using SkColorToCalibratedNSColor results in a different (typically ligher) color when used in Quartz drawing versus a web page, or for color constants from designers. This adds SkColorToSRGBNSColor to convert an SkColor value specified in the sRGB color space to an NSColor. [1] http://msdn.microsoft.com/en-us/library/windows/hardware/gg487409.aspx [2] http://www.w3.org/TR/css3-color/#rgb-color BUG=138633, 254361 Review URL: https://chromiumcodereview.appspot.com/17834003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209101 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/ext')
-rw-r--r--skia/ext/skia_utils_mac.h4
-rw-r--r--skia/ext/skia_utils_mac.mm12
2 files changed, 15 insertions, 1 deletions
diff --git a/skia/ext/skia_utils_mac.h b/skia/ext/skia_utils_mac.h
index 40eb6d4..e6f7b35 100644
--- a/skia/ext/skia_utils_mac.h
+++ b/skia/ext/skia_utils_mac.h
@@ -68,9 +68,11 @@ SK_API CGColorRef CGColorCreateFromSkColor(SkColor color);
// conversion. Only valid for colors in calibrated and device color spaces.
SK_API SkColor NSDeviceColorToSkColor(NSColor* color);
-// Converts ARGB to NSColor.
+// Converts ARGB in the specified color space to NSColor.
+// Prefer sRGB over calibrated colors.
SK_API NSColor* SkColorToCalibratedNSColor(SkColor color);
SK_API NSColor* SkColorToDeviceNSColor(SkColor color);
+SK_API NSColor* SkColorToSRGBNSColor(SkColor color);
// Converts a CGImage to a SkBitmap.
SK_API SkBitmap CGImageToSkBitmap(CGImageRef image);
diff --git a/skia/ext/skia_utils_mac.mm b/skia/ext/skia_utils_mac.mm
index 4d1ce00..213bb00 100644
--- a/skia/ext/skia_utils_mac.mm
+++ b/skia/ext/skia_utils_mac.mm
@@ -173,6 +173,18 @@ NSColor* SkColorToDeviceNSColor(SkColor color) {
alpha:SkColorGetA(color) / 255.0];
}
+NSColor* SkColorToSRGBNSColor(SkColor color) {
+ const CGFloat components[] = {
+ SkColorGetR(color) / 255.0,
+ SkColorGetG(color) / 255.0,
+ SkColorGetB(color) / 255.0,
+ SkColorGetA(color) / 255.0
+ };
+ return [NSColor colorWithColorSpace:[NSColorSpace sRGBColorSpace]
+ components:components
+ count:4];
+}
+
SkBitmap CGImageToSkBitmap(CGImageRef image) {
if (!image)
return SkBitmap();