From a92913e16957f0e5c9d51eb31d2be01a0d0d4c59 Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Mon, 12 Jul 2021 16:31:52 -0400 Subject: [PATCH] Make GrAuditTrail V1-only This CL has some rough edges since some classes that use it (e.g., GrOpsTask) aren't yet V1-only. That said, the big CL has to be broken up somehow. Bug: skia:11837 Change-Id: I41ed9982ca4664f893e447ba23c7aec59f42c964 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/426416 Reviewed-by: Brian Salomon Reviewed-by: Michael Ludwig Commit-Queue: Robert Phillips --- gn/gpu.gni | 2 +- include/gpu/GrRecordingContext.h | 5 +-- src/gpu/GrAuditTrail.h | 16 +++++++- src/gpu/GrDirectContextPriv.cpp | 1 - src/gpu/GrDirectContextPriv.h | 2 +- src/gpu/GrDrawingManager.cpp | 2 +- src/gpu/GrGpu.cpp | 1 - src/gpu/GrRecordingContextPriv.h | 2 +- src/gpu/GrSoftwarePathRenderer.cpp | 3 +- src/gpu/GrSurfaceContext.cpp | 12 ++---- src/gpu/GrSurfaceContext.h | 3 -- src/gpu/GrSurfaceDrawContext.cpp | 1 - src/gpu/GrTracing.h | 1 + src/gpu/ops/GrAAConvexPathRenderer.cpp | 2 +- src/gpu/ops/GrAAHairLinePathRenderer.cpp | 2 +- .../ops/GrAALinearizingConvexPathRenderer.cpp | 2 +- src/gpu/ops/GrDashLinePathRenderer.cpp | 2 +- src/gpu/ops/GrDefaultPathRenderer.cpp | 4 +- src/gpu/ops/GrSmallPathRenderer.cpp | 2 +- src/gpu/ops/GrTriangulatingPathRenderer.cpp | 2 +- src/gpu/tessellate/GrAtlasRenderTask.cpp | 5 ++- src/gpu/tessellate/GrAtlasRenderTask.h | 3 +- .../tessellate/GrTessellationPathRenderer.cpp | 2 +- tools/debugger/DebugCanvas.cpp | 39 ++++++++++++++----- tools/debugger/DebugCanvas.h | 5 ++- 25 files changed, 75 insertions(+), 46 deletions(-) diff --git a/gn/gpu.gni b/gn/gpu.gni index bdd94d8252..5208919586 100644 --- a/gn/gpu.gni +++ b/gn/gpu.gni @@ -38,7 +38,6 @@ skia_gpu_sources = [ "$_src/gpu/GrAppliedClip.h", "$_src/gpu/GrAttachment.cpp", "$_src/gpu/GrAttachment.h", - "$_src/gpu/GrAuditTrail.cpp", "$_src/gpu/GrAuditTrail.h", "$_src/gpu/GrAutoLocaleSetter.h", "$_src/gpu/GrBackendSemaphore.cpp", @@ -556,6 +555,7 @@ skia_skgpu_v2_sources = [ ] skia_skgpu_v1_sources = [ + "$_src/gpu/GrAuditTrail.cpp", "$_src/gpu/GrClipStack.cpp", "$_src/gpu/GrClipStack.h", "$_src/gpu/GrClipStackClip.cpp", diff --git a/include/gpu/GrRecordingContext.h b/include/gpu/GrRecordingContext.h index 3e83684837..fc060e112f 100644 --- a/include/gpu/GrRecordingContext.h +++ b/include/gpu/GrRecordingContext.h @@ -197,8 +197,6 @@ protected: */ void addOnFlushCallbackObject(GrOnFlushCallbackObject*); - GrAuditTrail* auditTrail() { return fAuditTrail.get(); } - GrRecordingContext* asRecordingContext() override { return this; } class Stats { @@ -251,10 +249,11 @@ protected: const Stats* stats() const { return &fStats; } void dumpJSON(SkJSONWriter*) const; -private: +protected: // Delete last in case other objects call it during destruction. std::unique_ptr fAuditTrail; +private: OwnedArenas fArenas; std::unique_ptr fDrawingManager; diff --git a/src/gpu/GrAuditTrail.h b/src/gpu/GrAuditTrail.h index a6eb8d3e85..f2d78dcb10 100644 --- a/src/gpu/GrAuditTrail.h +++ b/src/gpu/GrAuditTrail.h @@ -8,6 +8,10 @@ #ifndef GrAuditTrail_DEFINED #define GrAuditTrail_DEFINED +#include "include/gpu/GrTypes.h" + +#if SK_GPU_V1 + #include "include/core/SkRect.h" #include "include/core/SkString.h" #include "include/gpu/GrConfig.h" @@ -172,4 +176,14 @@ private: #define GR_AUDIT_TRAIL_OPS_RESULT_COMBINED(audit_trail, combineWith, op) \ GR_AUDIT_TRAIL_INVOKE_GUARD(audit_trail, opsCombined, combineWith, op) -#endif +#else // SK_GPU_V1 + +class GrAuditTrail { +}; + +#define GR_AUDIT_TRAIL_AUTO_FRAME(audit_trail, framename) +#define GR_AUDIT_TRAIL_ADD_OP(audit_trail, op, proxy_id) +#define GR_AUDIT_TRAIL_OPS_RESULT_COMBINED(audit_trail, combineWith, op) + +#endif // SK_GPU_V1 +#endif // GrAuditTrail_DEFINED diff --git a/src/gpu/GrDirectContextPriv.cpp b/src/gpu/GrDirectContextPriv.cpp index 15de5ced7c..e8a39d5641 100644 --- a/src/gpu/GrDirectContextPriv.cpp +++ b/src/gpu/GrDirectContextPriv.cpp @@ -10,7 +10,6 @@ #include "include/gpu/GrContextThreadSafeProxy.h" #include "include/gpu/GrDirectContext.h" #include "src/core/SkRuntimeEffectPriv.h" -#include "src/gpu/GrAuditTrail.h" #include "src/gpu/GrContextThreadSafeProxyPriv.h" #include "src/gpu/GrDrawingManager.h" #include "src/gpu/GrGpu.h" diff --git a/src/gpu/GrDirectContextPriv.h b/src/gpu/GrDirectContextPriv.h index ac65748dfa..c25fd4fe04 100644 --- a/src/gpu/GrDirectContextPriv.h +++ b/src/gpu/GrDirectContextPriv.h @@ -70,7 +70,7 @@ public: */ void addOnFlushCallbackObject(GrOnFlushCallbackObject*); - GrAuditTrail* auditTrail() { return fContext->auditTrail(); } + GrAuditTrail* auditTrail() { return fContext->fAuditTrail.get(); } /** * Finalizes all pending reads and writes to the surfaces and also performs an MSAA resolves diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp index d9a3e9d1b8..77e754b848 100644 --- a/src/gpu/GrDrawingManager.cpp +++ b/src/gpu/GrDrawingManager.cpp @@ -16,7 +16,6 @@ #include "include/gpu/GrRecordingContext.h" #include "src/core/SkDeferredDisplayListPriv.h" #include "src/core/SkTInternalLList.h" -#include "src/gpu/GrAuditTrail.h" #include "src/gpu/GrClientMappedBufferManager.h" #include "src/gpu/GrCopyRenderTask.h" #include "src/gpu/GrDDLTask.h" @@ -703,6 +702,7 @@ sk_sp GrDrawingManager::newOpsTask(GrSurfaceProxyView surfaceView, std::move(surfaceView), fContext->priv().auditTrail(), std::move(arenas))); + SkASSERT(this->getLastRenderTask(opsTask->target(0)) == opsTask.get()); if (flushTimeOpsTask) { diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp index 3022526fde..e8f33aecd4 100644 --- a/src/gpu/GrGpu.cpp +++ b/src/gpu/GrGpu.cpp @@ -15,7 +15,6 @@ #include "src/core/SkMathPriv.h" #include "src/core/SkMipmap.h" #include "src/gpu/GrAttachment.h" -#include "src/gpu/GrAuditTrail.h" #include "src/gpu/GrBackendUtils.h" #include "src/gpu/GrCaps.h" #include "src/gpu/GrDataUtils.h" diff --git a/src/gpu/GrRecordingContextPriv.h b/src/gpu/GrRecordingContextPriv.h index 21f546788b..8edd06e651 100644 --- a/src/gpu/GrRecordingContextPriv.h +++ b/src/gpu/GrRecordingContextPriv.h @@ -73,7 +73,7 @@ public: */ void addOnFlushCallbackObject(GrOnFlushCallbackObject*); - GrAuditTrail* auditTrail() { return fContext->auditTrail(); } + GrAuditTrail* auditTrail() { return fContext->fAuditTrail.get(); } #if GR_TEST_UTILS // Used by tests that intentionally exercise codepaths that print warning messages, in order to diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp index 0fe5979a37..885f377071 100644 --- a/src/gpu/GrSoftwarePathRenderer.cpp +++ b/src/gpu/GrSoftwarePathRenderer.cpp @@ -225,8 +225,9 @@ private: //////////////////////////////////////////////////////////////////////////////// // return true on success; false on failure bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) { - GR_AUDIT_TRAIL_AUTO_FRAME(args.fSurfaceDrawContext->auditTrail(), + GR_AUDIT_TRAIL_AUTO_FRAME(args.fContext->priv().auditTrail(), "GrSoftwarePathRenderer::onDrawPath"); + if (!fProxyProvider) { return false; } diff --git a/src/gpu/GrSurfaceContext.cpp b/src/gpu/GrSurfaceContext.cpp index 44e25dbe3d..33cdd68307 100644 --- a/src/gpu/GrSurfaceContext.cpp +++ b/src/gpu/GrSurfaceContext.cpp @@ -14,7 +14,6 @@ #include "src/core/SkAutoPixmapStorage.h" #include "src/core/SkMipmap.h" #include "src/core/SkYUVMath.h" -#include "src/gpu/GrAuditTrail.h" #include "src/gpu/GrClientMappedBufferManager.h" #include "src/gpu/GrColorSpaceXform.h" #include "src/gpu/GrDataUtils.h" @@ -147,10 +146,6 @@ GrSurfaceContext::GrSurfaceContext(GrRecordingContext* context, const GrCaps* GrSurfaceContext::caps() const { return fContext->priv().caps(); } -GrAuditTrail* GrSurfaceContext::auditTrail() { - return fContext->priv().auditTrail(); -} - GrDrawingManager* GrSurfaceContext::drawingManager() { return fContext->priv().drawingManager(); } @@ -172,7 +167,8 @@ bool GrSurfaceContext::readPixels(GrDirectContext* dContext, GrPixmap dst, SkIPo ASSERT_SINGLE_OWNER RETURN_FALSE_IF_ABANDONED SkDEBUGCODE(this->validate();) - GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(), "GrSurfaceContext::readPixels"); + GR_CREATE_TRACE_MARKER_CONTEXT("GrSurfaceContext", "readPixels", fContext); + if (!fContext->priv().matches(dContext)) { return false; } @@ -421,7 +417,7 @@ bool GrSurfaceContext::internalWritePixels(GrDirectContext* dContext, const GrCPixmap src[], int numLevels, SkIPoint pt) { - GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(), "GrSurfaceContext::internalWritePixels"); + GR_CREATE_TRACE_MARKER_CONTEXT("GrSurfaceContext", "internalWritePixels", fContext); SkASSERT(numLevels >= 1); SkASSERT(src); @@ -1132,7 +1128,7 @@ sk_sp GrSurfaceContext::copy(sk_sp src, ASSERT_SINGLE_OWNER RETURN_NULLPTR_IF_ABANDONED SkDEBUGCODE(this->validate();) - GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(), "GrSurfaceContextPriv::copy"); + GR_CREATE_TRACE_MARKER_CONTEXT("GrSurfaceContext", "copy", fContext); const GrCaps* caps = fContext->priv().caps(); diff --git a/src/gpu/GrSurfaceContext.h b/src/gpu/GrSurfaceContext.h index 77bd090019..d9946e0bb4 100644 --- a/src/gpu/GrSurfaceContext.h +++ b/src/gpu/GrSurfaceContext.h @@ -21,7 +21,6 @@ #include "src/gpu/GrSurfaceProxy.h" #include "src/gpu/GrSurfaceProxyView.h" -class GrAuditTrail; class GrDrawingManager; class GrRecordingContext; class GrRenderTargetProxy; @@ -191,8 +190,6 @@ public: SkImage::RescaleGamma, SkImage::RescaleMode); - GrAuditTrail* auditTrail(); - #if GR_TEST_UTILS bool testCopy(sk_sp src, const SkIRect& srcRect, const SkIPoint& dstPoint) { return this->copy(std::move(src), srcRect, dstPoint) != nullptr; diff --git a/src/gpu/GrSurfaceDrawContext.cpp b/src/gpu/GrSurfaceDrawContext.cpp index 50ce3216f7..bfcc88cd36 100644 --- a/src/gpu/GrSurfaceDrawContext.cpp +++ b/src/gpu/GrSurfaceDrawContext.cpp @@ -28,7 +28,6 @@ #include "src/core/SkSurfacePriv.h" #include "src/gpu/GrAppliedClip.h" #include "src/gpu/GrAttachment.h" -#include "src/gpu/GrAuditTrail.h" #include "src/gpu/GrBlurUtils.h" #include "src/gpu/GrCaps.h" #include "src/gpu/GrClip.h" diff --git a/src/gpu/GrTracing.h b/src/gpu/GrTracing.h index 9e0559b3d2..8b5dbf1146 100644 --- a/src/gpu/GrTracing.h +++ b/src/gpu/GrTracing.h @@ -18,4 +18,5 @@ #define GR_CREATE_TRACE_MARKER_CONTEXT(classname, op, context) \ GR_AUDIT_TRAIL_AUTO_FRAME(context->priv().auditTrail(), classname "::" op); \ TRACE_EVENT0("skia.gpu", classname "::" op) + #endif diff --git a/src/gpu/ops/GrAAConvexPathRenderer.cpp b/src/gpu/ops/GrAAConvexPathRenderer.cpp index 660bcc008f..e75dfcb259 100644 --- a/src/gpu/ops/GrAAConvexPathRenderer.cpp +++ b/src/gpu/ops/GrAAConvexPathRenderer.cpp @@ -920,7 +920,7 @@ private: } // anonymous namespace bool GrAAConvexPathRenderer::onDrawPath(const DrawPathArgs& args) { - GR_AUDIT_TRAIL_AUTO_FRAME(args.fSurfaceDrawContext->auditTrail(), + GR_AUDIT_TRAIL_AUTO_FRAME(args.fContext->priv().auditTrail(), "GrAAConvexPathRenderer::onDrawPath"); SkASSERT(args.fSurfaceDrawContext->numSamples() <= 1); SkASSERT(!args.fShape->isEmpty()); diff --git a/src/gpu/ops/GrAAHairLinePathRenderer.cpp b/src/gpu/ops/GrAAHairLinePathRenderer.cpp index 6c10f27baf..6715c54187 100644 --- a/src/gpu/ops/GrAAHairLinePathRenderer.cpp +++ b/src/gpu/ops/GrAAHairLinePathRenderer.cpp @@ -1310,7 +1310,7 @@ void AAHairlineOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBoun } bool GrAAHairLinePathRenderer::onDrawPath(const DrawPathArgs& args) { - GR_AUDIT_TRAIL_AUTO_FRAME(args.fSurfaceDrawContext->auditTrail(), + GR_AUDIT_TRAIL_AUTO_FRAME(args.fContext->priv().auditTrail(), "GrAAHairlinePathRenderer::onDrawPath"); SkASSERT(args.fSurfaceDrawContext->numSamples() <= 1); diff --git a/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp b/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp index e19b57eeaa..8057528514 100644 --- a/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp +++ b/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp @@ -388,7 +388,7 @@ private: } // anonymous namespace bool GrAALinearizingConvexPathRenderer::onDrawPath(const DrawPathArgs& args) { - GR_AUDIT_TRAIL_AUTO_FRAME(args.fSurfaceDrawContext->auditTrail(), + GR_AUDIT_TRAIL_AUTO_FRAME(args.fContext->priv().auditTrail(), "GrAALinearizingConvexPathRenderer::onDrawPath"); SkASSERT(args.fSurfaceDrawContext->numSamples() <= 1); SkASSERT(!args.fShape->isEmpty()); diff --git a/src/gpu/ops/GrDashLinePathRenderer.cpp b/src/gpu/ops/GrDashLinePathRenderer.cpp index d880283e07..1580ab7f6d 100644 --- a/src/gpu/ops/GrDashLinePathRenderer.cpp +++ b/src/gpu/ops/GrDashLinePathRenderer.cpp @@ -29,7 +29,7 @@ GrDashLinePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { } bool GrDashLinePathRenderer::onDrawPath(const DrawPathArgs& args) { - GR_AUDIT_TRAIL_AUTO_FRAME(args.fSurfaceDrawContext->auditTrail(), + GR_AUDIT_TRAIL_AUTO_FRAME(args.fContext->priv().auditTrail(), "GrDashLinePathRenderer::onDrawPath"); GrDashOp::AAMode aaMode; switch (args.fAAType) { diff --git a/src/gpu/ops/GrDefaultPathRenderer.cpp b/src/gpu/ops/GrDefaultPathRenderer.cpp index 73568c4bf2..c706a94039 100644 --- a/src/gpu/ops/GrDefaultPathRenderer.cpp +++ b/src/gpu/ops/GrDefaultPathRenderer.cpp @@ -757,7 +757,7 @@ GrDefaultPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { } bool GrDefaultPathRenderer::onDrawPath(const DrawPathArgs& args) { - GR_AUDIT_TRAIL_AUTO_FRAME(args.fSurfaceDrawContext->auditTrail(), + GR_AUDIT_TRAIL_AUTO_FRAME(args.fContext->priv().auditTrail(), "GrDefaultPathRenderer::onDrawPath"); GrAAType aaType = (GrAAType::kNone != args.fAAType) ? GrAAType::kMSAA : GrAAType::kNone; @@ -767,7 +767,7 @@ bool GrDefaultPathRenderer::onDrawPath(const DrawPathArgs& args) { } void GrDefaultPathRenderer::onStencilPath(const StencilPathArgs& args) { - GR_AUDIT_TRAIL_AUTO_FRAME(args.fSurfaceDrawContext->auditTrail(), + GR_AUDIT_TRAIL_AUTO_FRAME(args.fContext->priv().auditTrail(), "GrDefaultPathRenderer::onStencilPath"); SkASSERT(!args.fShape->inverseFilled()); diff --git a/src/gpu/ops/GrSmallPathRenderer.cpp b/src/gpu/ops/GrSmallPathRenderer.cpp index c2eee7dc56..9ddbc6a9da 100644 --- a/src/gpu/ops/GrSmallPathRenderer.cpp +++ b/src/gpu/ops/GrSmallPathRenderer.cpp @@ -694,7 +694,7 @@ private: }; bool GrSmallPathRenderer::onDrawPath(const DrawPathArgs& args) { - GR_AUDIT_TRAIL_AUTO_FRAME(args.fSurfaceDrawContext->auditTrail(), + GR_AUDIT_TRAIL_AUTO_FRAME(args.fContext->priv().auditTrail(), "GrSmallPathRenderer::onDrawPath"); // we've already bailed on inverse filled paths, so this is safe diff --git a/src/gpu/ops/GrTriangulatingPathRenderer.cpp b/src/gpu/ops/GrTriangulatingPathRenderer.cpp index b924238b62..aada2b0696 100644 --- a/src/gpu/ops/GrTriangulatingPathRenderer.cpp +++ b/src/gpu/ops/GrTriangulatingPathRenderer.cpp @@ -583,7 +583,7 @@ private: } // anonymous namespace bool GrTriangulatingPathRenderer::onDrawPath(const DrawPathArgs& args) { - GR_AUDIT_TRAIL_AUTO_FRAME(args.fSurfaceDrawContext->auditTrail(), + GR_AUDIT_TRAIL_AUTO_FRAME(args.fContext->priv().auditTrail(), "GrTriangulatingPathRenderer::onDrawPath"); GrOp::Owner op = TriangulatingPathOp::Make( diff --git a/src/gpu/tessellate/GrAtlasRenderTask.cpp b/src/gpu/tessellate/GrAtlasRenderTask.cpp index 79c0b8b684..3defd36d3d 100644 --- a/src/gpu/tessellate/GrAtlasRenderTask.cpp +++ b/src/gpu/tessellate/GrAtlasRenderTask.cpp @@ -14,11 +14,12 @@ #include "src/gpu/ops/GrFillRectOp.h" #include "src/gpu/tessellate/GrPathStencilCoverOp.h" -GrAtlasRenderTask::GrAtlasRenderTask(GrRecordingContext* rContext, GrAuditTrail* auditTrail, +GrAtlasRenderTask::GrAtlasRenderTask(GrRecordingContext* rContext, sk_sp arenas, std::unique_ptr dynamicAtlas) : GrOpsTask(rContext->priv().drawingManager(), - dynamicAtlas->writeView(*rContext->priv().caps()), auditTrail, + dynamicAtlas->writeView(*rContext->priv().caps()), + rContext->priv().auditTrail(), std::move(arenas)) , fDynamicAtlas(std::move(dynamicAtlas)) { } diff --git a/src/gpu/tessellate/GrAtlasRenderTask.h b/src/gpu/tessellate/GrAtlasRenderTask.h index 8215ec4554..4834ea4531 100644 --- a/src/gpu/tessellate/GrAtlasRenderTask.h +++ b/src/gpu/tessellate/GrAtlasRenderTask.h @@ -22,7 +22,8 @@ struct SkIPoint16; // call instantiate() at flush time. class GrAtlasRenderTask : public GrOpsTask { public: - GrAtlasRenderTask(GrRecordingContext*, GrAuditTrail*, sk_sp, + GrAtlasRenderTask(GrRecordingContext*, + sk_sp, std::unique_ptr); const GrTextureProxy* atlasProxy() const { return fDynamicAtlas->textureProxy(); } diff --git a/src/gpu/tessellate/GrTessellationPathRenderer.cpp b/src/gpu/tessellate/GrTessellationPathRenderer.cpp index 21d48b871e..397bc70236 100644 --- a/src/gpu/tessellate/GrTessellationPathRenderer.cpp +++ b/src/gpu/tessellate/GrTessellationPathRenderer.cpp @@ -403,7 +403,7 @@ bool GrTessellationPathRenderer::tryAddPathToAtlas(GrRecordingContext* rContext, kAtlasAlpha8Type, GrDynamicAtlas::InternalMultisample::kYes, SkISize{fAtlasInitialSize, fAtlasInitialSize}, fAtlasMaxSize, *rContext->priv().caps(), kAtlasAlgorithm); - auto newAtlasTask = sk_make_sp(rContext, rContext->priv().auditTrail(), + auto newAtlasTask = sk_make_sp(rContext, sk_make_sp(), std::move(dynamicAtlas)); rContext->priv().drawingManager()->addAtlasTask(newAtlasTask, currentAtlasTask); diff --git a/tools/debugger/DebugCanvas.cpp b/tools/debugger/DebugCanvas.cpp index 10be6e2a92..9298660548 100644 --- a/tools/debugger/DebugCanvas.cpp +++ b/tools/debugger/DebugCanvas.cpp @@ -17,7 +17,6 @@ #include "src/core/SkCanvasPriv.h" #include "src/core/SkClipOpPriv.h" #include "src/core/SkRectPriv.h" -#include "src/gpu/GrAuditTrail.h" #include "src/gpu/GrRecordingContextPriv.h" #include "src/gpu/GrSurfaceDrawContext.h" #include "src/utils/SkJSONWriter.h" @@ -26,6 +25,10 @@ #include +#if SK_GPU_V1 +#include "src/gpu/GrAuditTrail.h" +#endif + #define SKDEBUGCANVAS_VERSION 1 #define SKDEBUGCANVAS_ATTRIBUTE_VERSION "version" #define SKDEBUGCANVAS_ATTRIBUTE_COMMANDS "commands" @@ -141,6 +144,7 @@ void DebugCanvas::drawTo(SkCanvas* originalCanvas, int index, int m) { DebugPaintFilterCanvas filterCanvas(originalCanvas); SkCanvas* finalCanvas = fOverdrawViz ? &filterCanvas : originalCanvas; +#if SK_GPU_V1 auto dContext = GrAsDirectContext(finalCanvas->recordingContext()); // If we have a GPU backend we can also visualize the op information @@ -149,8 +153,10 @@ void DebugCanvas::drawTo(SkCanvas* originalCanvas, int index, int m) { // The audit trail must be obtained from the original canvas. at = this->getAuditTrail(originalCanvas); } +#endif for (int i = 0; i <= index; i++) { +#if SK_GPU_V1 GrAuditTrail::AutoCollectOps* acb = nullptr; if (at) { // We need to flush any pending operations, or they might combine with commands below. @@ -161,12 +167,15 @@ void DebugCanvas::drawTo(SkCanvas* originalCanvas, int index, int m) { } acb = new GrAuditTrail::AutoCollectOps(at, i); } +#endif if (fCommandVector[i]->isVisible()) { fCommandVector[i]->execute(finalCanvas); } +#if SK_GPU_V1 if (at && acb) { delete acb; } +#endif } if (SkColorGetA(fClipVizColor) != 0) { @@ -196,6 +205,7 @@ void DebugCanvas::drawTo(SkCanvas* originalCanvas, int index, int m) { finalCanvas->drawRect(fAndroidClip, androidClipPaint); } +#if SK_GPU_V1 // draw any ops if required and issue a full reset onto GrAuditTrail if (at) { // just in case there is global reordering, we flush the canvas before querying @@ -247,8 +257,9 @@ void DebugCanvas::drawTo(SkCanvas* originalCanvas, int index, int m) { } } finalCanvas->restore(); + this->cleanupAuditTrail(at); } - this->cleanupAuditTrail(originalCanvas); +#endif } void DebugCanvas::deleteDrawCommandAt(int index) { @@ -262,6 +273,7 @@ DrawCommand* DebugCanvas::getDrawCommandAt(int index) const { return fCommandVector[index]; } +#if SK_GPU_V1 GrAuditTrail* DebugCanvas::getAuditTrail(SkCanvas* canvas) { GrAuditTrail* at = nullptr; auto ctx = canvas->recordingContext(); @@ -293,21 +305,23 @@ void DebugCanvas::drawAndCollectOps(SkCanvas* canvas) { } } -void DebugCanvas::cleanupAuditTrail(SkCanvas* canvas) { - GrAuditTrail* at = this->getAuditTrail(canvas); +void DebugCanvas::cleanupAuditTrail(GrAuditTrail* at) { if (at) { GrAuditTrail::AutoEnable ae(at); at->fullReset(); } } +#endif void DebugCanvas::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager, SkCanvas* canvas) { +#if SK_GPU_V1 this->drawAndCollectOps(canvas); // now collect json GrAuditTrail* at = this->getAuditTrail(canvas); +#endif writer.appendS32(SKDEBUGCANVAS_ATTRIBUTE_VERSION, SKDEBUGCANVAS_VERSION); writer.beginArray(SKDEBUGCANVAS_ATTRIBUTE_COMMANDS); @@ -315,29 +329,36 @@ void DebugCanvas::toJSON(SkJSONWriter& writer, writer.beginObject(); // command this->getDrawCommandAt(i)->toJSON(writer, urlDataManager); +#if SK_GPU_V1 if (at) { writer.appendName(SKDEBUGCANVAS_ATTRIBUTE_AUDITTRAIL); at->toJson(writer, i); } +#endif writer.endObject(); // command } writer.endArray(); // commands - this->cleanupAuditTrail(canvas); +#if SK_GPU_V1 + this->cleanupAuditTrail(at); +#endif } void DebugCanvas::toJSONOpsTask(SkJSONWriter& writer, SkCanvas* canvas) { +#if SK_GPU_V1 this->drawAndCollectOps(canvas); GrAuditTrail* at = this->getAuditTrail(canvas); if (at) { GrAuditTrail::AutoManageOpsTask enable(at); at->toJson(writer); - } else { - writer.beginObject(); - writer.endObject(); + this->cleanupAuditTrail(at); + return; } - this->cleanupAuditTrail(canvas); +#endif + + writer.beginObject(); + writer.endObject(); } void DebugCanvas::setOverdrawViz(bool overdrawViz) { fOverdrawViz = overdrawViz; } diff --git a/tools/debugger/DebugCanvas.h b/tools/debugger/DebugCanvas.h index 893dae54f5..b3bc09657a 100644 --- a/tools/debugger/DebugCanvas.h +++ b/tools/debugger/DebugCanvas.h @@ -231,10 +231,11 @@ private: */ void addDrawCommand(DrawCommand* command); +#if SK_GPU_V1 GrAuditTrail* getAuditTrail(SkCanvas*); - void drawAndCollectOps(SkCanvas*); - void cleanupAuditTrail(SkCanvas*); + void cleanupAuditTrail(GrAuditTrail*); +#endif using INHERITED = SkCanvasVirtualEnforcer; };