Just skip uninstantiated GrOps instead of delete them on flush.
Change-Id: I4e1755872979b635ad993cfba6b17d7b79ee2c54
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/238179
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index 4776484..96f35c5 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -350,8 +350,9 @@
continue;
}
if (!renderTask->isInstantiated()) {
- // If the backing surface wasn't allocated, drop the entire renderTask.
- fDAG.removeRenderTask(i);
+ // No need to call the renderTask's handleInternalAllocationFailure
+ // since we will already skip executing the renderTask since it is not
+ // instantiated.
continue;
}
renderTask->handleInternalAllocationFailure();
@@ -426,12 +427,11 @@
bool anyRenderTasksExecuted = false;
for (int i = startIndex; i < stopIndex; ++i) {
- if (!fDAG.renderTask(i)) {
+ GrRenderTask* renderTask = fDAG.renderTask(i);
+ if (!renderTask || !renderTask->isInstantiated()) {
continue;
}
- GrRenderTask* renderTask = fDAG.renderTask(i);
- SkASSERT(renderTask->isInstantiated());
SkASSERT(renderTask->deferredProxiesAreInstantiated());
renderTask->prepare(flushState);
@@ -465,11 +465,12 @@
// Execute the normal op lists.
for (int i = startIndex; i < stopIndex; ++i) {
- if (!fDAG.renderTask(i)) {
+ GrRenderTask* renderTask = fDAG.renderTask(i);
+ if (!renderTask || !renderTask->isInstantiated()) {
continue;
}
- if (fDAG.renderTask(i)->execute(flushState)) {
+ if (renderTask->execute(flushState)) {
anyRenderTasksExecuted = true;
}
(*numRenderTasksExecuted)++;
diff --git a/src/gpu/GrOpsTask.cpp b/src/gpu/GrOpsTask.cpp
index c06a7ae..69f5780 100644
--- a/src/gpu/GrOpsTask.cpp
+++ b/src/gpu/GrOpsTask.cpp
@@ -396,7 +396,7 @@
// Loop over the ops that haven't yet been prepared.
for (const auto& chain : fOpChains) {
- if (chain.head()) {
+ if (chain.shouldExecute()) {
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
TRACE_EVENT0("skia.gpu", chain.head()->name());
#endif
@@ -472,7 +472,7 @@
// Draw all the generated geometry.
for (const auto& chain : fOpChains) {
- if (!chain.head()) {
+ if (!chain.shouldExecute()) {
continue;
}
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
@@ -616,8 +616,7 @@
hasUninstantiatedProxy = false;
recordedOp.visitProxies(checkInstantiation);
if (hasUninstantiatedProxy) {
- // When instantiation of the proxy fails we drop the Op
- recordedOp.deleteOps(fOpMemoryPool.get());
+ recordedOp.setSkipExecuteFlag();
}
}
}
diff --git a/src/gpu/GrOpsTask.h b/src/gpu/GrOpsTask.h
index d346f1f..b005671 100644
--- a/src/gpu/GrOpsTask.h
+++ b/src/gpu/GrOpsTask.h
@@ -165,6 +165,11 @@
const DstProxy*, const GrAppliedClip*, const GrCaps&,
GrOpMemoryPool*, GrAuditTrail*);
+ void setSkipExecuteFlag() { fSkipExecute = true; }
+ bool shouldExecute() const {
+ return SkToBool(this->head()) && !fSkipExecute;
+ }
+
private:
class List {
public:
@@ -200,6 +205,10 @@
DstProxy fDstProxy;
GrAppliedClip* fAppliedClip;
SkRect fBounds;
+
+ // We set this flag to true if any of the ops' proxies fail to instantiate so that we know
+ // not to try and draw the op.
+ bool fSkipExecute = false;
};