aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkScalerContext.h
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-11-22 19:42:41 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-11-22 19:42:41 +0000
commitffe49f5380dd5062073efeda70f2f91682c828ca (patch)
treea36192068d5ae373e938b3bb9ac978ef5083f27f /include/core/SkScalerContext.h
parent8caac6447dd68655b57dfe876626a9733b191416 (diff)
store 3 bits of luminance, but (for now) discretize that in fonthost::filterec
for backward compatibility git-svn-id: http://skia.googlecode.com/svn/trunk@2732 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core/SkScalerContext.h')
-rw-r--r--include/core/SkScalerContext.h43
1 files changed, 33 insertions, 10 deletions
diff --git a/include/core/SkScalerContext.h b/include/core/SkScalerContext.h
index 9b3264087b..22c22270ee 100644
--- a/include/core/SkScalerContext.h
+++ b/include/core/SkScalerContext.h
@@ -164,23 +164,29 @@ public:
kSubpixelPositioning_Flag = 0x0010,
kAutohinting_Flag = 0x0020,
kVertical_Flag = 0x0040,
+
// together, these two flags resulting in a two bit value which matches
// up with the SkPaint::Hinting enum.
+ kHinting_Shift = 7, // to shift into the other flags above
kHintingBit1_Flag = 0x0080,
kHintingBit2_Flag = 0x0100,
+
// these should only ever be set if fMaskFormat is LCD16 or LCD32
kLCD_Vertical_Flag = 0x0200, // else Horizontal
kLCD_BGROrder_Flag = 0x0400, // else RGB order
- // gamma flags
- kGammaForBlack_Flag = 0x0800,
- kGammaForWhite_Flag = 0x1000,
+
+ // luminance : 0 for black text, kLuminance_Max for white text
+ kLuminance_Shift = 11, // to shift into the other flags above
+ kLuminance_Bits = 3, // ensure Flags doesn't exceed 16bits
};
-private:
+
+ // computed values
enum {
- kHintingMask = kHintingBit1_Flag | kHintingBit2_Flag,
- kHintingShift = 7
+ kHinting_Mask = kHintingBit1_Flag | kHintingBit2_Flag,
+ kLuminance_Max = (1 << kLuminance_Bits) - 1,
+ kLuminance_Mask = kLuminance_Max << kLuminance_Shift,
};
-public:
+
struct Rec {
uint32_t fOrigFontID;
uint32_t fFontID;
@@ -200,12 +206,29 @@ public:
void getSingleMatrix(SkMatrix*) const;
SkPaint::Hinting getHinting() const {
- unsigned hint = (fFlags & kHintingMask) >> kHintingShift;
+ unsigned hint = (fFlags & kHinting_Mask) >> kHinting_Shift;
return static_cast<SkPaint::Hinting>(hint);
}
void setHinting(SkPaint::Hinting hinting) {
- fFlags = (fFlags & ~kHintingMask) | (hinting << kHintingShift);
+ fFlags = (fFlags & ~kHinting_Mask) | (hinting << kHinting_Shift);
+ }
+
+ unsigned getLuminanceBits() const {
+ return (fFlags & kLuminance_Mask) >> kLuminance_Shift;
+ }
+
+ void setLuminanceBits(unsigned lum) {
+ SkASSERT(lum <= kLuminance_Max);
+ fFlags = (fFlags & ~kLuminance_Mask) | (lum << kLuminance_Shift);
+ }
+
+ U8CPU getLuminanceByte() const {
+ SkASSERT(3 == kLuminance_Bits);
+ unsigned lum = this->getLuminanceBits();
+ lum |= (lum << kLuminance_Bits);
+ lum |= (lum << kLuminance_Bits*2);
+ return lum >> (4*kLuminance_Bits - 8);
}
SkMask::Format getFormat() const {
@@ -230,7 +253,7 @@ public:
fact correspond to a different font/context. In that case, we use the
base-glyph-count to know how to translate back into local glyph space.
*/
- uint16_t charToGlyphID(SkUnichar uni);
+ uint16_t charToGlyphID(SkUnichar uni);
/** Map the glyphID to its glyph index, and then to its char code. Unmapped
glyphs return zero.