Reland: Only send the RemoteStrikes that have pending glyphs.
This reverts commit 94c6647556
. The issue
was that we were not clearing the set of locked strikes, if there is no
data to send. As a result the client was assuming strikes are locked
even after they were purged on the service side.
R=herb@google.com
Bug:999682
Change-Id: I767dd0cab81e085123058201dab042628ac4e241
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/239343
Auto-Submit: Khushal Sagar <khushalsagar@chromium.org>
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Herb Derby <herb@google.com>
This commit is contained in:
parent
f0c681e459
commit
498a9b2449
@ -221,14 +221,16 @@ public:
|
||||
|
||||
void onAboutToExitScope() override {}
|
||||
|
||||
private:
|
||||
bool hasPendingGlyphs() const {
|
||||
return !fPendingGlyphImages.empty() || !fPendingGlyphPaths.empty();
|
||||
}
|
||||
|
||||
void resetScalerContext();
|
||||
|
||||
private:
|
||||
void writeGlyphPath(const SkPackedGlyphID& glyphID, Serializer* serializer) const;
|
||||
|
||||
void ensureScalerContext();
|
||||
void resetScalerContext();
|
||||
|
||||
// The set of glyphs cached on the remote client.
|
||||
SkTHashSet<SkPackedGlyphID> fCachedGlyphImages;
|
||||
@ -425,7 +427,17 @@ sk_sp<SkData> SkStrikeServer::serializeTypeface(SkTypeface* tf) {
|
||||
}
|
||||
|
||||
void SkStrikeServer::writeStrikeData(std::vector<uint8_t>* memory) {
|
||||
if (fRemoteStrikesToSend.empty() && fTypefacesToSend.empty()) {
|
||||
size_t strikesToSend = 0;
|
||||
fRemoteStrikesToSend.foreach ([&strikesToSend](RemoteStrike* strike) {
|
||||
if (strike->hasPendingGlyphs()) {
|
||||
strikesToSend++;
|
||||
} else {
|
||||
strike->resetScalerContext();
|
||||
}
|
||||
});
|
||||
|
||||
if (strikesToSend == 0 && fTypefacesToSend.empty()) {
|
||||
fRemoteStrikesToSend.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -436,11 +448,14 @@ void SkStrikeServer::writeStrikeData(std::vector<uint8_t>* memory) {
|
||||
}
|
||||
fTypefacesToSend.clear();
|
||||
|
||||
serializer.emplace<uint64_t>(SkTo<uint64_t>(fRemoteStrikesToSend.count()));
|
||||
fRemoteStrikesToSend.foreach(
|
||||
serializer.emplace<uint64_t>(SkTo<uint64_t>(strikesToSend));
|
||||
fRemoteStrikesToSend.foreach (
|
||||
#ifdef SK_DEBUG
|
||||
[&serializer, this](RemoteStrike* strike) {
|
||||
strike->writePendingGlyphs(&serializer);
|
||||
if (strike->hasPendingGlyphs()) {
|
||||
strike->writePendingGlyphs(&serializer);
|
||||
strike->resetScalerContext();
|
||||
}
|
||||
auto it = fDescToRemoteStrike.find(&strike->getDescriptor());
|
||||
SkASSERT(it != fDescToRemoteStrike.end());
|
||||
SkASSERT(it->second.get() == strike);
|
||||
@ -448,7 +463,10 @@ void SkStrikeServer::writeStrikeData(std::vector<uint8_t>* memory) {
|
||||
|
||||
#else
|
||||
[&serializer](RemoteStrike* strike) {
|
||||
strike->writePendingGlyphs(&serializer);
|
||||
if (strike->hasPendingGlyphs()) {
|
||||
strike->writePendingGlyphs(&serializer);
|
||||
strike->resetScalerContext();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
);
|
||||
@ -569,12 +587,8 @@ static void writeGlyph(SkGlyph* glyph, Serializer* serializer) {
|
||||
}
|
||||
|
||||
void SkStrikeServer::RemoteStrike::writePendingGlyphs(Serializer* serializer) {
|
||||
// TODO(khushalsagar): Write a strike only if it has any pending glyphs.
|
||||
serializer->emplace<bool>(this->hasPendingGlyphs());
|
||||
if (!this->hasPendingGlyphs()) {
|
||||
this->resetScalerContext();
|
||||
return;
|
||||
}
|
||||
SkASSERT(this->hasPendingGlyphs());
|
||||
|
||||
// Write the desc.
|
||||
serializer->emplace<StrikeSpec>(fContext->getTypeface()->uniqueID(), fDiscardableHandleId);
|
||||
@ -618,7 +632,6 @@ void SkStrikeServer::RemoteStrike::writePendingGlyphs(Serializer* serializer) {
|
||||
writeGlyphPath(glyphID, serializer);
|
||||
}
|
||||
fPendingGlyphPaths.clear();
|
||||
this->resetScalerContext();
|
||||
}
|
||||
|
||||
void SkStrikeServer::RemoteStrike::ensureScalerContext() {
|
||||
|
@ -314,6 +314,13 @@ DEF_TEST(SkRemoteGlyphCache_StrikeDeletionServer, reporter) {
|
||||
// handles.
|
||||
std::vector<uint8_t> fontData;
|
||||
server.writeStrikeData(&fontData);
|
||||
|
||||
// Another analysis pass, to ensure that deleting handles after a complete cache hit still
|
||||
// works. This is a regression test for crbug.com/999682.
|
||||
cache_diff_canvas.drawTextBlob(serverBlob.get(), 0, 0, paint);
|
||||
server.writeStrikeData(&fontData);
|
||||
REPORTER_ASSERT(reporter, discardableManager->handleCount() == 1u);
|
||||
|
||||
discardableManager->unlockAndDeleteAll();
|
||||
cache_diff_canvas.drawTextBlob(serverBlob.get(), 0, 0, paint);
|
||||
REPORTER_ASSERT(reporter, discardableManager->handleCount() == 2u);
|
||||
|
Loading…
Reference in New Issue
Block a user