Add a unique ID to GrOpLists and return it from GrRenderTargetContext::addDrawOp
This is to support the preFlush callbacks Change-Id: I8513ea08b6516681566eceafa789b2ee7925ebce Reviewed-on: https://skia-review.googlesource.com/9199 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
fd171ede0c
commit
c013892711
@ -11,17 +11,23 @@
|
||||
#include "GrSurface.h"
|
||||
#include "GrSurfaceProxy.h"
|
||||
|
||||
GrOpList::GrOpList(GrSurfaceProxy* surfaceProxy, GrAuditTrail* auditTrail)
|
||||
: fFlags(0)
|
||||
uint32_t GrOpList::CreateUniqueID() {
|
||||
static int32_t gUniqueID = SK_InvalidUniqueID;
|
||||
uint32_t id;
|
||||
// Loop in case our global wraps around, as we never want to return a 0.
|
||||
do {
|
||||
id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1);
|
||||
} while (id == SK_InvalidUniqueID);
|
||||
return id;
|
||||
}
|
||||
|
||||
GrOpList::GrOpList(GrSurfaceProxy* surfaceProxy, GrAuditTrail* auditTrail)
|
||||
: fUniqueID(CreateUniqueID())
|
||||
, fFlags(0)
|
||||
, fTarget(surfaceProxy)
|
||||
, fAuditTrail(auditTrail) {
|
||||
|
||||
surfaceProxy->setLastOpList(this);
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
static int debugID = 0;
|
||||
fDebugID = debugID++;
|
||||
#endif
|
||||
}
|
||||
|
||||
GrOpList::~GrOpList() {
|
||||
@ -62,10 +68,10 @@ void GrOpList::addDependency(GrSurface* dependedOn) {
|
||||
#ifdef SK_DEBUG
|
||||
void GrOpList::dump() const {
|
||||
SkDebugf("--------------------------------------------------------------\n");
|
||||
SkDebugf("node: %d -> RT: %d\n", fDebugID, fTarget ? fTarget->uniqueID().asUInt() : -1);
|
||||
SkDebugf("node: %d -> RT: %d\n", fUniqueID, fTarget ? fTarget->uniqueID().asUInt() : -1);
|
||||
SkDebugf("relies On (%d): ", fDependencies.count());
|
||||
for (int i = 0; i < fDependencies.count(); ++i) {
|
||||
SkDebugf("%d, ", fDependencies[i]->fDebugID);
|
||||
SkDebugf("%d, ", fDependencies[i]->fUniqueID);
|
||||
}
|
||||
SkDebugf("\n");
|
||||
}
|
||||
|
@ -73,6 +73,8 @@ public:
|
||||
*/
|
||||
virtual GrRenderTargetOpList* asRenderTargetOpList() { return nullptr; }
|
||||
|
||||
int32_t uniqueID() const { return fUniqueID; }
|
||||
|
||||
/*
|
||||
* Dump out the GrOpList dependency DAG
|
||||
*/
|
||||
@ -81,6 +83,8 @@ public:
|
||||
private:
|
||||
friend class GrDrawingManager; // for resetFlag & TopoSortTraits
|
||||
|
||||
static uint32_t CreateUniqueID();
|
||||
|
||||
enum Flags {
|
||||
kClosed_Flag = 0x01, //!< This GrOpList can't accept any more ops
|
||||
|
||||
@ -126,15 +130,15 @@ private:
|
||||
|
||||
void addDependency(GrOpList* dependedOn);
|
||||
|
||||
SkDEBUGCODE(int fDebugID;)
|
||||
uint32_t fFlags;
|
||||
GrSurfaceProxy* fTarget;
|
||||
uint32_t fUniqueID;
|
||||
uint32_t fFlags;
|
||||
GrSurfaceProxy* fTarget;
|
||||
|
||||
// 'this' GrOpList relies on the output of the GrOpLists in 'fDependencies'
|
||||
SkTDArray<GrOpList*> fDependencies;
|
||||
SkTDArray<GrOpList*> fDependencies;
|
||||
|
||||
protected:
|
||||
GrAuditTrail* fAuditTrail;
|
||||
GrAuditTrail* fAuditTrail;
|
||||
|
||||
typedef SkRefCnt INHERITED;
|
||||
};
|
||||
|
@ -1673,10 +1673,13 @@ static void op_bounds(SkRect* bounds, const GrOp* op) {
|
||||
}
|
||||
}
|
||||
|
||||
void GrRenderTargetContext::addDrawOp(const GrPipelineBuilder& pipelineBuilder, const GrClip& clip,
|
||||
std::unique_ptr<GrDrawOp> op) {
|
||||
uint32_t GrRenderTargetContext::addDrawOp(const GrPipelineBuilder& pipelineBuilder,
|
||||
const GrClip& clip,
|
||||
std::unique_ptr<GrDrawOp> op) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
RETURN_IF_ABANDONED
|
||||
if (this->drawingManager()->wasAbandoned()) {
|
||||
return SK_InvalidUniqueID;
|
||||
}
|
||||
SkDEBUGCODE(this->validate();)
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrRenderTargetContext::addDrawOp");
|
||||
|
||||
@ -1686,21 +1689,21 @@ void GrRenderTargetContext::addDrawOp(const GrPipelineBuilder& pipelineBuilder,
|
||||
GrAppliedClip appliedClip(bounds);
|
||||
if (!clip.apply(fContext, this, pipelineBuilder.isHWAntialias(),
|
||||
pipelineBuilder.hasUserStencilSettings(), &appliedClip)) {
|
||||
return;
|
||||
return SK_InvalidUniqueID;
|
||||
}
|
||||
|
||||
// This forces instantiation of the render target. Pipeline creation is moving to flush time
|
||||
// by which point instantiation must have occurred anyway.
|
||||
GrRenderTarget* rt = this->accessRenderTarget();
|
||||
if (!rt) {
|
||||
return;
|
||||
return SK_InvalidUniqueID;
|
||||
}
|
||||
|
||||
GrResourceProvider* resourceProvider = fContext->resourceProvider();
|
||||
if (pipelineBuilder.hasUserStencilSettings() || appliedClip.hasStencilClip()) {
|
||||
if (!resourceProvider->attachStencilAttachment(this->accessRenderTarget())) {
|
||||
SkDebugf("ERROR creating stencil attachment. Draw skipped.\n");
|
||||
return;
|
||||
return SK_InvalidUniqueID;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1717,13 +1720,13 @@ void GrRenderTargetContext::addDrawOp(const GrPipelineBuilder& pipelineBuilder,
|
||||
if (pipelineBuilder.willXPNeedDstTexture(*this->caps(), analysis)) {
|
||||
this->setupDstTexture(rt, clip, bounds, &args.fDstTexture);
|
||||
if (!args.fDstTexture.texture()) {
|
||||
return;
|
||||
return SK_InvalidUniqueID;
|
||||
}
|
||||
}
|
||||
op->initPipeline(args);
|
||||
// TODO: We need to add pipeline dependencies on textures, etc before recording this op.
|
||||
op->setClippedBounds(appliedClip.clippedDrawBounds());
|
||||
this->getOpList()->addOp(std::move(op), this);
|
||||
return this->getOpList()->addOp(std::move(op), this);
|
||||
}
|
||||
|
||||
void GrRenderTargetContext::setupDstTexture(GrRenderTarget* rt, const GrClip& clip,
|
||||
|
@ -473,8 +473,9 @@ private:
|
||||
size_t srcRowBytes, int x, int y, uint32_t flags) override;
|
||||
|
||||
// This performs processing specific to GrDrawOp-derived ops before recording them into the
|
||||
// op list.
|
||||
void addDrawOp(const GrPipelineBuilder&, const GrClip&, std::unique_ptr<GrDrawOp>);
|
||||
// op list. It returns the id of the opList to which the op was added, or 0, if it was
|
||||
// dropped (e.g., due to clipping).
|
||||
uint32_t addDrawOp(const GrPipelineBuilder&, const GrClip&, std::unique_ptr<GrDrawOp>);
|
||||
|
||||
// Makes a copy of the dst if it is necessary for the draw and returns the texture that should
|
||||
// be used by GrXferProcessor to access the destination color. If the texture is nullptr then
|
||||
|
@ -108,11 +108,11 @@ public:
|
||||
return fRenderTargetContext->fRenderTargetProxy->uniqueID();
|
||||
}
|
||||
|
||||
void testingOnly_addDrawOp(GrPaint&&,
|
||||
GrAAType,
|
||||
std::unique_ptr<GrDrawOp>,
|
||||
const GrUserStencilSettings* = nullptr,
|
||||
bool snapToCenters = false);
|
||||
uint32_t testingOnly_addDrawOp(GrPaint&&,
|
||||
GrAAType,
|
||||
std::unique_ptr<GrDrawOp>,
|
||||
const GrUserStencilSettings* = nullptr,
|
||||
bool snapToCenters = false);
|
||||
|
||||
bool refsWrappedObjects() const {
|
||||
return fRenderTargetContext->fRenderTargetProxy->refsWrappedObjects();
|
||||
|
@ -67,8 +67,9 @@ public:
|
||||
*/
|
||||
const GrCaps* caps() const { return fGpu->caps(); }
|
||||
|
||||
void addOp(std::unique_ptr<GrOp> op, GrRenderTargetContext* renderTargetContext) {
|
||||
uint32_t addOp(std::unique_ptr<GrOp> op, GrRenderTargetContext* renderTargetContext) {
|
||||
this->recordOp(std::move(op), renderTargetContext);
|
||||
return this->uniqueID();
|
||||
}
|
||||
|
||||
/** Clears the entire render target */
|
||||
|
@ -233,15 +233,16 @@ int GrResourceCache::countUniqueKeysWithTag(const char* tag) const {
|
||||
|
||||
#define ASSERT_SINGLE_OWNER \
|
||||
SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fRenderTargetContext->fSingleOwner);)
|
||||
#define RETURN_IF_ABANDONED if (fRenderTargetContext->drawingManager()->wasAbandoned()) { return; }
|
||||
|
||||
void GrRenderTargetContextPriv::testingOnly_addDrawOp(GrPaint&& paint,
|
||||
GrAAType aaType,
|
||||
std::unique_ptr<GrDrawOp> op,
|
||||
const GrUserStencilSettings* uss,
|
||||
bool snapToCenters) {
|
||||
uint32_t GrRenderTargetContextPriv::testingOnly_addDrawOp(GrPaint&& paint,
|
||||
GrAAType aaType,
|
||||
std::unique_ptr<GrDrawOp> op,
|
||||
const GrUserStencilSettings* uss,
|
||||
bool snapToCenters) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
RETURN_IF_ABANDONED
|
||||
if (fRenderTargetContext->drawingManager()->wasAbandoned()) {
|
||||
return SK_InvalidUniqueID;
|
||||
}
|
||||
SkDEBUGCODE(fRenderTargetContext->validate();)
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(fRenderTargetContext->fAuditTrail,
|
||||
"GrRenderTargetContext::testingOnly_addDrawOp");
|
||||
@ -252,11 +253,10 @@ void GrRenderTargetContextPriv::testingOnly_addDrawOp(GrPaint&& paint,
|
||||
}
|
||||
pipelineBuilder.setSnapVerticesToPixelCenters(snapToCenters);
|
||||
|
||||
fRenderTargetContext->addDrawOp(pipelineBuilder, GrNoClip(), std::move(op));
|
||||
return fRenderTargetContext->addDrawOp(pipelineBuilder, GrNoClip(), std::move(op));
|
||||
}
|
||||
|
||||
#undef ASSERT_SINGLE_OWNER
|
||||
#undef RETURN_IF_ABANDONED
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user