diff options
author | keishi@chromium.org <keishi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-15 12:39:52 +0000 |
---|---|---|
committer | keishi@chromium.org <keishi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-15 12:39:52 +0000 |
commit | 1075da5df3dfec5adc6816aa2ac736d71c55a6c9 (patch) | |
tree | 3bb12c846a2d5d18039d55d180bcd5948bdaf0c2 /skia | |
parent | 2614ed923300f66bd8f9bd2d109f0be5eed69a0d (diff) | |
download | chromium_src-1075da5df3dfec5adc6816aa2ac736d71c55a6c9.zip chromium_src-1075da5df3dfec5adc6816aa2ac736d71c55a6c9.tar.gz chromium_src-1075da5df3dfec5adc6816aa2ac736d71c55a6c9.tar.bz2 |
Implement input type=color UI
BUG=92608
TEST=
Review URL: http://codereview.chromium.org/9203001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126889 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia')
-rw-r--r-- | skia/ext/skia_utils_mac.h | 5 | ||||
-rw-r--r-- | skia/ext/skia_utils_mac.mm | 20 |
2 files changed, 25 insertions, 0 deletions
diff --git a/skia/ext/skia_utils_mac.h b/skia/ext/skia_utils_mac.h index 8d11165..683ddf0 100644 --- a/skia/ext/skia_utils_mac.h +++ b/skia/ext/skia_utils_mac.h @@ -64,8 +64,13 @@ SkColor CGColorRefToSkColor(CGColorRef color); // Converts ARGB to CGColorRef. CGColorRef SkColorToCGColorRef(SkColor color); +// Converts NSColor to ARGB. Returns raw rgb values and does no colorspace +// conversion. Only valid for colors in calibrated and device color spaces. +SK_API SkColor NSDeviceColorToSkColor(NSColor* color); + // Converts ARGB to NSColor. SK_API NSColor* SkColorToCalibratedNSColor(SkColor color); +SK_API NSColor* SkColorToDeviceNSColor(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 d639460..0c82a95e 100644 --- a/skia/ext/skia_utils_mac.mm +++ b/skia/ext/skia_utils_mac.mm @@ -190,6 +190,19 @@ CGColorRef SkColorToCGColorRef(SkColor color) { SkColorGetA(color) / 255.0); } +// Converts NSColor to ARGB +SkColor NSDeviceColorToSkColor(NSColor* color) { + DCHECK([color colorSpace] == [NSColorSpace genericRGBColorSpace] || + [color colorSpace] == [NSColorSpace deviceRGBColorSpace]); + CGFloat red, green, blue, alpha; + color = [color colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]]; + [color getRed:&red green:&green blue:&blue alpha:&alpha]; + return SkColorSetARGB(SkScalarRound(255.0 * alpha), + SkScalarRound(255.0 * red), + SkScalarRound(255.0 * green), + SkScalarRound(255.0 * blue)); +} + // Converts ARGB to NSColor. NSColor* SkColorToCalibratedNSColor(SkColor color) { return [NSColor colorWithCalibratedRed:SkColorGetR(color) / 255.0 @@ -198,6 +211,13 @@ NSColor* SkColorToCalibratedNSColor(SkColor color) { alpha:SkColorGetA(color) / 255.0]; } +NSColor* SkColorToDeviceNSColor(SkColor color) { + return [NSColor colorWithDeviceRed:SkColorGetR(color) / 255.0 + green:SkColorGetG(color) / 255.0 + blue:SkColorGetB(color) / 255.0 + alpha:SkColorGetA(color) / 255.0]; +} + SkBitmap CGImageToSkBitmap(CGImageRef image) { if (!image) return SkBitmap(); |