diff options
author | herb <herb@google.com> | 2015-02-24 05:12:05 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-24 05:12:05 -0800 |
commit | f8d24e2c0c7b44b7ccf20e40890514db4cde7b15 (patch) | |
tree | 01187c9c660dbc97ca5a3281b4d64a4a056b86b7 /src/core | |
parent | 73953e7d00f0a75a98e985ceed88059d35945327 (diff) |
BUG=skia:
(mtklein from here on)
No public API changes.
TBR=reed@google.com
Review URL: https://codereview.chromium.org/939123002
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkDraw.cpp | 2 | ||||
-rw-r--r-- | src/core/SkGlyph.h | 58 | ||||
-rwxr-xr-x | src/core/SkGlyphCache.cpp | 2 | ||||
-rw-r--r-- | src/core/SkScalerContext.cpp | 2 | ||||
-rw-r--r-- | src/core/SkScalerContext.h | 2 |
5 files changed, 41 insertions, 25 deletions
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp index f40c1bbcb0..b6738e2429 100644 --- a/src/core/SkDraw.cpp +++ b/src/core/SkDraw.cpp @@ -1534,7 +1534,7 @@ SkDraw1Glyph::Proc SkDraw1Glyph::init(const SkDraw* draw, SkBlitter* blitter, Sk fPaint = &pnt; if (cache->isSubpixel()) { - fHalfSampleX = fHalfSampleY = (SK_FixedHalf >> SkGlyph::kSubBits); + fHalfSampleX = fHalfSampleY = SkGlyph::kSubpixelRound; } else { fHalfSampleX = fHalfSampleY = SK_FixedHalf; } diff --git a/src/core/SkGlyph.h b/src/core/SkGlyph.h index 9abefa84c7..4a9acbfe75 100644 --- a/src/core/SkGlyph.h +++ b/src/core/SkGlyph.h @@ -13,6 +13,7 @@ #include "SkMask.h" class SkPath; +class SkGlyphCache; // needs to be != to any valid SkMask::Format #define MASK_FORMAT_UNKNOWN (0xFF) @@ -20,12 +21,23 @@ class SkPath; #define kMaxGlyphWidth (1<<13) -struct SkGlyph { +class SkGlyph { + enum { + kSubBits = 2, + kSubMask = ((1 << kSubBits) - 1), + kSubShift = 24, // must be large enough for glyphs and unichars + kCodeMask = ((1 << kSubShift) - 1), + // relative offsets for X and Y subpixel bits + kSubShiftX = kSubBits, + kSubShiftY = 0 + }; + + public: + static const SkFixed kSubpixelRound = SK_FixedHalf >> SkGlyph::kSubBits; void* fImage; SkPath* fPath; SkFixed fAdvanceX, fAdvanceY; - uint32_t fID; uint16_t fWidth, fHeight; int16_t fTop, fLeft; @@ -33,12 +45,12 @@ struct SkGlyph { int8_t fRsbDelta, fLsbDelta; // used by auto-kerning int8_t fForceBW; - void init(uint32_t id) { - fID = id; - fImage = NULL; - fPath = NULL; - fMaskFormat = MASK_FORMAT_UNKNOWN; - fForceBW = 0; + void initWithGlyphID(uint32_t glyph_id) { + this->initCommon(MakeID(glyph_id)); + } + + void initGlyphIdFrom(const SkGlyph& glyph) { + this->initCommon(glyph.fID); } /** @@ -94,18 +106,22 @@ struct SkGlyph { */ void zeroMetrics(); - enum { - kSubBits = 2, - kSubMask = ((1 << kSubBits) - 1), - kSubShift = 24, // must be large enough for glyphs and unichars - kCodeMask = ((1 << kSubShift) - 1), - // relative offsets for X and Y subpixel bits - kSubShiftX = kSubBits, - kSubShiftY = 0 - }; + void toMask(SkMask* mask) const; + + private: + // TODO(herb) remove friend statement after SkGlyphCache cleanup. + friend class SkGlyphCache; + + void initCommon(uint32_t id) { + fID = id; + fImage = NULL; + fPath = NULL; + fMaskFormat = MASK_FORMAT_UNKNOWN; + fForceBW = 0; + } static unsigned ID2Code(uint32_t id) { - return id & kCodeMask; + return (id & kCodeMask); } static unsigned ID2SubX(uint32_t id) { @@ -134,11 +150,11 @@ struct SkGlyph { x = FixedToSub(x); y = FixedToSub(y); return (x << (kSubShift + kSubShiftX)) | - (y << (kSubShift + kSubShiftY)) | - code; + (y << (kSubShift + kSubShiftY)) | + code; } - void toMask(SkMask* mask) const; + uint32_t fID; }; #endif diff --git a/src/core/SkGlyphCache.cpp b/src/core/SkGlyphCache.cpp index 57c54bfc1e..f0fd859385 100755 --- a/src/core/SkGlyphCache.cpp +++ b/src/core/SkGlyphCache.cpp @@ -314,7 +314,7 @@ SkGlyph* SkGlyphCache::lookupMetrics(uint32_t id, MetricsType mtype) { glyph = (SkGlyph*)fGlyphAlloc.alloc(sizeof(SkGlyph), SkChunkAlloc::kThrow_AllocFailType); - glyph->init(id); + glyph->initCommon(id); *fGlyphArray.insert(hi) = glyph; if (kJustAdvance_MetricsType == mtype) { diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp index a3ff95ca0a..e3b5d80b3d 100644 --- a/src/core/SkScalerContext.cpp +++ b/src/core/SkScalerContext.cpp @@ -482,7 +482,7 @@ void SkScalerContext::getImage(const SkGlyph& origGlyph) { SkMask::kARGB32_Format != origGlyph.fMaskFormat); if (fMaskFilter) { // restore the prefilter bounds - tmpGlyph.init(origGlyph.fID); + tmpGlyph.initGlyphIdFrom(origGlyph); // need the original bounds, sans our maskfilter SkMaskFilter* mf = fMaskFilter; diff --git a/src/core/SkScalerContext.h b/src/core/SkScalerContext.h index 4677635d7c..02b3a76825 100644 --- a/src/core/SkScalerContext.h +++ b/src/core/SkScalerContext.h @@ -14,7 +14,7 @@ #include "SkPaint.h" #include "SkTypeface.h" -struct SkGlyph; +class SkGlyph; class SkDescriptor; class SkMaskFilter; class SkPathEffect; |