From 6385314686875ecb484d95b33fcbf08890b5144d Mon Sep 17 00:00:00 2001 From: "bungeman@google.com" Date: Wed, 1 Aug 2012 15:36:46 +0000 Subject: [PATCH] Handle rgb_to_a8 when kGenA8FromLCD_Flag is set. git-svn-id: http://skia.googlecode.com/svn/trunk@4889 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/ports/SkFontHost_win.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp index fbe4bb1..7b3c8ad 100755 --- a/src/ports/SkFontHost_win.cpp +++ b/src/ports/SkFontHost_win.cpp @@ -954,11 +954,13 @@ static const uint8_t* getInverseGammaTableClearType() { #include "SkColorPriv.h" +//Cannot assume that the input rgb is gray due to possible setting of kGenA8FromLCD_Flag. template static inline uint8_t rgb_to_a8(SkGdiRGB rgb, const uint8_t* table8) { - SkASSERT( ((rgb >> 16) & 0xFF) == ((rgb >> 8) & 0xFF) && - ((rgb >> 16) & 0xFF) == ((rgb >> 0) & 0xFF) ); - return sk_apply_lut_if((rgb >> 16) & 0xFF, table8); + U8CPU r = (rgb >> 16) & 0xFF; + U8CPU g = (rgb >> 8) & 0xFF; + U8CPU b = (rgb >> 0) & 0xFF; + return sk_apply_lut_if((r + g + b) / 3, table8); } template -- 2.7.4