aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkRemoteGlyphCache.cpp
diff options
context:
space:
mode:
authorGravatar Herb Derby <herb@google.com>2018-06-21 15:15:50 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-21 19:49:27 +0000
commit5c0c7983bb6371c493561dbc97671e4997f822d5 (patch)
treee8bf690e86f2fb4ed0c55bbf5db929dee2a947ab /src/core/SkRemoteGlyphCache.cpp
parentc113e9e23d76a463743d6e5372284fb84b58fd8c (diff)
Use local strike caches to avoid flaky test behavior
The remote glyph cache tests assume that the strike cache will not change during a test. This is not true because other test also mutate the strike cache. This is causing flaky tests. BUG=skia:8091 Change-Id: I397d411f9412006715f6860941dfb05ad54ae1b6 Reviewed-on: https://skia-review.googlesource.com/136741 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Mike Klein <mtklein@google.com> Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'src/core/SkRemoteGlyphCache.cpp')
-rw-r--r--src/core/SkRemoteGlyphCache.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/core/SkRemoteGlyphCache.cpp b/src/core/SkRemoteGlyphCache.cpp
index fa4767069f..774a1eb77c 100644
--- a/src/core/SkRemoteGlyphCache.cpp
+++ b/src/core/SkRemoteGlyphCache.cpp
@@ -734,8 +734,11 @@ private:
sk_sp<DiscardableHandleManager> fManager;
};
-SkStrikeClient::SkStrikeClient(sk_sp<DiscardableHandleManager> discardableManager, bool isLogging)
+SkStrikeClient::SkStrikeClient(sk_sp<DiscardableHandleManager> discardableManager,
+ bool isLogging,
+ SkStrikeCache* strikeCache)
: fDiscardableHandleManager(std::move(discardableManager))
+ , fStrikeCache{strikeCache ? strikeCache : SkStrikeCache::GlobalStrikeCache()}
, fIsLogging{isLogging} {}
SkStrikeClient::~SkStrikeClient() = default;
@@ -792,18 +795,19 @@ bool SkStrikeClient::readStrikeData(const volatile void* memory, size_t memorySi
SkAutoDescriptor ad;
auto* client_desc = auto_descriptor_from_desc(sourceAd.getDesc(), tf->uniqueID(), &ad);
- auto strike = SkStrikeCache::FindStrikeExclusive(*client_desc);
+ auto strike = fStrikeCache->findStrikeExclusive(*client_desc);
if (strike == nullptr) {
// Note that we don't need to deserialize the effects since we won't be generating any
// glyphs here anyway, and the desc is still correct since it includes the serialized
// effects.
SkScalerContextEffects effects;
auto scaler = SkStrikeCache::CreateScalerContext(*client_desc, effects, *tf);
- strike = SkStrikeCache::CreateStrikeExclusive(
+ strike = fStrikeCache->createStrikeExclusive(
*client_desc, std::move(scaler), &fontMetrics,
skstd::make_unique<DiscardableStrikePinner>(spec.discardableHandleId,
fDiscardableHandleManager));
- static_cast<SkScalerContextProxy*>(strike->getScalerContext())->initCache(strike.get());
+ auto proxyContext = static_cast<SkScalerContextProxy*>(strike->getScalerContext());
+ proxyContext->initCache(strike.get(), fStrikeCache);
}
size_t glyphImagesCount = 0u;
@@ -865,7 +869,7 @@ sk_sp<SkTypeface> SkStrikeClient::deserializeTypeface(const void* buf, size_t le
WireTypeface wire;
if (len != sizeof(wire)) return nullptr;
memcpy(&wire, buf, sizeof(wire));
- return addTypeface(wire);
+ return this->addTypeface(wire);
}
sk_sp<SkTypeface> SkStrikeClient::addTypeface(const WireTypeface& wire) {