diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-29 18:57:00 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-29 18:57:00 +0000 |
commit | 9a26b0dc5e055f6cfb114ec904a67a9cbee6cfae (patch) | |
tree | ed1b3207a9280f4e454892fdb162107d5455425f /skia/ext | |
parent | d2cdbb1958899a7fc549c13c7677767b800d1001 (diff) | |
download | chromium_src-9a26b0dc5e055f6cfb114ec904a67a9cbee6cfae.zip chromium_src-9a26b0dc5e055f6cfb114ec904a67a9cbee6cfae.tar.gz chromium_src-9a26b0dc5e055f6cfb114ec904a67a9cbee6cfae.tar.bz2 |
Fix PrintWebViewHelperTest.AllowUserOriginatedPrinting on Win Aura.
This was triggering the assert in SkColorToCOLORREF because on Aura NativeThemeBase is used and PaintButton uses an alpha value that's not opaque.
BUG=154081
Review URL: https://codereview.chromium.org/11411256
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170228 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/ext')
-rw-r--r-- | skia/ext/skia_utils_win.cc | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/skia/ext/skia_utils_win.cc b/skia/ext/skia_utils_win.cc index 4988a3a..97d793c 100644 --- a/skia/ext/skia_utils_win.cc +++ b/skia/ext/skia_utils_win.cc @@ -54,16 +54,23 @@ SkColor COLORREFToSkColor(COLORREF color) { } COLORREF SkColorToCOLORREF(SkColor color) { - // Currently, Alpha is always 255 or the color is 0 so there is no need to - // demultiply the channels. If this DCHECK() is ever hit, the full - // (SkColorGetX(color) * 255 / a) will have to be added in the conversion. - SkASSERT((0xFF == SkColorGetA(color)) || (0 == color)); + int alpha = SkColorGetA(color); + if (alpha == 0) + return 0; + + if (alpha == 0xFF) { + // Fast path. #ifndef _MSC_VER - return RGB(SkColorGetR(color), SkColorGetG(color), SkColorGetB(color)); + return RGB(SkColorGetR(color), SkColorGetG(color), SkColorGetB(color)); #else - // 0BGR = ((ARGB -> BGRA) >> 8) - return (_byteswap_ulong(color) >> 8); + // 0BGR = ((ARGB -> BGRA) >> 8) + return (_byteswap_ulong(color) >> 8); #endif + } + + return RGB(SkColorGetR(color) * 255 / alpha, + SkColorGetG(color) * 255 / alpha, + SkColorGetB(color) * 255 / alpha); } } // namespace skia |