aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/text/GrGlyphCache.cpp
diff options
context:
space:
mode:
authorGravatar Jim Van Verth <jvanverth@google.com>2018-03-05 14:40:36 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-05 21:22:55 +0000
commitcf838c7450bc5bca649024a2698e630be8970f85 (patch)
tree686fb9d8afc3371018ca0e45886f88822b0edcf6 /src/gpu/text/GrGlyphCache.cpp
parent974aa8eaba6ca7df70ef498ce6e72a80390bfa00 (diff)
Add bilerp support to scaled emojis
Bug: skia:7562 Change-Id: Ibdf8e71050e909de87ca2beb3fb2b57327011364 Reviewed-on: https://skia-review.googlesource.com/111820 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'src/gpu/text/GrGlyphCache.cpp')
-rw-r--r--src/gpu/text/GrGlyphCache.cpp34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/gpu/text/GrGlyphCache.cpp b/src/gpu/text/GrGlyphCache.cpp
index 7d899076b2..2372af815c 100644
--- a/src/gpu/text/GrGlyphCache.cpp
+++ b/src/gpu/text/GrGlyphCache.cpp
@@ -298,35 +298,57 @@ bool GrTextStrike::addGlyphToAtlas(GrResourceProvider* resourceProvider,
GrAtlasManager* fullAtlasManager,
GrGlyph* glyph,
SkGlyphCache* cache,
- GrMaskFormat expectedMaskFormat) {
+ GrMaskFormat expectedMaskFormat,
+ bool isScaledGlyph) {
SkASSERT(glyph);
SkASSERT(cache);
SkASSERT(fCache.find(glyph->fPackedID));
int bytesPerPixel = GrMaskFormatBytesPerPixel(expectedMaskFormat);
+ int width = glyph->width();
+ int height = glyph->height();
+ int rowBytes = width * bytesPerPixel;
size_t size = glyph->fBounds.area() * bytesPerPixel;
+ bool isSDFGlyph = GrGlyph::kDistance_MaskStyle == GrGlyph::UnpackMaskStyle(glyph->fPackedID);
+ bool addPad = isScaledGlyph && !isSDFGlyph;
+ if (addPad) {
+ width += 2;
+ rowBytes += 2*bytesPerPixel;
+ size += 2 * rowBytes;
+ height += 2;
+ size += 2 * (height + 2) * bytesPerPixel;
+ }
SkAutoSMalloc<1024> storage(size);
const SkGlyph& skGlyph = GrToSkGlyph(cache, glyph->fPackedID);
- if (GrGlyph::kDistance_MaskStyle == GrGlyph::UnpackMaskStyle(glyph->fPackedID)) {
- if (!get_packed_glyph_df_image(cache, skGlyph, glyph->width(), glyph->height(),
+ if (isSDFGlyph) {
+ if (!get_packed_glyph_df_image(cache, skGlyph, width, height,
storage.get())) {
return false;
}
} else {
+ void* dataPtr = storage.get();
+ if (addPad) {
+ sk_bzero(dataPtr, size);
+ dataPtr = (char*)(dataPtr) + rowBytes + bytesPerPixel;
+ }
if (!get_packed_glyph_image(cache, skGlyph, glyph->width(), glyph->height(),
- glyph->width() * bytesPerPixel, expectedMaskFormat,
- storage.get())) {
+ rowBytes, expectedMaskFormat,
+ dataPtr)) {
return false;
}
}
bool success = fullAtlasManager->addToAtlas(resourceProvider, glyphCache, this,
&glyph->fID, target, expectedMaskFormat,
- glyph->width(), glyph->height(),
+ width, height,
storage.get(), &glyph->fAtlasLocation);
if (success) {
+ if (addPad) {
+ glyph->fAtlasLocation.fX += 1;
+ glyph->fAtlasLocation.fY += 1;
+ }
SkASSERT(GrDrawOpAtlas::kInvalidAtlasID != glyph->fID);
fAtlasedGlyphs++;
}