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>
This commit is contained in:
parent
d64756e66e
commit
dc83b892a0
@ -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
|
||||
}
|
||||
|
||||
|
@ -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; }
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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(),
|
||||
|
@ -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?
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
int fMaxOpCombineLookahead = -1;
|
||||
};
|
||||
|
||||
GrRenderTargetOpList(GrRenderTargetProxy*, GrGpu*, GrResourceProvider*,
|
||||
GrRenderTargetOpList(sk_sp<GrRenderTargetProxy>, GrGpu*, GrResourceProvider*,
|
||||
GrAuditTrail*, const Options&);
|
||||
|
||||
~GrRenderTargetOpList() override;
|
||||
|
@ -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?
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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)) {
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ struct SkIRect;
|
||||
|
||||
class GrTextureOpList final : public GrOpList {
|
||||
public:
|
||||
GrTextureOpList(GrTextureProxy*, GrGpu*, GrAuditTrail*);
|
||||
GrTextureOpList(sk_sp<GrTextureProxy>, GrGpu*, GrAuditTrail*);
|
||||
|
||||
~GrTextureOpList() override;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user