Handle rgb_to_a8 when kGenA8FromLCD_Flag is set.
authorbungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 1 Aug 2012 15:36:46 +0000 (15:36 +0000)
committerbungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 1 Aug 2012 15:36:46 +0000 (15:36 +0000)
git-svn-id: http://skia.googlecode.com/svn/trunk@4889 2bbb7eff-a529-9590-31e7-b0007b416f81

src/ports/SkFontHost_win.cpp

index fbe4bb1..7b3c8ad 100755 (executable)
@@ -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<bool APPLY_PREBLEND>
 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<APPLY_PREBLEND>((rgb >> 16) & 0xFF, table8);
+    U8CPU r = (rgb >> 16) & 0xFF;
+    U8CPU g = (rgb >>  8) & 0xFF;
+    U8CPU b = (rgb >>  0) & 0xFF;
+    return sk_apply_lut_if<APPLY_PREBLEND>((r + g + b) / 3, table8);
 }
 
 template<bool APPLY_PREBLEND>