diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkRemoteGlyphCache.cpp | 10 | ||||
-rw-r--r-- | src/core/SkRemoteGlyphCache.h | 3 | ||||
-rw-r--r-- | src/core/SkTypeface_remote.cpp | 25 | ||||
-rw-r--r-- | src/core/SkTypeface_remote.h | 17 |
4 files changed, 39 insertions, 16 deletions
diff --git a/src/core/SkRemoteGlyphCache.cpp b/src/core/SkRemoteGlyphCache.cpp index 6e0c61e01f..922014b173 100644 --- a/src/core/SkRemoteGlyphCache.cpp +++ b/src/core/SkRemoteGlyphCache.cpp @@ -651,8 +651,9 @@ private: sk_sp<DiscardableHandleManager> fManager; }; -SkStrikeClient::SkStrikeClient(sk_sp<DiscardableHandleManager> discardableManager) - : fDiscardableHandleManager(std::move(discardableManager)) {} +SkStrikeClient::SkStrikeClient(sk_sp<DiscardableHandleManager> discardableManager, bool isLogging) + : fDiscardableHandleManager(std::move(discardableManager)) + , fIsLogging{isLogging} {} SkStrikeClient::~SkStrikeClient() = default; @@ -780,8 +781,9 @@ sk_sp<SkTypeface> SkStrikeClient::addTypeface(const WireTypeface& wire) { auto* typeface = fRemoteFontIdToTypeface.find(wire.typefaceID); if (typeface) return *typeface; - auto newTypeface = sk_make_sp<SkTypefaceProxy>(wire.typefaceID, wire.glyphCount, wire.style, - wire.isFixed, fDiscardableHandleManager); + auto newTypeface = sk_make_sp<SkTypefaceProxy>( + wire.typefaceID, wire.glyphCount, wire.style, wire.isFixed, + fDiscardableHandleManager, fIsLogging); fRemoteFontIdToTypeface.set(wire.typefaceID, newTypeface); return std::move(newTypeface); } diff --git a/src/core/SkRemoteGlyphCache.h b/src/core/SkRemoteGlyphCache.h index 4d22a197a7..4fa4e0afc1 100644 --- a/src/core/SkRemoteGlyphCache.h +++ b/src/core/SkRemoteGlyphCache.h @@ -209,7 +209,7 @@ public: virtual void NotifyCacheMiss(CacheMissType) {} }; - SkStrikeClient(sk_sp<DiscardableHandleManager>); + SkStrikeClient(sk_sp<DiscardableHandleManager>, bool isLogging = true); ~SkStrikeClient(); // Deserializes the typeface previously serialized using the SkStrikeServer. Returns null if the @@ -229,6 +229,7 @@ private: SkTHashMap<SkFontID, sk_sp<SkTypeface>> fRemoteFontIdToTypeface; sk_sp<DiscardableHandleManager> fDiscardableHandleManager; + const bool fIsLogging; }; #endif // SkRemoteGlyphCache_DEFINED diff --git a/src/core/SkTypeface_remote.cpp b/src/core/SkTypeface_remote.cpp index 479ad16b7b..b5871ded25 100644 --- a/src/core/SkTypeface_remote.cpp +++ b/src/core/SkTypeface_remote.cpp @@ -15,7 +15,8 @@ SkScalerContextProxy::SkScalerContextProxy(sk_sp<SkTypeface> tf, const SkScalerContextEffects& effects, const SkDescriptor* desc, sk_sp<SkStrikeClient::DiscardableHandleManager> manager) - : SkScalerContext{std::move(tf), effects, desc}, fDiscardableManager{std::move(manager)} {} + : SkScalerContext{std::move(tf), effects, desc} + , fDiscardableManager{std::move(manager)} {} unsigned SkScalerContextProxy::generateGlyphCount() { SK_ABORT("Should never be called."); @@ -33,7 +34,9 @@ void SkScalerContextProxy::generateAdvance(SkGlyph* glyph) { void SkScalerContextProxy::generateMetrics(SkGlyph* glyph) { TRACE_EVENT1("skia", "generateMetrics", "rec", TRACE_STR_COPY(this->getRec().dump().c_str())); - //SkDebugf("GlyphCacheMiss generateMetrics: %s\n", this->getRec().dump().c_str()); + if (this->getProxyTypeface()->isLogging()) { + SkDebugf("GlyphCacheMiss generateMetrics: %s\n", this->getRec().dump().c_str()); + } fDiscardableManager->NotifyCacheMiss(SkStrikeClient::CacheMissType::kGlyphMetrics); glyph->zeroMetrics(); @@ -41,14 +44,18 @@ void SkScalerContextProxy::generateMetrics(SkGlyph* glyph) { void SkScalerContextProxy::generateImage(const SkGlyph& glyph) { TRACE_EVENT1("skia", "generateImage", "rec", TRACE_STR_COPY(this->getRec().dump().c_str())); - //SkDebugf("GlyphCacheMiss generateImage: %s\n", this->getRec().dump().c_str()); + if (this->getProxyTypeface()->isLogging()) { + SkDebugf("GlyphCacheMiss generateImage: %s\n", this->getRec().dump().c_str()); + } fDiscardableManager->NotifyCacheMiss(SkStrikeClient::CacheMissType::kGlyphImage); } bool SkScalerContextProxy::generatePath(SkGlyphID glyphID, SkPath* path) { TRACE_EVENT1("skia", "generatePath", "rec", TRACE_STR_COPY(this->getRec().dump().c_str())); - //SkDebugf("GlyphCacheMiss generatePath: %s\n", this->getRec().dump().c_str()); + if (this->getProxyTypeface()->isLogging()) { + SkDebugf("GlyphCacheMiss generatePath: %s\n", this->getRec().dump().c_str()); + } fDiscardableManager->NotifyCacheMiss(SkStrikeClient::CacheMissType::kGlyphPath); return false; @@ -57,9 +64,15 @@ bool SkScalerContextProxy::generatePath(SkGlyphID glyphID, SkPath* path) { void SkScalerContextProxy::generateFontMetrics(SkPaint::FontMetrics* metrics) { TRACE_EVENT1( "skia", "generateFontMetrics", "rec", TRACE_STR_COPY(this->getRec().dump().c_str())); - //SkDebugf("GlyphCacheMiss generateFontMetrics: %s\n", this->getRec().dump().c_str()); - //SkDEBUGCODE(SkStrikeCache::Dump()); + if (this->getProxyTypeface()->isLogging()) { + SkDebugf("GlyphCacheMiss generateFontMetrics: %s\n", this->getRec().dump().c_str()); + SkDEBUGCODE(SkStrikeCache::Dump()); + } fDiscardableManager->NotifyCacheMiss(SkStrikeClient::CacheMissType::kFontMetrics); sk_bzero(metrics, sizeof(*metrics)); } + +SkTypefaceProxy* SkScalerContextProxy::getProxyTypeface() const { + return (SkTypefaceProxy*)this->getTypeface(); +}
\ No newline at end of file diff --git a/src/core/SkTypeface_remote.h b/src/core/SkTypeface_remote.h index ff5bc66775..1e079eff49 100644 --- a/src/core/SkTypeface_remote.h +++ b/src/core/SkTypeface_remote.h @@ -17,6 +17,8 @@ #include "SkScalerContext.h" #include "SkTypeface.h" +class SkTypefaceProxy; + class SkScalerContextProxy : public SkScalerContext { public: SkScalerContextProxy(sk_sp<SkTypeface> tf, @@ -32,6 +34,7 @@ protected: void generateImage(const SkGlyph& glyph) override; bool generatePath(SkGlyphID glyphID, SkPath* path) override; void generateFontMetrics(SkPaint::FontMetrics* metrics) override; + SkTypefaceProxy* getProxyTypeface() const; private: // Copied from SkGlyphCache @@ -40,7 +43,7 @@ private: static constexpr size_t kMinGlyphImageSize = 16 /* height */ * 8 /* width */; static constexpr size_t kMinAllocAmount = kMinGlyphImageSize * kMinGlyphCount; - SkArenaAlloc fAlloc{kMinAllocAmount}; + SkArenaAlloc fAlloc{kMinAllocAmount}; sk_sp<SkStrikeClient::DiscardableHandleManager> fDiscardableManager; typedef SkScalerContext INHERITED; }; @@ -51,13 +54,16 @@ public: int glyphCount, const SkFontStyle& style, bool isFixed, - sk_sp<SkStrikeClient::DiscardableHandleManager> manager) + sk_sp<SkStrikeClient::DiscardableHandleManager> manager, + bool isLogging = true) : INHERITED{style, false} , fFontId{fontId} , fGlyphCount{glyphCount} + , fIsLogging{isLogging} , fDiscardableManager{std::move(manager)} {} SkFontID remoteTypefaceID() const {return fFontId;} int glyphCount() const {return fGlyphCount;} + bool isLogging() const {return fIsLogging;} protected: int onGetUPEM() const override { SK_ABORT("Should never be called."); return 0; } @@ -125,11 +131,12 @@ protected: } private: - const SkFontID fFontId; - const int fGlyphCount; - + const SkFontID fFontId; + const int fGlyphCount; + const bool fIsLogging; sk_sp<SkStrikeClient::DiscardableHandleManager> fDiscardableManager; + typedef SkTypeface INHERITED; }; |