diff options
Diffstat (limited to 'include/core/SkScalerContext.h')
-rw-r--r-- | include/core/SkScalerContext.h | 57 |
1 files changed, 37 insertions, 20 deletions
diff --git a/include/core/SkScalerContext.h b/include/core/SkScalerContext.h index 59d7125..0c93e2e 100644 --- a/include/core/SkScalerContext.h +++ b/include/core/SkScalerContext.h @@ -29,7 +29,10 @@ class SkPathEffect; class SkRasterizer; // needs to be != to any valid SkMask::Format -#define MASK_FORMAT_JUST_ADVANCE (0xFF) +#define MASK_FORMAT_UNKNOWN (0xFF) +#define MASK_FORMAT_JUST_ADVANCE MASK_FORMAT_UNKNOWN + +#define kMaxGlyphWidth (1<<13) struct SkGlyph { void* fImage; @@ -42,25 +45,38 @@ struct SkGlyph { uint8_t fMaskFormat; int8_t fRsbDelta, fLsbDelta; // used by auto-kerning - + + void init(uint32_t id) { + fID = id; + fImage = NULL; + fPath = NULL; + fMaskFormat = MASK_FORMAT_UNKNOWN; +#ifdef SK_GPU_AWARE_GLYPHCACHE + fGLCacheOffset = SKGLYPH_GLCACHEOFFSET_INVALID; + fGLStrikePtr = NULL; +#endif + } + unsigned rowBytes() const { unsigned rb = fWidth; if (SkMask::kBW_Format == fMaskFormat) { rb = (rb + 7) >> 3; + } else if (SkMask::kARGB32_Format == fMaskFormat) { + rb <<= 2; } else { rb = SkAlign4(rb); } return rb; } - + bool isJustAdvance() const { return MASK_FORMAT_JUST_ADVANCE == fMaskFormat; } - + bool isFullMetrics() const { return MASK_FORMAT_JUST_ADVANCE != fMaskFormat; } - + uint16_t getGlyphID() const { return ID2Code(fID); } @@ -70,27 +86,27 @@ struct SkGlyph { SkASSERT(code >= baseGlyphCount); return code - baseGlyphCount; } - + unsigned getSubX() const { return ID2SubX(fID); } - + SkFixed getSubXFixed() const { return SubToFixed(ID2SubX(fID)); } - + SkFixed getSubYFixed() const { return SubToFixed(ID2SubY(fID)); } - + size_t computeImageSize() const; - + /** Call this to set all of the metrics fields to 0 (e.g. if the scaler encounters an error measuring a glyph). Note: this does not alter the fImage, fPath, fID, fMaskFormat fields. */ void zeroMetrics(); - + enum { kSubBits = 2, kSubMask = ((1 << kSubBits) - 1), @@ -104,28 +120,28 @@ struct SkGlyph { static unsigned ID2Code(uint32_t id) { return id & kCodeMask; } - + static unsigned ID2SubX(uint32_t id) { return id >> (kSubShift + kSubShiftX); } - + static unsigned ID2SubY(uint32_t id) { return (id >> (kSubShift + kSubShiftY)) & kSubMask; } - + static unsigned FixedToSub(SkFixed n) { return (n >> (16 - kSubBits)) & kSubMask; } - + static SkFixed SubToFixed(unsigned sub) { SkASSERT(sub <= kSubMask); return sub << (16 - kSubBits); } - + static uint32_t MakeID(unsigned code) { return code; } - + static uint32_t MakeID(unsigned code, SkFixed x, SkFixed y) { SkASSERT(code <= kCodeMask); x = FixedToSub(x); @@ -134,7 +150,7 @@ struct SkGlyph { (y << (kSubShift + kSubShiftY)) | code; } - + void toMask(SkMask* mask) const; /** Given a glyph which is has a mask format of LCD or VerticalLCD, take @@ -156,6 +172,8 @@ public: kHintingBit2_Flag = 0x20, kEmbeddedBitmapText_Flag = 0x40, kEmbolden_Flag = 0x80, + kSubpixelPositioning_Flag = 0x100, + kAutohinting_Flag = 0x200, }; private: enum { @@ -167,10 +185,9 @@ public: SkScalar fTextSize, fPreScaleX, fPreSkewX; SkScalar fPost2x2[2][2]; SkScalar fFrameWidth, fMiterLimit; - bool fSubpixelPositioning; uint8_t fMaskFormat; uint8_t fStrokeJoin; - uint8_t fFlags; + uint16_t fFlags; // Warning: when adding members note that the size of this structure // must be a multiple of 4. SkDescriptor requires that its arguments be // multiples of four and this structure is put in an SkDescriptor in |