diff options
author | Robert Phillips <robertphillips@google.com> | 2017-04-13 12:23:54 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-04-14 15:55:47 +0000 |
commit | dc83b892a0ae431c5fe123a7e6873d63264bd64c (patch) | |
tree | 9f266166998488a7661a674ea1131bf0f7603979 | |
parent | d64756e66e65f1a8ec500819d22bbdd1c96fa28d (diff) |
sk_sp-ify opList creation & storage
Change-Id: Idd4d81cd248ad2b2169028ac2e269a66c9cad26b
Reviewed-on: https://skia-review.googlesource.com/13400
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
-rw-r--r-- | src/gpu/GrDrawingManager.cpp | 15 | ||||
-rw-r--r-- | src/gpu/GrDrawingManager.h | 4 | ||||
-rw-r--r-- | src/gpu/GrOpList.cpp | 13 | ||||
-rw-r--r-- | src/gpu/GrOpList.h | 10 | ||||
-rw-r--r-- | src/gpu/GrPreFlushResourceProvider.cpp | 9 | ||||
-rw-r--r-- | src/gpu/GrRenderTargetContext.cpp | 9 | ||||
-rw-r--r-- | src/gpu/GrRenderTargetContext.h | 2 | ||||
-rw-r--r-- | src/gpu/GrRenderTargetOpList.cpp | 5 | ||||
-rw-r--r-- | src/gpu/GrRenderTargetOpList.h | 2 | ||||
-rw-r--r-- | src/gpu/GrTextureContext.cpp | 9 | ||||
-rw-r--r-- | src/gpu/GrTextureContext.h | 2 | ||||
-rw-r--r-- | src/gpu/GrTextureOpList.cpp | 4 | ||||
-rw-r--r-- | src/gpu/GrTextureOpList.h | 2 |
13 files changed, 44 insertions, 42 deletions
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp index b64b9ee23a..cecf52f329 100644 --- a/src/gpu/GrDrawingManager.cpp +++ b/src/gpu/GrDrawingManager.cpp @@ -197,7 +197,7 @@ void GrDrawingManager::addPreFlushCallbackObject(sk_sp<GrPreFlushCallbackObject> fPreFlushCBObjects.push_back(preFlushCBObject); } -GrRenderTargetOpList* GrDrawingManager::newOpList(GrRenderTargetProxy* rtp) { +sk_sp<GrRenderTargetOpList> GrDrawingManager::newRTOpList(sk_sp<GrRenderTargetProxy> rtp) { SkASSERT(fContext); #ifndef ENABLE_MDB @@ -210,7 +210,7 @@ GrRenderTargetOpList* GrDrawingManager::newOpList(GrRenderTargetProxy* rtp) { // DrawingManager gets the creation ref - this ref is for the caller // TODO: although this is true right now it isn't cool - return SkRef((GrRenderTargetOpList*) fOpLists[0]); + return sk_ref_sp((GrRenderTargetOpList*) fOpLists[0]); } #endif @@ -219,18 +219,19 @@ GrRenderTargetOpList* GrDrawingManager::newOpList(GrRenderTargetProxy* rtp) { fContext->resourceProvider(), fContext->getAuditTrail(), fOptionsForOpLists); + SkASSERT(rtp->getLastOpList() == opList); *fOpLists.append() = opList; // DrawingManager gets the creation ref - this ref is for the caller - return SkRef(opList); + return sk_ref_sp(opList); } -GrTextureOpList* GrDrawingManager::newOpList(GrTextureProxy* textureProxy) { +sk_sp<GrTextureOpList> GrDrawingManager::newTextureOpList(sk_sp<GrTextureProxy> textureProxy) { SkASSERT(fContext); - GrTextureOpList* opList = new GrTextureOpList(textureProxy, fContext->getGpu(), - fContext->getAuditTrail()); + sk_sp<GrTextureOpList> opList(new GrTextureOpList(std::move(textureProxy), fContext->getGpu(), + fContext->getAuditTrail())); #ifndef ENABLE_MDB // When MDB is disabled we still create a new GrOpList, but don't store or ref it - we rely @@ -240,7 +241,7 @@ GrTextureOpList* GrDrawingManager::newOpList(GrTextureProxy* textureProxy) { *fOpLists.append() = opList; // Drawing manager gets the creation ref - this ref is for the caller - return SkRef(opList); + return opList; #endif } diff --git a/src/gpu/GrDrawingManager.h b/src/gpu/GrDrawingManager.h index f30273f7f1..ac6bbb45f2 100644 --- a/src/gpu/GrDrawingManager.h +++ b/src/gpu/GrDrawingManager.h @@ -44,8 +44,8 @@ public: // The caller automatically gets a ref on the returned opList. It must // be balanced by an unref call. - GrRenderTargetOpList* newOpList(GrRenderTargetProxy* rtp); - GrTextureOpList* newOpList(GrTextureProxy* textureProxy); + sk_sp<GrRenderTargetOpList> newRTOpList(sk_sp<GrRenderTargetProxy> rtp); + sk_sp<GrTextureOpList> newTextureOpList(sk_sp<GrTextureProxy> textureProxy); GrContext* getContext() { return fContext; } diff --git a/src/gpu/GrOpList.cpp b/src/gpu/GrOpList.cpp index 1f90f431a5..28b972df99 100644 --- a/src/gpu/GrOpList.cpp +++ b/src/gpu/GrOpList.cpp @@ -21,12 +21,13 @@ uint32_t GrOpList::CreateUniqueID() { return id; } -GrOpList::GrOpList(GrSurfaceProxy* surfaceProxy, GrAuditTrail* auditTrail) - : fUniqueID(CreateUniqueID()) - , fFlags(0) - , fTarget(surfaceProxy) - , fAuditTrail(auditTrail) { - +GrOpList::GrOpList(sk_sp<GrSurfaceProxy> surfaceProxy, GrAuditTrail* auditTrail) + // MDB TODO: in the future opLists will own the GrSurfaceProxy they target. + // For now, preserve the status quo. + : fTarget(surfaceProxy.get()) + , fAuditTrail(auditTrail) + , fUniqueID(CreateUniqueID()) + , fFlags(0) { surfaceProxy->setLastOpList(this); } diff --git a/src/gpu/GrOpList.h b/src/gpu/GrOpList.h index 557126681a..0139b6b4d3 100644 --- a/src/gpu/GrOpList.h +++ b/src/gpu/GrOpList.h @@ -22,7 +22,7 @@ class GrTextureOpList; class GrOpList : public SkRefCnt { public: - GrOpList(GrSurfaceProxy* surfaceProxy, GrAuditTrail* auditTrail); + GrOpList(sk_sp<GrSurfaceProxy> surfaceProxy, GrAuditTrail* auditTrail); ~GrOpList() override; // These two methods are invoked as flush time @@ -80,6 +80,10 @@ public: */ SkDEBUGCODE(virtual void dump() const;) +protected: + GrSurfaceProxy* fTarget; + GrAuditTrail* fAuditTrail; + private: friend class GrDrawingManager; // for resetFlag & TopoSortTraits @@ -132,14 +136,10 @@ private: uint32_t fUniqueID; uint32_t fFlags; - GrSurfaceProxy* fTarget; // 'this' GrOpList relies on the output of the GrOpLists in 'fDependencies' SkTDArray<GrOpList*> fDependencies; -protected: - GrAuditTrail* fAuditTrail; - typedef SkRefCnt INHERITED; }; diff --git a/src/gpu/GrPreFlushResourceProvider.cpp b/src/gpu/GrPreFlushResourceProvider.cpp index 7a105604e0..3c6ddc4ab7 100644 --- a/src/gpu/GrPreFlushResourceProvider.cpp +++ b/src/gpu/GrPreFlushResourceProvider.cpp @@ -30,8 +30,10 @@ sk_sp<GrRenderTargetContext> GrPreFlushResourceProvider::makeRenderTargetContext return nullptr; } + // MDB TODO: This explicit resource creation is required in the pre-MDB world so that the + // pre-Flush ops are placed in their own opList. sk_sp<GrRenderTargetOpList> opList(new GrRenderTargetOpList( - proxy->asRenderTargetProxy(), + sk_ref_sp(proxy->asRenderTargetProxy()), fDrawingMgr->fContext->getGpu(), fDrawingMgr->fContext->resourceProvider(), fDrawingMgr->fContext->getAuditTrail(), @@ -58,9 +60,10 @@ sk_sp<GrRenderTargetContext> GrPreFlushResourceProvider::makeRenderTargetContext sk_sp<GrSurfaceProxy> proxy, sk_sp<SkColorSpace> colorSpace, const SkSurfaceProps* props) { - + // MDB TODO: This explicit resource creation is required in the pre-MDB world so that the + // pre-Flush ops are placed in their own opList. sk_sp<GrRenderTargetOpList> opList(new GrRenderTargetOpList( - proxy->asRenderTargetProxy(), + sk_ref_sp(proxy->asRenderTargetProxy()), fDrawingMgr->fContext->getGpu(), fDrawingMgr->fContext->resourceProvider(), fDrawingMgr->fContext->getAuditTrail(), diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp index 40ccbeaa21..8ad9a4e633 100644 --- a/src/gpu/GrRenderTargetContext.cpp +++ b/src/gpu/GrRenderTargetContext.cpp @@ -82,7 +82,7 @@ GrRenderTargetContext::GrRenderTargetContext(GrContext* context, GrSingleOwner* singleOwner) : GrSurfaceContext(context, drawingMgr, std::move(colorSpace), auditTrail, singleOwner) , fRenderTargetProxy(std::move(rtp)) - , fOpList(SkSafeRef(fRenderTargetProxy->getLastRenderTargetOpList())) + , fOpList(sk_ref_sp(fRenderTargetProxy->getLastRenderTargetOpList())) , fInstancedPipelineInfo(fRenderTargetProxy.get()) , fColorXformFromSRGB(nullptr) , fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps)) { @@ -100,14 +100,13 @@ void GrRenderTargetContext::validate() const { fRenderTargetProxy->validate(fContext); if (fOpList && !fOpList->isClosed()) { - SkASSERT(fRenderTargetProxy->getLastOpList() == fOpList); + SkASSERT(fRenderTargetProxy->getLastOpList() == fOpList.get()); } } #endif GrRenderTargetContext::~GrRenderTargetContext() { ASSERT_SINGLE_OWNER - SkSafeUnref(fOpList); } GrTextureProxy* GrRenderTargetContext::asTextureProxy() { @@ -123,10 +122,10 @@ GrRenderTargetOpList* GrRenderTargetContext::getOpList() { SkDEBUGCODE(this->validate();) if (!fOpList || fOpList->isClosed()) { - fOpList = this->drawingManager()->newOpList(fRenderTargetProxy.get()); + fOpList = this->drawingManager()->newRTOpList(fRenderTargetProxy); } - return fOpList; + return fOpList.get(); } // TODO: move this (and GrTextContext::copy) to GrSurfaceContext? diff --git a/src/gpu/GrRenderTargetContext.h b/src/gpu/GrRenderTargetContext.h index 1d1f9ecd18..dd42db6156 100644 --- a/src/gpu/GrRenderTargetContext.h +++ b/src/gpu/GrRenderTargetContext.h @@ -479,7 +479,7 @@ private: // In MDB-mode the GrOpList can be closed by some other renderTargetContext that has picked // it up. For this reason, the GrOpList should only ever be accessed via 'getOpList'. - GrRenderTargetOpList* fOpList; + sk_sp<GrRenderTargetOpList> fOpList; GrInstancedPipelineInfo fInstancedPipelineInfo; sk_sp<GrColorSpaceXform> fColorXformFromSRGB; diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp index 3d38c99eb8..5730e2e7ad 100644 --- a/src/gpu/GrRenderTargetOpList.cpp +++ b/src/gpu/GrRenderTargetOpList.cpp @@ -25,16 +25,15 @@ using gr_instanced::InstancedRendering; static const int kDefaultMaxOpLookback = 10; static const int kDefaultMaxOpLookahead = 10; -GrRenderTargetOpList::GrRenderTargetOpList(GrRenderTargetProxy* rtp, GrGpu* gpu, +GrRenderTargetOpList::GrRenderTargetOpList(sk_sp<GrRenderTargetProxy> proxy, GrGpu* gpu, GrResourceProvider* resourceProvider, GrAuditTrail* auditTrail, const Options& options) - : INHERITED(rtp, auditTrail) + : INHERITED(std::move(proxy), auditTrail) , fGpu(SkRef(gpu)) , fResourceProvider(resourceProvider) , fLastClipStackGenID(SK_InvalidUniqueID) , fClipAllocator(fClipAllocatorStorage, sizeof(fClipAllocatorStorage), sizeof(fClipAllocatorStorage)) { - fMaxOpLookback = (options.fMaxOpCombineLookback < 0) ? kDefaultMaxOpLookback : options.fMaxOpCombineLookback; fMaxOpLookahead = (options.fMaxOpCombineLookahead < 0) ? kDefaultMaxOpLookahead diff --git a/src/gpu/GrRenderTargetOpList.h b/src/gpu/GrRenderTargetOpList.h index cd08559a77..1b6f0865b0 100644 --- a/src/gpu/GrRenderTargetOpList.h +++ b/src/gpu/GrRenderTargetOpList.h @@ -39,7 +39,7 @@ public: int fMaxOpCombineLookahead = -1; }; - GrRenderTargetOpList(GrRenderTargetProxy*, GrGpu*, GrResourceProvider*, + GrRenderTargetOpList(sk_sp<GrRenderTargetProxy>, GrGpu*, GrResourceProvider*, GrAuditTrail*, const Options&); ~GrRenderTargetOpList() override; diff --git a/src/gpu/GrTextureContext.cpp b/src/gpu/GrTextureContext.cpp index 76b7588e39..68e94f9be3 100644 --- a/src/gpu/GrTextureContext.cpp +++ b/src/gpu/GrTextureContext.cpp @@ -26,7 +26,7 @@ GrTextureContext::GrTextureContext(GrContext* context, GrSingleOwner* singleOwner) : GrSurfaceContext(context, drawingMgr, std::move(colorSpace), auditTrail, singleOwner) , fTextureProxy(std::move(textureProxy)) - , fOpList(SkSafeRef(fTextureProxy->getLastTextureOpList())) { + , fOpList(sk_ref_sp(fTextureProxy->getLastTextureOpList())) { SkDEBUGCODE(this->validate();) } @@ -36,14 +36,13 @@ void GrTextureContext::validate() const { fTextureProxy->validate(fContext); if (fOpList && !fOpList->isClosed()) { - SkASSERT(fTextureProxy->getLastOpList() == fOpList); + SkASSERT(fTextureProxy->getLastOpList() == fOpList.get()); } } #endif GrTextureContext::~GrTextureContext() { ASSERT_SINGLE_OWNER - SkSafeUnref(fOpList); } GrRenderTargetProxy* GrTextureContext::asRenderTargetProxy() { @@ -63,10 +62,10 @@ GrTextureOpList* GrTextureContext::getOpList() { SkDEBUGCODE(this->validate();) if (!fOpList || fOpList->isClosed()) { - fOpList = this->drawingManager()->newOpList(fTextureProxy.get()); + fOpList = this->drawingManager()->newTextureOpList(fTextureProxy); } - return fOpList; + return fOpList.get(); } // TODO: move this (and GrRenderTargetContext::copy) to GrSurfaceContext? diff --git a/src/gpu/GrTextureContext.h b/src/gpu/GrTextureContext.h index 995ebf53d2..4cde61b883 100644 --- a/src/gpu/GrTextureContext.h +++ b/src/gpu/GrTextureContext.h @@ -54,7 +54,7 @@ private: // In MDB-mode the GrOpList can be closed by some other renderTargetContext that has picked // it up. For this reason, the GrOpList should only ever be accessed via 'getOpList'. - GrTextureOpList* fOpList; + sk_sp<GrTextureOpList> fOpList; typedef GrSurfaceContext INHERITED; }; diff --git a/src/gpu/GrTextureOpList.cpp b/src/gpu/GrTextureOpList.cpp index d2d922643a..d4becad579 100644 --- a/src/gpu/GrTextureOpList.cpp +++ b/src/gpu/GrTextureOpList.cpp @@ -15,8 +15,8 @@ //////////////////////////////////////////////////////////////////////////////// -GrTextureOpList::GrTextureOpList(GrTextureProxy* tex, GrGpu* gpu, GrAuditTrail* auditTrail) - : INHERITED(tex, auditTrail) +GrTextureOpList::GrTextureOpList(sk_sp<GrTextureProxy> proxy, GrGpu* gpu, GrAuditTrail* auditTrail) + : INHERITED(std::move(proxy), auditTrail) , fGpu(SkRef(gpu)) { } diff --git a/src/gpu/GrTextureOpList.h b/src/gpu/GrTextureOpList.h index 22828fd936..ca5bda44f6 100644 --- a/src/gpu/GrTextureOpList.h +++ b/src/gpu/GrTextureOpList.h @@ -23,7 +23,7 @@ struct SkIRect; class GrTextureOpList final : public GrOpList { public: - GrTextureOpList(GrTextureProxy*, GrGpu*, GrAuditTrail*); + GrTextureOpList(sk_sp<GrTextureProxy>, GrGpu*, GrAuditTrail*); ~GrTextureOpList() override; |