aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-01-18 17:06:35 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-01-18 17:06:35 +0000
commit8351aabbfe82a76a698fa2bde00d33c1174518cd (patch)
tree61fd4f195e75889ff3b5b5baf9da53da0b1a8b81
parent2c1eb6f08d77d85d3d422444fc8f4b0b0fc25037 (diff)
add GenA8FromLCD as a hack to force GDI to create the A8 mask from the LCD
results, rather than asking GDI directly for A8 (which it sometimes decides to interpret as BW) git-svn-id: http://skia.googlecode.com/svn/trunk@3061 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--include/core/SkPaint.h5
-rw-r--r--include/core/SkScalerContext.h6
-rw-r--r--src/core/SkPaint.cpp3
-rwxr-xr-xsrc/ports/SkFontHost_win.cpp14
4 files changed, 22 insertions, 6 deletions
diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h
index 38234816c6..f5d98a9875 100644
--- a/include/core/SkPaint.h
+++ b/include/core/SkPaint.h
@@ -100,11 +100,12 @@ public:
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.
@@ -870,7 +871,7 @@ private:
SkColor fColor;
SkScalar fWidth;
SkScalar fMiterLimit;
- unsigned fFlags : 14;
+ unsigned fFlags : 15;
unsigned fTextAlign : 2;
unsigned fCapType : 2;
unsigned fJoinType : 2;
diff --git a/include/core/SkScalerContext.h b/include/core/SkScalerContext.h
index f59d489910..2e4d594122 100644
--- a/include/core/SkScalerContext.h
+++ b/include/core/SkScalerContext.h
@@ -175,8 +175,12 @@ public:
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
};
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index f7b3ae35fe..cf25dbf9ee 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -1440,6 +1440,9 @@ void SkScalerContext::MakeRec(const SkPaint& paint,
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
diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp
index 9d98bcb4e3..156f51cff2 100755
--- a/src/ports/SkFontHost_win.cpp
+++ b/src/ports/SkFontHost_win.cpp
@@ -468,7 +468,11 @@ static BYTE compute_quality(const SkScalerContext::Rec& rec) {
case SkMask::kLCD32_Format:
return CLEARTYPE_QUALITY;
default:
- return ANTIALIASED_QUALITY;
+ if (rec.fFlags & SkScalerContext::kGenA8FromLCD_Flag) {
+ return CLEARTYPE_QUALITY;
+ } else {
+ return ANTIALIASED_QUALITY;
+ }
}
}
@@ -713,12 +717,16 @@ static const uint8_t* getInverseGammaTable() {
// 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) {