Turn off logging for tests

Change-Id: I00bb3059bb92b5c11178022aff8a87918bb3781e
Reviewed-on: https://skia-review.googlesource.com/131640
Reviewed-by: Khushal Sagar <khushalsagar@google.com>
Commit-Queue: Herb Derby <herb@google.com>
diff --git a/src/core/SkRemoteGlyphCache.cpp b/src/core/SkRemoteGlyphCache.cpp
index 6e0c61e..922014b 100644
--- a/src/core/SkRemoteGlyphCache.cpp
+++ b/src/core/SkRemoteGlyphCache.cpp
@@ -651,8 +651,9 @@
     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 @@
     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 4d22a19..4fa4e0a 100644
--- a/src/core/SkRemoteGlyphCache.h
+++ b/src/core/SkRemoteGlyphCache.h
@@ -209,7 +209,7 @@
         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 @@
 
     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 479ad16..b5871de 100644
--- a/src/core/SkTypeface_remote.cpp
+++ b/src/core/SkTypeface_remote.cpp
@@ -15,7 +15,8 @@
                                            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::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::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 @@
 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 ff5bc66..1e079ef 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 @@
     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 @@
     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 @@
                     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 @@
     }
 
 private:
-    const SkFontID        fFontId;
-    const int             fGlyphCount;
-
+    const SkFontID                                  fFontId;
+    const int                                       fGlyphCount;
+    const bool                                      fIsLogging;
     sk_sp<SkStrikeClient::DiscardableHandleManager> fDiscardableManager;
 
+
     typedef SkTypeface INHERITED;
 };
 
diff --git a/tests/SkRemoteGlyphCacheTest.cpp b/tests/SkRemoteGlyphCacheTest.cpp
index 235d4ca..013eead 100644
--- a/tests/SkRemoteGlyphCacheTest.cpp
+++ b/tests/SkRemoteGlyphCacheTest.cpp
@@ -106,7 +106,7 @@
 DEF_TEST(SkRemoteGlyphCache_TypefaceSerialization, reporter) {
     sk_sp<DiscardableManager> discardableManager = sk_make_sp<DiscardableManager>();
     SkStrikeServer server(discardableManager.get());
-    SkStrikeClient client(discardableManager);
+    SkStrikeClient client(discardableManager, false);
 
     auto server_tf = SkTypeface::MakeDefault();
     auto tf_data = server.serializeTypeface(server_tf.get());
@@ -123,7 +123,7 @@
 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_StrikeSerialization, reporter, ctxInfo) {
     sk_sp<DiscardableManager> discardableManager = sk_make_sp<DiscardableManager>();
     SkStrikeServer server(discardableManager.get());
-    SkStrikeClient client(discardableManager);
+    SkStrikeClient client(discardableManager, false);
     const SkPaint paint;
 
     // Server.
@@ -157,7 +157,7 @@
 DEF_TEST(SkRemoteGlyphCache_StrikeLockingServer, reporter) {
     sk_sp<DiscardableManager> discardableManager = sk_make_sp<DiscardableManager>();
     SkStrikeServer server(discardableManager.get());
-    SkStrikeClient client(discardableManager);
+    SkStrikeClient client(discardableManager, false);
 
     auto serverTf = SkTypeface::MakeFromName("monospace", SkFontStyle());
     server.serializeTypeface(serverTf.get());
@@ -191,7 +191,7 @@
 DEF_TEST(SkRemoteGlyphCache_StrikeDeletionServer, reporter) {
     sk_sp<DiscardableManager> discardableManager = sk_make_sp<DiscardableManager>();
     SkStrikeServer server(discardableManager.get());
-    SkStrikeClient client(discardableManager);
+    SkStrikeClient client(discardableManager, false);
 
     auto serverTf = SkTypeface::MakeFromName("monospace", SkFontStyle());
     server.serializeTypeface(serverTf.get());
@@ -219,7 +219,7 @@
 DEF_TEST(SkRemoteGlyphCache_StrikePinningClient, reporter) {
     sk_sp<DiscardableManager> discardableManager = sk_make_sp<DiscardableManager>();
     SkStrikeServer server(discardableManager.get());
-    SkStrikeClient client(discardableManager);
+    SkStrikeClient client(discardableManager, false);
 
     // Server.
     auto serverTf = SkTypeface::MakeFromName("monospace", SkFontStyle());
@@ -258,7 +258,7 @@
 DEF_TEST(SkRemoteGlyphCache_ClientMemoryAccounting, reporter) {
     sk_sp<DiscardableManager> discardableManager = sk_make_sp<DiscardableManager>();
     SkStrikeServer server(discardableManager.get());
-    SkStrikeClient client(discardableManager);
+    SkStrikeClient client(discardableManager, false);
 
     // Server.
     auto serverTf = SkTypeface::MakeFromName("monospace", SkFontStyle());
@@ -287,7 +287,7 @@
 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_DrawTextAsPath, reporter, ctxInfo) {
     sk_sp<DiscardableManager> discardableManager = sk_make_sp<DiscardableManager>();
     SkStrikeServer server(discardableManager.get());
-    SkStrikeClient client(discardableManager);
+    SkStrikeClient client(discardableManager, false);
     SkPaint paint;
     paint.setStyle(SkPaint::kStroke_Style);
     paint.setStrokeWidth(0);
@@ -325,7 +325,7 @@
 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_DrawTextAsDFT, reporter, ctxInfo) {
     sk_sp<DiscardableManager> discardableManager = sk_make_sp<DiscardableManager>();
     SkStrikeServer server(discardableManager.get());
-    SkStrikeClient client(discardableManager);
+    SkStrikeClient client(discardableManager, false);
     SkPaint paint;
 
     // A perspective transform forces fallback to dft.
@@ -371,7 +371,7 @@
 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_CacheMissReporting, reporter, ctxInfo) {
     sk_sp<DiscardableManager> discardableManager = sk_make_sp<DiscardableManager>();
     SkStrikeServer server(discardableManager.get());
-    SkStrikeClient client(discardableManager);
+    SkStrikeClient client(discardableManager, false);
 
     auto serverTf = SkTypeface::MakeFromName("monospace", SkFontStyle());
     auto tfData = server.serializeTypeface(serverTf.get());