From 1c4cf27965bd6658cf02e959b776535da5ebda03 Mon Sep 17 00:00:00 2001 From: Herb Derby Date: Tue, 7 Dec 2021 11:41:36 -0500 Subject: [PATCH] better tracing Change-Id: I778703ae91df56ba4b7dd768637ac774010c4e08 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/481197 Reviewed-by: Robert Phillips Commit-Queue: Herb Derby --- src/core/SkGlyph.h | 14 +++++++++++++- src/core/SkGlyphBuffer.cpp | 2 +- src/core/SkGlyphRun.h | 2 -- src/core/SkGlyphRunPainter.cpp | 12 ++++++++++-- src/core/SkGlyphRunPainter.h | 3 ++- src/core/SkRemoteGlyphCache.cpp | 4 +++- src/core/SkScalerContext.h | 2 +- src/core/SkStrikeCache.cpp | 2 +- src/core/SkTypeface_remote.cpp | 3 ++- src/gpu/text/GrTextBlob.cpp | 8 ++++++-- 10 files changed, 39 insertions(+), 13 deletions(-) diff --git a/src/core/SkGlyph.h b/src/core/SkGlyph.h index c6a163136e..0a73fd12b4 100644 --- a/src/core/SkGlyph.h +++ b/src/core/SkGlyph.h @@ -101,6 +101,14 @@ struct SkPackedGlyphID { return str; } + SkString shortDump() const { + SkString str; + str.appendf("0x%x|%1d|%1d", this->glyphID(), + this->subPixelField(kSubPixelX), + this->subPixelField(kSubPixelY)); + return str; + } + private: static constexpr uint32_t PackIDSubXSubY(SkGlyphID glyphID, uint32_t x, uint32_t y) { SkASSERT(x < (1u << kSubPixelPosLen)); @@ -164,8 +172,12 @@ private: return ((uint32_t)n >> kFixedPointSubPixelPosBits) & kSubPixelPosMask; } + constexpr uint32_t subPixelField(uint32_t subPixelPosBit) const { + return (fID >> subPixelPosBit) & kSubPixelPosMask; + } + constexpr SkFixed subToFixed(uint32_t subPixelPosBit) const { - uint32_t subPixelPosition = (fID >> subPixelPosBit) & kSubPixelPosMask; + uint32_t subPixelPosition = this->subPixelField(subPixelPosBit); return subPixelPosition << kFixedPointSubPixelPosBits; } diff --git a/src/core/SkGlyphBuffer.cpp b/src/core/SkGlyphBuffer.cpp index 31b247ac28..b05d1e3901 100644 --- a/src/core/SkGlyphBuffer.cpp +++ b/src/core/SkGlyphBuffer.cpp @@ -104,7 +104,7 @@ SkString SkDrawableGlyphBuffer::dumpInput() const { SkString msg; for (auto [packedGlyphID, pos] : SkZip{fInputSize, fMultiBuffer.get(), fPositions.get()}) { - msg.appendf("0x%x:(%a,%a), ", packedGlyphID.packedID().value(), pos.x(), pos.y()); + msg.appendf("%s:(%a,%a), ", packedGlyphID.packedID().shortDump().c_str(), pos.x(), pos.y()); } return msg; } diff --git a/src/core/SkGlyphRun.h b/src/core/SkGlyphRun.h index 94b41639de..b2e77f9a0f 100644 --- a/src/core/SkGlyphRun.h +++ b/src/core/SkGlyphRun.h @@ -74,8 +74,6 @@ public: SkGlyphRunList(const SkGlyphRun& glyphRun, const SkRect& bounds, SkPoint origin); - - uint64_t uniqueID() const; bool anyRunsLCD() const; void temporaryShuntBlobNotifyAddedToCache(uint32_t cacheID) const; diff --git a/src/core/SkGlyphRunPainter.cpp b/src/core/SkGlyphRunPainter.cpp index 2bbe8120e1..c122578184 100644 --- a/src/core/SkGlyphRunPainter.cpp +++ b/src/core/SkGlyphRunPainter.cpp @@ -35,6 +35,7 @@ #include "src/core/SkStrikeSpec.h" #include "src/core/SkTraceEvent.h" +#include #include // -- SkGlyphRunListPainter ------------------------------------------------------------------------ @@ -229,14 +230,21 @@ void SkGlyphRunListPainter::processGlyphRun(const SkGlyphRun& glyphRun, const SkPaint& runPaint, const GrSDFTControl& control, SkGlyphRunPainterInterface* process, - const char* tag) { + const char* tag, + uint64_t uniqueID) { #if defined(SK_TRACE_GLYPH_RUN_PROCESS) SkString msg; msg.appendf("\nStart glyph run processing"); if (tag != nullptr) { msg.appendf(" for %s ", tag); + if (uniqueID != SK_InvalidUniqueID) { + msg.appendf(" uniqueID: %" PRIu64, uniqueID); + } } - msg.appendf("\n"); + msg.appendf("\n matrix\n"); + msg.appendf(" %7.3g %7.3g %7.3g\n %7.3g %7.3g %7.3g\n", + drawMatrix[0], drawMatrix[1], drawMatrix[2], + drawMatrix[3], drawMatrix[4], drawMatrix[5]); #endif ScopedBuffers _ = this->ensureBuffers(glyphRun); fRejects.setSource(glyphRun.source()); diff --git a/src/core/SkGlyphRunPainter.h b/src/core/SkGlyphRunPainter.h index f2336c5d3d..a65b0d7e29 100644 --- a/src/core/SkGlyphRunPainter.h +++ b/src/core/SkGlyphRunPainter.h @@ -92,7 +92,8 @@ public: const SkPaint& drawPaint, const GrSDFTControl& control, SkGlyphRunPainterInterface* process, - const char* tag = nullptr); + const char* tag = nullptr, + uint64_t blobID = SK_InvalidUniqueID); #endif // SK_SUPPORT_GPU private: diff --git a/src/core/SkRemoteGlyphCache.cpp b/src/core/SkRemoteGlyphCache.cpp index 9d4938adb9..a9295515ec 100644 --- a/src/core/SkRemoteGlyphCache.cpp +++ b/src/core/SkRemoteGlyphCache.cpp @@ -808,13 +808,15 @@ protected: SkMatrix drawMatrix = this->localToDevice(); drawMatrix.preTranslate(glyphRunList.origin().x(), glyphRunList.origin().y()); + const uint64_t uniqueID = glyphRunList.uniqueID(); for (auto& glyphRun : glyphRunList) { fPainter.processGlyphRun(glyphRun, drawMatrix, paint, control, nullptr, - "Cache Diff"); + "Cache Diff", + uniqueID); } #endif // SK_SUPPORT_GPU } diff --git a/src/core/SkScalerContext.h b/src/core/SkScalerContext.h index 74682307df..303eb1fbca 100644 --- a/src/core/SkScalerContext.h +++ b/src/core/SkScalerContext.h @@ -141,7 +141,7 @@ public: fFrameWidth, fMiterLimit, fMaskFormat, fStrokeJoin, fStrokeCap, fFlags); msg.appendf(" lum bits %x, device gamma %d, paint gamma %d contrast %d\n", fLumBits, fDeviceGamma, fPaintGamma, fContrast); - msg.appendf(" foreground color %x", fForegroundColor); + msg.appendf(" foreground color %x\n", fForegroundColor); return msg; } diff --git a/src/core/SkStrikeCache.cpp b/src/core/SkStrikeCache.cpp index 149bdba262..d160498e03 100644 --- a/src/core/SkStrikeCache.cpp +++ b/src/core/SkStrikeCache.cpp @@ -63,7 +63,7 @@ void SkStrikeCache::Dump() { auto visitor = [&counter](const SkStrike& strike) { const SkScalerContextRec& rec = strike.fScalerCache.getScalerContext()->getRec(); - SkDebugf("index %d\n", counter); + SkDebugf("index %d checksum: %x\n", counter, strike.getDescriptor().getChecksum()); SkDebugf("%s", rec.dump().c_str()); counter += 1; }; diff --git a/src/core/SkTypeface_remote.cpp b/src/core/SkTypeface_remote.cpp index a59d214e4b..2c9f990eb8 100644 --- a/src/core/SkTypeface_remote.cpp +++ b/src/core/SkTypeface_remote.cpp @@ -26,7 +26,8 @@ bool SkScalerContextProxy::generateAdvance(SkGlyph* glyph) { void SkScalerContextProxy::generateMetrics(SkGlyph* glyph, SkArenaAlloc*) { TRACE_EVENT1("skia", "generateMetrics", "rec", TRACE_STR_COPY(this->getRec().dump().c_str())); if (this->getProxyTypeface()->isLogging()) { - SkDebugf("GlyphCacheMiss generateMetrics: %s\n", this->getRec().dump().c_str()); + SkDebugf("GlyphCacheMiss generateMetrics looking for glyph: %x\n generateMetrics: %s\n", + glyph->getPackedID().value(), this->getRec().dump().c_str()); } glyph->fMaskFormat = fRec.fMaskFormat; diff --git a/src/gpu/text/GrTextBlob.cpp b/src/gpu/text/GrTextBlob.cpp index 90b74a018c..d5afd71192 100644 --- a/src/gpu/text/GrTextBlob.cpp +++ b/src/gpu/text/GrTextBlob.cpp @@ -1551,13 +1551,15 @@ sk_sp GrTextBlob::Make(const SkGlyphRunList& glyphRunList, sk_sp blob{new (allocation) GrTextBlob(bytesNeededForSubRun, positionMatrix, initialLuminance)}; + const uint64_t uniqueID = glyphRunList.uniqueID(); for (auto& glyphRun : glyphRunList) { painter->processGlyphRun(glyphRun, positionMatrix, paint, control, blob.get(), - "GrTextBlob"); + "GrTextBlob", + uniqueID); } return blob; @@ -3080,13 +3082,15 @@ sk_sp Slug::Make(const SkMatrixProvider& viewMatrix, glyphRunList.origin(), bytesNeededForSubRun)}; + const uint64_t uniqueID = glyphRunList.uniqueID(); for (auto& glyphRun : glyphRunList) { painter->processGlyphRun(glyphRun, positionMatrix, paint, control, slug.get(), - "Slug"); + "Slug", + uniqueID); } return slug;