Use shifts for all fields in SkPackedGlyphID

This should allow the bit field positions to be moved
around in the SkPackedGlyphID.

Change-Id: I85390f594a017b9df779f0a12e1f24c4d9e077dd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/251761
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
This commit is contained in:
Herb Derby 2019-10-30 11:23:27 -04:00 committed by Skia Commit-Bot
parent 8a64a44244
commit 7820da3db5

View File

@ -48,7 +48,7 @@ struct SkPackedGlyphID {
};
constexpr explicit SkPackedGlyphID(SkGlyphID glyphID)
: fID{glyphID} { }
: fID{(uint32_t)glyphID << kGlyphID} { }
constexpr SkPackedGlyphID(SkGlyphID glyphID, SkFixed x, SkFixed y)
: fID {PackIDXY(glyphID, x, y)} {
@ -71,7 +71,7 @@ struct SkPackedGlyphID {
}
SkGlyphID glyphID() const {
return fID & kGlyphIDMask;
return (fID >> kGlyphID) & kGlyphIDMask;
}
uint32_t value() const {
@ -97,10 +97,15 @@ struct SkPackedGlyphID {
}
private:
static constexpr uint32_t PackIDSubXSubY(SkGlyphID glyphID, uint32_t x, uint32_t y) {
SkASSERT(x < 4);
SkASSERT(y < 4);
return (x << kSubPixelX) | (y << kSubPixelY) | (glyphID << kGlyphID);
}
static constexpr uint32_t PackIDXY(SkGlyphID glyphID, SkFixed x, SkFixed y) {
return (FixedToSub(x) << kSubPixelX)
| (FixedToSub(y) << kSubPixelY)
| glyphID;
return PackIDSubXSubY(glyphID, FixedToSub(x), FixedToSub(y));
}
static constexpr uint32_t FixedToSub(SkFixed n) {