Move the maskStyle into the GrGlyph

Change-Id: I560e909a9d1882ae6777915e165c740b3751e544
Reviewed-on: https://skia-review.googlesource.com/c/179382
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
Herb Derby 2018-12-19 19:56:02 -05:00 committed by Skia Commit-Bot
parent 30cf62bf48
commit 37e21f6910
2 changed files with 15 additions and 14 deletions

View File

@ -30,18 +30,19 @@ struct GrGlyph {
typedef uint32_t PackedID; typedef uint32_t PackedID;
GrDrawOpAtlas::AtlasID fID; GrDrawOpAtlas::AtlasID fID{GrDrawOpAtlas::kInvalidAtlasID};
PackedID fPackedID; PackedID fPackedID;
GrMaskFormat fMaskFormat; GrMaskFormat fMaskFormat;
GrIRect16 fBounds; GrIRect16 fBounds;
SkIPoint16 fAtlasLocation; SkIPoint16 fAtlasLocation{0, 0};
MaskStyle fMaskStyle;
void init(GrGlyph::PackedID packed, const SkIRect& bounds, GrMaskFormat format) { void init(
fID = GrDrawOpAtlas::kInvalidAtlasID; GrGlyph::PackedID packed, const SkIRect& bounds, GrMaskFormat format, MaskStyle style) {
fPackedID = packed; fPackedID = packed;
fBounds.set(bounds); fBounds.set(bounds);
fMaskFormat = format; fMaskFormat = format;
fAtlasLocation.set(0, 0); fMaskStyle = style;
} }
int width() const { return fBounds.width(); } int width() const { return fBounds.width(); }
@ -49,6 +50,7 @@ struct GrGlyph {
bool isEmpty() const { return fBounds.isEmpty(); } bool isEmpty() const { return fBounds.isEmpty(); }
uint16_t glyphID() const { return UnpackID(fPackedID); } uint16_t glyphID() const { return UnpackID(fPackedID); }
uint32_t pageIndex() const { return GrDrawOpAtlas::GetPageIndexFromID(fID); } uint32_t pageIndex() const { return GrDrawOpAtlas::GetPageIndexFromID(fID); }
MaskStyle maskStyle() const { return fMaskStyle; }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -72,10 +74,6 @@ struct GrGlyph {
return ((packed >> 16) & 3) << 14; return ((packed >> 16) & 3) << 14;
} }
static inline MaskStyle UnpackMaskStyle(PackedID packed) {
return ((packed >> 20) & 1) ? kDistance_MaskStyle : kCoverage_MaskStyle;
}
static inline uint16_t UnpackID(PackedID packed) { static inline uint16_t UnpackID(PackedID packed) {
return (uint16_t)packed; return (uint16_t)packed;
} }

View File

@ -200,7 +200,10 @@ GrGlyph* GrTextStrike::generateGlyph(const SkGlyph& skGlyph, GrGlyph::PackedID p
GrMaskFormat format = get_packed_glyph_mask_format(skGlyph); GrMaskFormat format = get_packed_glyph_mask_format(skGlyph);
GrGlyph* glyph = fPool.make<GrGlyph>(); GrGlyph* glyph = fPool.make<GrGlyph>();
glyph->init(packed, bounds, format); GrGlyph::MaskStyle maskStyle = (SkMask::Format)skGlyph.fMaskFormat == SkMask::kSDF_Format
? GrGlyph::MaskStyle::kDistance_MaskStyle
: GrGlyph::MaskStyle::kCoverage_MaskStyle;
glyph->init(packed, bounds, format, maskStyle);
fCache.add(glyph); fCache.add(glyph);
return glyph; return glyph;
} }
@ -237,7 +240,7 @@ GrDrawOpAtlas::ErrorCode GrTextStrike::addGlyphToAtlas(
int rowBytes = width * bytesPerPixel; int rowBytes = width * bytesPerPixel;
size_t size = glyph->fBounds.area() * bytesPerPixel; size_t size = glyph->fBounds.area() * bytesPerPixel;
bool isSDFGlyph = GrGlyph::kDistance_MaskStyle == GrGlyph::UnpackMaskStyle(glyph->fPackedID); bool isSDFGlyph = GrGlyph::kDistance_MaskStyle == glyph->maskStyle();
bool addPad = isScaledGlyph && !isSDFGlyph; bool addPad = isScaledGlyph && !isSDFGlyph;
if (addPad) { if (addPad) {
width += 2; width += 2;