Rename GrDrawingMgr::abandon to wasAbandoned & add a matching entry point to GrDrawingContext

Since GrDrawingContext is generally replacing GrRenderTarget, this is to provide functionality similar to GrRenderTarget::wasDestroyed.

This is split out of https://codereview.chromium.org/1930013002/ ((Mostly) Retract GrRenderTarget from SkGpuDevice)

GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1979913002

Review-Url: https://codereview.chromium.org/1979913002
This commit is contained in:
robertphillips 2016-05-16 09:14:53 -07:00 committed by Commit bot
parent d584d46c99
commit 7761d61876
7 changed files with 19 additions and 13 deletions

View File

@ -264,6 +264,8 @@ public:
int numColorSamples() const { return fRenderTarget->numColorSamples(); }
bool isGammaCorrect() const { return fSurfaceProps.isGammaCorrect(); }
bool wasAbandoned() const;
GrRenderTarget* accessRenderTarget() { return fRenderTarget.get(); }
sk_sp<GrRenderTarget> renderTarget() { return fRenderTarget; }

View File

@ -26,9 +26,9 @@
#define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this)
#define ASSERT_SINGLE_OWNER \
SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(&fSingleOwner);)
#define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; }
#define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return false; }
#define RETURN_NULL_IF_ABANDONED if (fDrawingManager->abandoned()) { return nullptr; }
#define RETURN_IF_ABANDONED if (fDrawingManager->wasAbandoned()) { return; }
#define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->wasAbandoned()) { return false; }
#define RETURN_NULL_IF_ABANDONED if (fDrawingManager->wasAbandoned()) { return nullptr; }
////////////////////////////////////////////////////////////////////////////////
@ -686,7 +686,7 @@ sk_sp<GrDrawContext> GrContext::newDrawContext(SkBackingFit fit,
bool GrContext::abandoned() const {
ASSERT_SINGLE_OWNER
return fDrawingManager->abandoned();
return fDrawingManager->wasAbandoned();
}
namespace {

View File

@ -35,10 +35,10 @@
SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fSingleOwner);)
#define ASSERT_SINGLE_OWNER_PRIV \
SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fDrawContext->fSingleOwner);)
#define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; }
#define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return false; }
#define RETURN_FALSE_IF_ABANDONED_PRIV if (fDrawContext->fDrawingManager->abandoned()) { return false; }
#define RETURN_NULL_IF_ABANDONED if (fDrawingManager->abandoned()) { return nullptr; }
#define RETURN_IF_ABANDONED if (fDrawingManager->wasAbandoned()) { return; }
#define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->wasAbandoned()) { return false; }
#define RETURN_FALSE_IF_ABANDONED_PRIV if (fDrawContext->fDrawingManager->wasAbandoned()) { return false; }
#define RETURN_NULL_IF_ABANDONED if (fDrawingManager->wasAbandoned()) { return nullptr; }
class AutoCheckFlush {
public:
@ -51,6 +51,10 @@ private:
GrDrawingManager* fDrawingManager;
};
bool GrDrawContext::wasAbandoned() const {
return fDrawingManager->wasAbandoned();
}
// In MDB mode the reffing of the 'getLastDrawTarget' call's result allows in-progress
// drawTargets to be picked up and added to by drawContexts lower in the call
// stack. When this occurs with a closed drawTarget, a new one will be allocated

View File

@ -58,7 +58,7 @@ void GrDrawingManager::reset() {
}
void GrDrawingManager::flush() {
if (fFlushing || this->abandoned()) {
if (fFlushing || this->wasAbandoned()) {
return;
}
fFlushing = true;
@ -161,7 +161,7 @@ GrPathRenderer* GrDrawingManager::getPathRenderer(const GrPathRenderer::CanDrawP
sk_sp<GrDrawContext> GrDrawingManager::drawContext(sk_sp<GrRenderTarget> rt,
const SkSurfaceProps* surfaceProps) {
if (this->abandoned()) {
if (this->wasAbandoned()) {
return nullptr;
}

View File

@ -28,7 +28,7 @@ class GrDrawingManager {
public:
~GrDrawingManager();
bool abandoned() const { return fAbandoned; }
bool wasAbandoned() const { return fAbandoned; }
void freeGpuResources();
sk_sp<GrDrawContext> drawContext(sk_sp<GrRenderTarget> rt, const SkSurfaceProps*);

View File

@ -13,7 +13,7 @@
#define ASSERT_SINGLE_OWNER \
SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(this->singleOwner());)
#define RETURN_IF_ABANDONED if (this->drawingManager()->abandoned()) { return; }
#define RETURN_IF_ABANDONED if (this->drawingManager()->wasAbandoned()) { return; }
void GrPathRenderingDrawContext::drawText(const GrClip& clip, const GrPaint& grPaint,
const SkPaint& skPaint,

View File

@ -249,7 +249,7 @@ void GrResourceCache::changeTimestamp(uint32_t newTimestamp) { fTimestamp = newT
#define ASSERT_SINGLE_OWNER \
SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fDrawContext->fSingleOwner);)
#define RETURN_IF_ABANDONED if (fDrawContext->fDrawingManager->abandoned()) { return; }
#define RETURN_IF_ABANDONED if (fDrawContext->fDrawingManager->wasAbandoned()) { return; }
void GrDrawContextPriv::testingOnly_drawBatch(const GrPipelineBuilder& pipelineBuilder,
GrDrawBatch* batch,