diff options
author | herb <herb@google.com> | 2015-02-09 06:38:28 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-09 06:38:28 -0800 |
commit | b4c29ac173e6f8844327338687248b98bc94132d (patch) | |
tree | 8f52c3ac31b3caacea0447801f3c1e53819b5519 /src/core/SkGlyph.h | |
parent | 4e534d05b7b062966b61d98662712a3a8657495e (diff) |
Make the glyph array entries inline.
BUG=skia:
Committed: https://skia.googlesource.com/skia/+/4c08f16b252a55e438a61f26e5581394ed177da1
Review URL: https://codereview.chromium.org/885903002
Diffstat (limited to 'src/core/SkGlyph.h')
-rw-r--r-- | src/core/SkGlyph.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/core/SkGlyph.h b/src/core/SkGlyph.h index 9abefa84c7..4f9c5bf4cc 100644 --- a/src/core/SkGlyph.h +++ b/src/core/SkGlyph.h @@ -104,8 +104,10 @@ struct SkGlyph { kSubShiftY = 0 }; + // The code is increased by one in MakeID. Adjust back. This allows the zero + // id to be the invalid id. static unsigned ID2Code(uint32_t id) { - return id & kCodeMask; + return (id & kCodeMask) - 1; } static unsigned ID2SubX(uint32_t id) { @@ -125,17 +127,21 @@ struct SkGlyph { return sub << (16 - kSubBits); } + // This and the MakeID below must not return an id of zero. Zero is used as + // the invalid id. static uint32_t MakeID(unsigned code) { - return code; + SkASSERT(code + 1 <= kCodeMask); + return code + 1; } + // See comment for MakeID above. static uint32_t MakeID(unsigned code, SkFixed x, SkFixed y) { - SkASSERT(code <= kCodeMask); + SkASSERT(code + 1 <= kCodeMask); x = FixedToSub(x); y = FixedToSub(y); return (x << (kSubShift + kSubShiftX)) | (y << (kSubShift + kSubShiftY)) | - code; + (code + 1); } void toMask(SkMask* mask) const; |