aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkRemoteGlyphCache.cpp
diff options
context:
space:
mode:
authorGravatar Khushal <khushalsagar@chromium.org>2018-06-13 09:44:23 -0700
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-13 17:10:56 +0000
commit4010c792c6bd0378087225ae16b0131bd2c303f2 (patch)
tree0f09301a1539664603f285ad991e677abda04ebc /src/core/SkRemoteGlyphCache.cpp
parentc6530d1e5ecce640e0255d66a01f9db73add7df9 (diff)
fonts: Ignore re-initialization of fallback glyphs from the server.
If the client finds that the server re-initializes a cached path/image, we consider this an error and invalid data. But since we might initialize a glyph using a fallback on the client, and receive the correct version from the server later, this is not longer true. Bug: 829622 Change-Id: I34ab17b54139d89a15179265d4aed4a1fe36fd47 Reviewed-on: https://skia-review.googlesource.com/133566 Commit-Queue: Khusal Sagar <khushalsagar@chromium.org> Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
Diffstat (limited to 'src/core/SkRemoteGlyphCache.cpp')
-rw-r--r--src/core/SkRemoteGlyphCache.cpp31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/core/SkRemoteGlyphCache.cpp b/src/core/SkRemoteGlyphCache.cpp
index 0ccbf2f15e..fa4767069f 100644
--- a/src/core/SkRemoteGlyphCache.cpp
+++ b/src/core/SkRemoteGlyphCache.cpp
@@ -668,6 +668,8 @@ void SkStrikeServer::SkGlyphCacheState::writePendingGlyphs(Serializer* serialize
SkGlyph stationaryGlyph = *glyph;
stationaryGlyph.fImage = serializer->allocate(imageSize, stationaryGlyph.formatAlignment());
fContext->getImage(stationaryGlyph);
+ // TODO: Generating the image can change the mask format, do we need to update it in the
+ // serialized glyph?
}
fPendingGlyphImages.clear();
@@ -811,10 +813,14 @@ bool SkStrikeClient::readStrikeData(const volatile void* memory, size_t memorySi
if (!deserializer.read<SkGlyph>(&glyph)) READ_FAILURE
SkGlyph* allocatedGlyph = strike->getRawGlyphByID(glyph.getPackedID());
- // Don't override the path, if the glyph has one.
- auto* glyphPath = allocatedGlyph->fPathData;
- *allocatedGlyph = glyph;
- allocatedGlyph->fPathData = glyphPath;
+
+ // Update the glyph unless it's already got an image (from fallback),
+ // preserving any path that might be present.
+ if (allocatedGlyph->fImage == nullptr) {
+ auto* glyphPath = allocatedGlyph->fPathData;
+ *allocatedGlyph = glyph;
+ allocatedGlyph->fPathData = glyphPath;
+ }
bool tooLargeForAtlas = false;
#if SK_SUPPORT_GPU
@@ -828,9 +834,8 @@ bool SkStrikeClient::readStrikeData(const volatile void* memory, size_t memorySi
if (imageSize == 0u) continue;
auto* image = deserializer.read(imageSize, allocatedGlyph->formatAlignment());
- if (!image ||
- !strike->initializeImage(image, imageSize, allocatedGlyph))
- READ_FAILURE
+ if (!image) READ_FAILURE
+ strike->initializeImage(image, imageSize, allocatedGlyph);
}
size_t glyphPathsCount = 0u;
@@ -840,10 +845,14 @@ bool SkStrikeClient::readStrikeData(const volatile void* memory, size_t memorySi
if (!deserializer.read<SkGlyph>(&glyph)) READ_FAILURE
SkGlyph* allocatedGlyph = strike->getRawGlyphByID(glyph.getPackedID());
- // Don't override the image, if the glyph has one.
- auto* glyphImage = allocatedGlyph->fImage;
- *allocatedGlyph = glyph;
- allocatedGlyph->fImage = glyphImage;
+
+ // Update the glyph unless it's already got a path (from fallback),
+ // preserving any image that might be present.
+ if (allocatedGlyph->fPathData == nullptr) {
+ auto* glyphImage = allocatedGlyph->fImage;
+ *allocatedGlyph = glyph;
+ allocatedGlyph->fImage = glyphImage;
+ }
if (!read_path(&deserializer, allocatedGlyph, strike.get())) READ_FAILURE
}