fPreFlushCBObjects.push_back(preFlushCBObject);
}
-GrRenderTargetOpList* GrDrawingManager::newOpList(GrRenderTargetProxy* rtp) {
+sk_sp<GrRenderTargetOpList> GrDrawingManager::newRTOpList(sk_sp<GrRenderTargetProxy> rtp) {
SkASSERT(fContext);
#ifndef ENABLE_MDB
// 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
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
*fOpLists.append() = opList;
// Drawing manager gets the creation ref - this ref is for the caller
- return SkRef(opList);
+ return opList;
#endif
}
// 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; }
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);
}
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
*/
SkDEBUGCODE(virtual void dump() const;)
+protected:
+ GrSurfaceProxy* fTarget;
+ GrAuditTrail* fAuditTrail;
+
private:
friend class GrDrawingManager; // for resetFlag & TopoSortTraits
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;
};
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(),
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(),
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)) {
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() {
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?
// 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;
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
int fMaxOpCombineLookahead = -1;
};
- GrRenderTargetOpList(GrRenderTargetProxy*, GrGpu*, GrResourceProvider*,
+ GrRenderTargetOpList(sk_sp<GrRenderTargetProxy>, GrGpu*, GrResourceProvider*,
GrAuditTrail*, const Options&);
~GrRenderTargetOpList() override;
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();)
}
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() {
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?
// 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;
};
////////////////////////////////////////////////////////////////////////////////
-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)) {
}
class GrTextureOpList final : public GrOpList {
public:
- GrTextureOpList(GrTextureProxy*, GrGpu*, GrAuditTrail*);
+ GrTextureOpList(sk_sp<GrTextureProxy>, GrGpu*, GrAuditTrail*);
~GrTextureOpList() override;