kEmbeddedBitmapText_Flag = 0x400, //!< mask to enable embedded bitmap strikes
kAutoHinting_Flag = 0x800, //!< mask to force Freetype's autohinter
kVerticalText_Flag = 0x1000,
+ kGenA8FromLCD_Flag = 0x2000, // hack for GDI -- do not use if you can help it
// when adding extra flags, note that the fFlags member is specified
// with a bit-width and you'll have to expand it.
- kAllFlags = 0x1FFF
+ kAllFlags = 0x3FFF
};
/** Return the paint's flags. Use the Flag enum to test flag values.
SkColor fColor;
SkScalar fWidth;
SkScalar fMiterLimit;
- unsigned fFlags : 14;
+ unsigned fFlags : 15;
unsigned fTextAlign : 2;
unsigned fCapType : 2;
unsigned fJoinType : 2;
kLCD_Vertical_Flag = 0x0200, // else Horizontal
kLCD_BGROrder_Flag = 0x0400, // else RGB order
+ // Generate A8 from LCD source (for GDI), only meaningful if fMaskFormat is kA8
+ // Perhaps we can store this (instead) in fMaskFormat, in hight bit?
+ kGenA8FromLCD_Flag = 0x0800,
+
// luminance : 0 for black text, kLuminance_Max for white text
- kLuminance_Shift = 11, // to shift into the other flags above
+ kLuminance_Shift = 13, // shift to land in the high 3-bits of Flags
kLuminance_Bits = 3, // ensure Flags doesn't exceed 16bits
};
if (paint.isVerticalText()) {
flags |= SkScalerContext::kVertical_Flag;
}
+ if (paint.getFlags() & SkPaint::kGenA8FromLCD_Flag) {
+ flags |= SkScalerContext::kGenA8FromLCD_Flag;
+ }
rec->fFlags = SkToU16(flags);
// these modify fFlags, so do them after assigning fFlags
case SkMask::kLCD32_Format:
return CLEARTYPE_QUALITY;
default:
- return ANTIALIASED_QUALITY;
+ if (rec.fFlags & SkScalerContext::kGenA8FromLCD_Flag) {
+ return CLEARTYPE_QUALITY;
+ } else {
+ return ANTIALIASED_QUALITY;
+ }
}
}
// gdi's bitmap is upside-down, so we reverse dst walking in Y
// whenever we copy it into skia's buffer
+static int compute_luminance(int r, int g, int b) {
+// return (r * 2 + g * 5 + b) >> 3;
+ return (r * 27 + g * 92 + b * 9) >> 7;
+}
+
static inline uint8_t rgb_to_a8(SkGdiRGB rgb) {
int r = (rgb >> 16) & 0xFF;
int g = (rgb >> 8) & 0xFF;
int b = (rgb >> 0) & 0xFF;
-
- return (r * 2 + g * 5 + b) >> 3; // luminance
+ return compute_luminance(r, g, b);
}
static inline uint16_t rgb_to_lcd16(SkGdiRGB rgb) {