diff options
Diffstat (limited to 'src/gpu/GrRenderTargetOpList.cpp')
-rw-r--r-- | src/gpu/GrRenderTargetOpList.cpp | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp index a7e109d5e8..3abc21c131 100644 --- a/src/gpu/GrRenderTargetOpList.cpp +++ b/src/gpu/GrRenderTargetOpList.cpp @@ -26,21 +26,17 @@ static const int kMaxOpLookback = 10; static const int kMaxOpLookahead = 10; GrRenderTargetOpList::GrRenderTargetOpList(sk_sp<GrRenderTargetProxy> proxy, GrGpu* gpu, - GrResourceProvider* resourceProvider, GrAuditTrail* auditTrail) : INHERITED(std::move(proxy), auditTrail) - , fGpu(SkRef(gpu)) - , fResourceProvider(resourceProvider) , fLastClipStackGenID(SK_InvalidUniqueID) , fClipAllocator(fClipAllocatorStorage, sizeof(fClipAllocatorStorage), sizeof(fClipAllocatorStorage)) { - if (GrCaps::InstancedSupport::kNone != this->caps()->instancedSupport()) { - fInstancedRendering.reset(fGpu->createInstancedRendering()); + if (GrCaps::InstancedSupport::kNone != gpu->caps()->instancedSupport()) { + fInstancedRendering.reset(gpu->createInstancedRendering()); } } GrRenderTargetOpList::~GrRenderTargetOpList() { - fGpu->unref(); } //////////////////////////////////////////////////////////////////////////////// @@ -161,10 +157,10 @@ bool GrRenderTargetOpList::executeOps(GrOpFlushState* flushState) { finish_command_buffer(commandBuffer.get()); currentRenderTarget = fRecordedOps[i].fRenderTarget.get(); - commandBuffer = create_command_buffer(fGpu); + commandBuffer = create_command_buffer(flushState->gpu()); flushState->setCommandBuffer(commandBuffer.get()); } else if (!commandBuffer) { - commandBuffer = create_command_buffer(fGpu); + commandBuffer = create_command_buffer(flushState->gpu()); flushState->setCommandBuffer(commandBuffer.get()); } @@ -182,7 +178,7 @@ bool GrRenderTargetOpList::executeOps(GrOpFlushState* flushState) { finish_command_buffer(commandBuffer.get()); flushState->setCommandBuffer(nullptr); - fGpu->finishOpList(); + flushState->gpu()->finishOpList(); return true; } @@ -197,16 +193,14 @@ void GrRenderTargetOpList::reset() { } void GrRenderTargetOpList::abandonGpuResources() { - if (GrCaps::InstancedSupport::kNone != this->caps()->instancedSupport()) { - InstancedRendering* ir = this->instancedRendering(); - ir->resetGpuResources(InstancedRendering::ResetType::kAbandon); + if (fInstancedRendering) { + fInstancedRendering->resetGpuResources(InstancedRendering::ResetType::kAbandon); } } void GrRenderTargetOpList::freeGpuResources() { - if (GrCaps::InstancedSupport::kNone != this->caps()->instancedSupport()) { - InstancedRendering* ir = this->instancedRendering(); - ir->resetGpuResources(InstancedRendering::ResetType::kDestroy); + if (fInstancedRendering) { + fInstancedRendering->resetGpuResources(InstancedRendering::ResetType::kDestroy); } } @@ -278,7 +272,8 @@ static inline bool can_reorder(const SkRect& a, const SkRect& b) { bool GrRenderTargetOpList::combineIfPossible(const RecordedOp& a, GrOp* b, const GrAppliedClip* bClip, - const DstTexture* bDstTexture) { + const DstTexture* bDstTexture, + const GrCaps& caps) { if (a.fAppliedClip) { if (!bClip) { return false; @@ -296,7 +291,7 @@ bool GrRenderTargetOpList::combineIfPossible(const RecordedOp& a, GrOp* b, } else if (a.fDstTexture.texture()) { return false; } - return a.fOp->combineIfPossible(b, *this->caps()); + return a.fOp->combineIfPossible(b, caps); } GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op, @@ -309,6 +304,8 @@ GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op, return nullptr; } + const GrCaps* caps = renderTargetContext->caps(); + // A closed GrOpList should never receive new/more ops SkASSERT(!this->isClosed()); @@ -340,7 +337,7 @@ GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op, candidate.fOp->uniqueID()); break; } - if (this->combineIfPossible(candidate, op.get(), clip, dstTexture)) { + if (this->combineIfPossible(candidate, op.get(), clip, dstTexture, *caps)) { GrOP_INFO("\t\tBackward: Combining with (%s, opID: %u)\n", candidate.fOp->name(), candidate.fOp->uniqueID()); GrOP_INFO("\t\t\tBackward: Combined op info:\n"); @@ -375,7 +372,7 @@ GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op, return fRecordedOps.back().fOp.get(); } -void GrRenderTargetOpList::forwardCombine() { +void GrRenderTargetOpList::forwardCombine(const GrCaps& caps) { SkASSERT(!this->isClosed()); for (int i = 0; i < fRecordedOps.count() - 1; ++i) { @@ -398,7 +395,7 @@ void GrRenderTargetOpList::forwardCombine() { break; } if (this->combineIfPossible(fRecordedOps[i], candidate.fOp.get(), - candidate.fAppliedClip, &candidate.fDstTexture)) { + candidate.fAppliedClip, &candidate.fDstTexture, caps)) { GrOP_INFO("\t\tForward: Combining with (%s, opID: %u)\n", candidate.fOp->name(), candidate.fOp->uniqueID()); GR_AUDIT_TRAIL_OPS_RESULT_COMBINED(fAuditTrail, op, candidate.fOp.get()); |