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:
parent
30cf62bf48
commit
37e21f6910
@ -30,18 +30,19 @@ struct GrGlyph {
|
||||
|
||||
typedef uint32_t PackedID;
|
||||
|
||||
GrDrawOpAtlas::AtlasID fID;
|
||||
PackedID fPackedID;
|
||||
GrMaskFormat fMaskFormat;
|
||||
GrIRect16 fBounds;
|
||||
SkIPoint16 fAtlasLocation;
|
||||
GrDrawOpAtlas::AtlasID fID{GrDrawOpAtlas::kInvalidAtlasID};
|
||||
PackedID fPackedID;
|
||||
GrMaskFormat fMaskFormat;
|
||||
GrIRect16 fBounds;
|
||||
SkIPoint16 fAtlasLocation{0, 0};
|
||||
MaskStyle fMaskStyle;
|
||||
|
||||
void init(GrGlyph::PackedID packed, const SkIRect& bounds, GrMaskFormat format) {
|
||||
fID = GrDrawOpAtlas::kInvalidAtlasID;
|
||||
void init(
|
||||
GrGlyph::PackedID packed, const SkIRect& bounds, GrMaskFormat format, MaskStyle style) {
|
||||
fPackedID = packed;
|
||||
fBounds.set(bounds);
|
||||
fMaskFormat = format;
|
||||
fAtlasLocation.set(0, 0);
|
||||
fMaskStyle = style;
|
||||
}
|
||||
|
||||
int width() const { return fBounds.width(); }
|
||||
@ -49,6 +50,7 @@ struct GrGlyph {
|
||||
bool isEmpty() const { return fBounds.isEmpty(); }
|
||||
uint16_t glyphID() const { return UnpackID(fPackedID); }
|
||||
uint32_t pageIndex() const { return GrDrawOpAtlas::GetPageIndexFromID(fID); }
|
||||
MaskStyle maskStyle() const { return fMaskStyle; }
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -72,10 +74,6 @@ struct GrGlyph {
|
||||
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) {
|
||||
return (uint16_t)packed;
|
||||
}
|
||||
|
@ -200,7 +200,10 @@ GrGlyph* GrTextStrike::generateGlyph(const SkGlyph& skGlyph, GrGlyph::PackedID p
|
||||
GrMaskFormat format = get_packed_glyph_mask_format(skGlyph);
|
||||
|
||||
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);
|
||||
return glyph;
|
||||
}
|
||||
@ -237,7 +240,7 @@ GrDrawOpAtlas::ErrorCode GrTextStrike::addGlyphToAtlas(
|
||||
int rowBytes = width * 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;
|
||||
if (addPad) {
|
||||
width += 2;
|
||||
|
Loading…
Reference in New Issue
Block a user