aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/gpu/GrRenderTargetContext.h2
-rw-r--r--src/gpu/GrRenderTargetOpList.cpp12
-rw-r--r--src/gpu/GrRenderTargetOpList.h22
-rw-r--r--src/gpu/ccpr/GrCCDrawPathsOp.cpp9
-rw-r--r--src/gpu/ccpr/GrCCDrawPathsOp.h2
-rw-r--r--src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp20
-rw-r--r--src/gpu/ccpr/GrCoverageCountingPathRenderer.h6
-rw-r--r--src/gpu/ops/GrOp.h8
-rw-r--r--tests/LazyProxyTest.cpp1
-rw-r--r--tests/OnFlushCallbackTest.cpp1
10 files changed, 43 insertions, 40 deletions
diff --git a/src/gpu/GrRenderTargetContext.h b/src/gpu/GrRenderTargetContext.h
index 1a68444b13..b237d489cc 100644
--- a/src/gpu/GrRenderTargetContext.h
+++ b/src/gpu/GrRenderTargetContext.h
@@ -435,7 +435,7 @@ private:
// These perform processing specific to Gr[Mesh]DrawOp-derived ops before recording them into
// the op list. They return the id of the opList to which the op was added, or 0, if it was
- // dropped (e.g., due to clipping).
+ // dropped (e.g., due to clipping or being combined).
uint32_t addDrawOp(const GrClip&, std::unique_ptr<GrDrawOp>);
// Makes a copy of the proxy if it is necessary for the draw and places the texture that should
diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp
index b53b4006c8..f98e0f4197 100644
--- a/src/gpu/GrRenderTargetOpList.cpp
+++ b/src/gpu/GrRenderTargetOpList.cpp
@@ -322,10 +322,10 @@ bool GrRenderTargetOpList::combineIfPossible(const RecordedOp& a, GrOp* b,
return a.fOp->combineIfPossible(b, caps);
}
-void GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op,
- const GrCaps& caps,
- GrAppliedClip* clip,
- const DstProxy* dstProxy) {
+uint32_t GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op,
+ const GrCaps& caps,
+ GrAppliedClip* clip,
+ const DstProxy* dstProxy) {
SkASSERT(fTarget.get());
// A closed GrOpList should never receive new/more ops
@@ -358,7 +358,7 @@ void GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op,
GrOP_INFO("\t\t\tBackward: Combined op info:\n");
GrOP_INFO(SkTabString(candidate.fOp->dumpInfo(), 4).c_str());
GR_AUDIT_TRAIL_OPS_RESULT_COMBINED(fAuditTrail, candidate.fOp.get(), op.get());
- return;
+ return SK_InvalidUniqueID;
}
// Stop going backwards if we would cause a painter's order violation.
if (!can_reorder(fRecordedOps.fromBack(i).fOp->bounds(), op->bounds())) {
@@ -381,7 +381,7 @@ void GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op,
SkDEBUGCODE(fNumClips++;)
}
fRecordedOps.emplace_back(std::move(op), clip, dstProxy);
- fRecordedOps.back().fOp->wasRecorded(this);
+ return this->uniqueID();
}
void GrRenderTargetOpList::forwardCombine(const GrCaps& caps) {
diff --git a/src/gpu/GrRenderTargetOpList.h b/src/gpu/GrRenderTargetOpList.h
index 938f69aba6..af9b4a4670 100644
--- a/src/gpu/GrRenderTargetOpList.h
+++ b/src/gpu/GrRenderTargetOpList.h
@@ -60,6 +60,10 @@ public:
void onPrepare(GrOpFlushState* flushState) override;
bool onExecute(GrOpFlushState* flushState) override;
+ /**
+ * Returns this opList's id if the Op was recorded, or SK_InvalidUniqueID if it was combined
+ * into an existing Op or otherwise deleted.
+ */
uint32_t addOp(std::unique_ptr<GrOp> op, const GrCaps& caps) {
auto addDependency = [ &caps, this ] (GrSurfaceProxy* p) {
this->addDependency(p, caps);
@@ -67,11 +71,13 @@ public:
op->visitProxies(addDependency);
- this->recordOp(std::move(op), caps);
-
- return this->uniqueID();
+ return this->recordOp(std::move(op), caps);
}
+ /**
+ * Returns this opList's id if the Op was recorded, or SK_InvalidUniqueID if it was combined
+ * into an existing Op or otherwise deleted.
+ */
uint32_t addOp(std::unique_ptr<GrOp> op, const GrCaps& caps,
GrAppliedClip&& clip, const DstProxy& dstProxy) {
auto addDependency = [ &caps, this ] (GrSurfaceProxy* p) {
@@ -81,9 +87,7 @@ public:
op->visitProxies(addDependency);
clip.visitProxies(addDependency);
- this->recordOp(std::move(op), caps, clip.doesClip() ? &clip : nullptr, &dstProxy);
-
- return this->uniqueID();
+ return this->recordOp(std::move(op), caps, clip.doesClip() ? &clip : nullptr, &dstProxy);
}
void discard();
@@ -147,8 +151,10 @@ private:
void gatherProxyIntervals(GrResourceAllocator*) const override;
- void recordOp(std::unique_ptr<GrOp>, const GrCaps& caps,
- GrAppliedClip* = nullptr, const DstProxy* = nullptr);
+ // Returns this opList's id if the Op was recorded, or SK_InvalidUniqueID if it was combined
+ // into an existing Op or otherwise deleted.
+ uint32_t recordOp(std::unique_ptr<GrOp>, const GrCaps& caps,
+ GrAppliedClip* = nullptr, const DstProxy* = nullptr);
void forwardCombine(const GrCaps&);
diff --git a/src/gpu/ccpr/GrCCDrawPathsOp.cpp b/src/gpu/ccpr/GrCCDrawPathsOp.cpp
index 80304857d0..96c1134536 100644
--- a/src/gpu/ccpr/GrCCDrawPathsOp.cpp
+++ b/src/gpu/ccpr/GrCCDrawPathsOp.cpp
@@ -81,10 +81,11 @@ bool GrCCDrawPathsOp::onCombineIfPossible(GrOp* op, const GrCaps& caps) {
return true;
}
-void GrCCDrawPathsOp::wasRecorded(GrRenderTargetOpList* opList) {
+void GrCCDrawPathsOp::wasRecorded(GrCCRTPendingPaths* owningRTPendingPaths) {
+ SkASSERT(1 == fNumDraws);
SkASSERT(!fOwningRTPendingPaths);
- fOwningRTPendingPaths = fCCPR->lookupRTPendingPaths(opList);
- fOwningRTPendingPaths->fDrawOps.addToTail(this);
+ owningRTPendingPaths->fDrawOps.addToTail(this);
+ fOwningRTPendingPaths = owningRTPendingPaths;
}
int GrCCDrawPathsOp::countPaths(GrCCPathParser::PathStats* stats) const {
@@ -134,6 +135,8 @@ void GrCCDrawPathsOp::setupResources(GrCCPerFlushResources* resources,
}
void GrCCDrawPathsOp::onExecute(GrOpFlushState* flushState) {
+ SkASSERT(fOwningRTPendingPaths);
+
const GrCCPerFlushResources* resources = fCCPR->getPerFlushResources();
if (!resources) {
return; // Setup failed.
diff --git a/src/gpu/ccpr/GrCCDrawPathsOp.h b/src/gpu/ccpr/GrCCDrawPathsOp.h
index 35981723cb..b523442393 100644
--- a/src/gpu/ccpr/GrCCDrawPathsOp.h
+++ b/src/gpu/ccpr/GrCCDrawPathsOp.h
@@ -35,13 +35,13 @@ public:
FixedFunctionFlags fixedFunctionFlags() const override { return FixedFunctionFlags::kNone; }
RequiresDstTexture finalize(const GrCaps&, const GrAppliedClip*,
GrPixelConfigIsClamped) override;
- void wasRecorded(GrRenderTargetOpList*) override;
bool onCombineIfPossible(GrOp* other, const GrCaps& caps) override;
void visitProxies(const VisitProxyFunc& func) const override {
fProcessors.visitProxies(func);
}
void onPrepare(GrOpFlushState*) override {}
+ void wasRecorded(GrCCRTPendingPaths* owningRTPendingPaths);
int countPaths(GrCCPathParser::PathStats*) const;
void setupResources(GrCCPerFlushResources*, GrOnFlushResourceProvider*);
SkDEBUGCODE(int numSkippedInstances_debugOnly() const { return fNumSkippedInstances; })
diff --git a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
index 35ac86c542..0c1b493471 100644
--- a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
+++ b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
@@ -112,19 +112,25 @@ bool GrCoverageCountingPathRenderer::onDrawPath(const DrawPathArgs& args) {
SkPath croppedPath;
path.transform(*args.fViewMatrix, &croppedPath);
crop_path(croppedPath, clipIBounds, &croppedPath);
- auto op = skstd::make_unique<GrCCDrawPathsOp>(this, std::move(args.fPaint), clipIBounds,
- SkMatrix::I(), croppedPath,
- croppedPath.getBounds());
- rtc->addDrawOp(*args.fClip, std::move(op));
+ this->adoptAndRecordOp(new GrCCDrawPathsOp(this, std::move(args.fPaint), clipIBounds,
+ SkMatrix::I(), croppedPath,
+ croppedPath.getBounds()), args);
return true;
}
- auto op = skstd::make_unique<GrCCDrawPathsOp>(this, std::move(args.fPaint), clipIBounds,
- *args.fViewMatrix, path, devBounds);
- rtc->addDrawOp(*args.fClip, std::move(op));
+ this->adoptAndRecordOp(new GrCCDrawPathsOp(this, std::move(args.fPaint), clipIBounds,
+ *args.fViewMatrix, path, devBounds), args);
return true;
}
+void GrCoverageCountingPathRenderer::adoptAndRecordOp(GrCCDrawPathsOp* op,
+ const DrawPathArgs& args) {
+ GrRenderTargetContext* rtc = args.fRenderTargetContext;
+ if (uint32_t opListID = rtc->addDrawOp(*args.fClip, std::unique_ptr<GrDrawOp>(op))) {
+ op->wasRecorded(&fRTPendingPathsMap[opListID]);
+ }
+}
+
std::unique_ptr<GrFragmentProcessor> GrCoverageCountingPathRenderer::makeClipProcessor(
GrProxyProvider* proxyProvider,
uint32_t opListID, const SkPath& deviceSpacePath, const SkIRect& accessRect,
diff --git a/src/gpu/ccpr/GrCoverageCountingPathRenderer.h b/src/gpu/ccpr/GrCoverageCountingPathRenderer.h
index 93f767fce2..ca52fedada 100644
--- a/src/gpu/ccpr/GrCoverageCountingPathRenderer.h
+++ b/src/gpu/ccpr/GrCoverageCountingPathRenderer.h
@@ -78,10 +78,7 @@ public:
private:
GrCoverageCountingPathRenderer(bool drawCachablePaths);
- GrCCRTPendingPaths* lookupRTPendingPaths(GrRenderTargetOpList* opList) {
- SkASSERT(!fFlushing);
- return &fRTPendingPathsMap[opList->uniqueID()];
- }
+ void adoptAndRecordOp(GrCCDrawPathsOp*, const DrawPathArgs&);
const GrCCPerFlushResources* getPerFlushResources() const {
SkASSERT(fFlushing);
@@ -96,7 +93,6 @@ private:
const bool fDrawCachablePaths;
- friend void GrCCDrawPathsOp::wasRecorded(GrRenderTargetOpList*); // For lookupRTPendingPaths.
friend void GrCCDrawPathsOp::onExecute(GrOpFlushState*); // For getPerFlushResources.
};
diff --git a/src/gpu/ops/GrOp.h b/src/gpu/ops/GrOp.h
index 96d39d32c3..5d7922374c 100644
--- a/src/gpu/ops/GrOp.h
+++ b/src/gpu/ops/GrOp.h
@@ -138,14 +138,6 @@ public:
}
/**
- * This is called to notify the op that it has been recorded into a GrOpList. Ops can use this
- * to begin preparations for the flush of the op list. Note that the op still may either be
- * combined into another op or have another op combined into it via combineIfPossible() after
- * this call is made.
- */
- virtual void wasRecorded(GrRenderTargetOpList*) {}
-
- /**
* Called prior to executing. The op should perform any resource creation or data transfers
* necessary before execute() is called.
*/
diff --git a/tests/LazyProxyTest.cpp b/tests/LazyProxyTest.cpp
index b8e672a55f..dc8232b644 100644
--- a/tests/LazyProxyTest.cpp
+++ b/tests/LazyProxyTest.cpp
@@ -96,7 +96,6 @@ public:
GrPixelConfigIsClamped) override {
return RequiresDstTexture::kNo;
}
- void wasRecorded(GrRenderTargetOpList*) override {}
bool onCombineIfPossible(GrOp* other, const GrCaps& caps) override { return false; }
void onPrepare(GrOpFlushState*) override {}
diff --git a/tests/OnFlushCallbackTest.cpp b/tests/OnFlushCallbackTest.cpp
index 8fb8a38d75..706ce7a9d9 100644
--- a/tests/OnFlushCallbackTest.cpp
+++ b/tests/OnFlushCallbackTest.cpp
@@ -442,6 +442,7 @@ static sk_sp<GrTextureProxy> make_upstream_image(GrContext* context, AtlasObject
AtlasedRectOp* sparePtr = op.get();
uint32_t opListID = rtc->priv().testingOnly_addDrawOp(std::move(op));
+ SkASSERT(SK_InvalidUniqueID != opListID);
object->addOp(opListID, sparePtr);
}