ccpr: Remove the dangling pointer from GrCCDrawPathsOp
Actually takes a ref on fOwningPerOpListPaths, instead of just
asserting it continues to exist. Removes unnecessary asserts
surrounding dangling pointers.
Bug: skia:8359
Change-Id: Ie80da55510f320452bd9ee3a4b38bd59d48681a0
Reviewed-on: https://skia-review.googlesource.com/154684
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/src/gpu/ccpr/GrCCClipProcessor.cpp b/src/gpu/ccpr/GrCCClipProcessor.cpp
index 864ac58..c43814b 100644
--- a/src/gpu/ccpr/GrCCClipProcessor.cpp
+++ b/src/gpu/ccpr/GrCCClipProcessor.cpp
@@ -22,6 +22,7 @@
, fOverrideFillType(overrideFillType)
, fAtlasAccess(sk_ref_sp(fClipPath->atlasLazyProxy()), GrSamplerState::Filter::kNearest,
GrSamplerState::WrapMode::kClamp) {
+ SkASSERT(fAtlasAccess.proxy());
this->setTextureSamplerCnt(1);
}
diff --git a/src/gpu/ccpr/GrCCDrawPathsOp.cpp b/src/gpu/ccpr/GrCCDrawPathsOp.cpp
index 1ec9493..7390b9f 100644
--- a/src/gpu/ccpr/GrCCDrawPathsOp.cpp
+++ b/src/gpu/ccpr/GrCCDrawPathsOp.cpp
@@ -130,7 +130,7 @@
GrCCDrawPathsOp::~GrCCDrawPathsOp() {
if (fOwningPerOpListPaths) {
- // Remove CCPR's dangling pointer to this Op before deleting it.
+ // Remove the list's dangling pointer to this Op before deleting it.
fOwningPerOpListPaths->fDrawOps.remove(this);
}
}
@@ -223,11 +223,11 @@
return CombineResult::kMerged;
}
-void GrCCDrawPathsOp::wasRecorded(GrCCPerOpListPaths* owningPerOpListPaths) {
+void GrCCDrawPathsOp::wasRecorded(sk_sp<GrCCPerOpListPaths> owningPerOpListPaths) {
SkASSERT(1 == fNumDraws);
SkASSERT(!fOwningPerOpListPaths);
- owningPerOpListPaths->fDrawOps.addToTail(this);
- fOwningPerOpListPaths = owningPerOpListPaths;
+ fOwningPerOpListPaths = std::move(owningPerOpListPaths);
+ fOwningPerOpListPaths->fDrawOps.addToTail(this);
}
void GrCCDrawPathsOp::accountForOwnPaths(GrCCPathCache* pathCache,
diff --git a/src/gpu/ccpr/GrCCDrawPathsOp.h b/src/gpu/ccpr/GrCCDrawPathsOp.h
index 2716d59..e1d354d 100644
--- a/src/gpu/ccpr/GrCCDrawPathsOp.h
+++ b/src/gpu/ccpr/GrCCDrawPathsOp.h
@@ -14,12 +14,12 @@
#include "ops/GrDrawOp.h"
struct GrCCPerFlushResourceSpecs;
+struct GrCCPerOpListPaths;
class GrCCAtlas;
class GrOnFlushResourceProvider;
class GrCCPathCache;
class GrCCPathCacheEntry;
class GrCCPerFlushResources;
-class GrCCPerOpListPaths;
/**
* This is the Op that draws paths to the actual canvas, using atlases generated by CCPR.
@@ -40,7 +40,7 @@
void visitProxies(const VisitProxyFunc& fn) const override { fProcessors.visitProxies(fn); }
void onPrepare(GrOpFlushState*) override {}
- void wasRecorded(GrCCPerOpListPaths* owningPerOpListPaths);
+ void wasRecorded(sk_sp<GrCCPerOpListPaths> owningPerOpListPaths);
// Makes decisions about how to draw each path (cached, copied, rendered, etc.), and
// increments/fills out the corresponding GrCCPerFlushResourceSpecs. 'stashedAtlasKey', if
@@ -112,7 +112,7 @@
GrCCSTLList<SingleDraw> fDraws;
SkDEBUGCODE(int fNumDraws = 1);
- GrCCPerOpListPaths* fOwningPerOpListPaths = nullptr;
+ sk_sp<GrCCPerOpListPaths> fOwningPerOpListPaths;
GrProcessorSet fProcessors;
struct InstanceRange {
diff --git a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
index 9d30bb4..69d7200 100644
--- a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
+++ b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
@@ -18,17 +18,6 @@
using PathInstance = GrCCPathProcessor::Instance;
-GrCCPerOpListPaths::~GrCCPerOpListPaths() {
- // Ensure there are no surviving DrawPathsOps with a dangling pointer into this class.
- if (!fDrawOps.isEmpty()) {
- SK_ABORT("GrCCDrawPathsOp(s) not deleted during flush");
- }
- // Clip lazy proxies also reference this class from their callbacks, but those callbacks
- // are only invoked at flush time while we are still alive. (Unlike DrawPathsOps, that
- // unregister themselves upon destruction.) So it shouldn't matter if any clip proxies
- // are still around.
-}
-
bool GrCoverageCountingPathRenderer::IsSupported(const GrCaps& caps) {
const GrShaderCaps& shaderCaps = *caps.shaderCaps();
return shaderCaps.integerSupport() && shaderCaps.flatInterpolationSupport() &&
@@ -52,12 +41,6 @@
}
}
-GrCoverageCountingPathRenderer::~GrCoverageCountingPathRenderer() {
- // Ensure callers are actually flushing paths they record, not causing us to leak memory.
- SkASSERT(fPendingPaths.empty());
- SkASSERT(!fFlushing);
-}
-
GrCCPerOpListPaths* GrCoverageCountingPathRenderer::lookupPendingPaths(uint32_t opListID) {
auto it = fPendingPaths.find(opListID);
if (fPendingPaths.end() == it) {
@@ -165,7 +148,7 @@
if (GrCCDrawPathsOp* op = opHolder.get()) {
GrRenderTargetContext* rtc = args.fRenderTargetContext;
if (uint32_t opListID = rtc->addDrawOp(*args.fClip, std::move(opHolder))) {
- op->wasRecorded(this->lookupPendingPaths(opListID));
+ op->wasRecorded(sk_ref_sp(this->lookupPendingPaths(opListID)));
}
}
}
diff --git a/src/gpu/ccpr/GrCoverageCountingPathRenderer.h b/src/gpu/ccpr/GrCoverageCountingPathRenderer.h
index 1d3bfd8..19e42a9 100644
--- a/src/gpu/ccpr/GrCoverageCountingPathRenderer.h
+++ b/src/gpu/ccpr/GrCoverageCountingPathRenderer.h
@@ -36,8 +36,6 @@
static sk_sp<GrCoverageCountingPathRenderer> CreateIfSupported(const GrCaps&, AllowCaching);
- ~GrCoverageCountingPathRenderer() override;
-
using PendingPathsMap = std::map<uint32_t, sk_sp<GrCCPerOpListPaths>>;
// In DDL mode, Ganesh needs to be able to move the pending GrCCPerOpListPaths to the DDL object