Re-enable explicit resource allocation in Skia (take 2)

Unsurprisingly, given how we're adding them to the opList's deferredProxy list, a proxy can appear twice.

Change-Id: I474357a1c3ee8cedf51dbeffcd0e0a96f396375c
Reviewed-on: https://skia-review.googlesource.com/103701
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Robert Phillips 2018-02-07 08:37:50 -05:00 committed by Skia Commit-Bot
parent 14962b7f13
commit ed858ec095
5 changed files with 16 additions and 11 deletions

View File

@ -69,6 +69,9 @@ protected:
}
fContext = SkAtlasTextContext::Make(fRenderer);
auto targetHandle = fRenderer->makeTargetHandle(kSize, kSize);
if (!targetHandle) {
return;
}
fTarget = SkAtlasTextTarget::Make(fContext, kSize, kSize, targetHandle);
fTypefaces[0] = sk_tool_utils::create_portable_typeface("serif", SkFontStyle::Italic());
@ -82,7 +85,7 @@ protected:
}
void onDraw(SkCanvas* canvas) override {
if (!fRenderer) {
if (!fRenderer || !fTarget || !fTarget->handle()) {
canvas->clear(SK_ColorRED);
return;
}

View File

@ -16,9 +16,9 @@
// Turn on/off the explicit distribution of GPU resources at flush time
#ifndef SK_DISABLE_EXPLICIT_GPU_RESOURCE_ALLOCATION
#define SK_DISABLE_EXPLICIT_GPU_RESOURCE_ALLOCATION
#endif
//#ifndef SK_DISABLE_EXPLICIT_GPU_RESOURCE_ALLOCATION
// #define SK_DISABLE_EXPLICIT_GPU_RESOURCE_ALLOCATION
//#endif
// Turn on/off the sorting of opLists at flush time
#ifndef SK_DISABLE_RENDER_TARGET_SORTING
@ -111,7 +111,7 @@ public:
void setStencilLoadOp(GrLoadOp loadOp) { fStencilLoadOp = loadOp; }
protected:
SkDEBUGCODE(bool isInstantiated() const;)
bool isInstantiated() const;
GrSurfaceProxyRef fTarget;
GrAuditTrail* fAuditTrail;

View File

@ -237,7 +237,11 @@ bool GrDrawingManager::executeOpLists(int startIndex, int stopIndex, GrOpFlushSt
continue;
}
#else
SkASSERT(fOpLists[i]->isInstantiated());
if (!fOpLists[i]->isInstantiated()) {
// If the backing surface wasn't allocated drop the draw of the entire opList.
fOpLists[i] = nullptr;
continue;
}
#endif
// TODO: handle this instantiation via lazy surface proxies?

View File

@ -118,11 +118,11 @@ void GrOpList::addDependency(GrSurfaceProxy* dependedOn, const GrCaps& caps) {
}
}
#ifdef SK_DEBUG
bool GrOpList::isInstantiated() const {
return fTarget.get()->priv().isInstantiated();
}
#ifdef SK_DEBUG
void GrOpList::dump() const {
SkDebugf("--------------------------------------------------------------\n");
SkDebugf("node: %d -> RT: %d\n", fUniqueID, fTarget.get() ? fTarget.get()->uniqueID().asUInt()

View File

@ -95,10 +95,8 @@ void GrTextureProxyPriv::setDeferredUploader(std::unique_ptr<GrDeferredProxyUplo
}
void GrTextureProxyPriv::scheduleUpload(GrOpFlushState* flushState) {
SkASSERT(fTextureProxy->fDeferredUploader);
// Instantiate might have failed
if (fTextureProxy->fTarget) {
// The texture proxy's contents may already have been uploaded or instantiation may have failed
if (fTextureProxy->fDeferredUploader && fTextureProxy->fTarget) {
fTextureProxy->fDeferredUploader->scheduleUpload(flushState, fTextureProxy);
}
}