diff options
-rw-r--r-- | src/gpu/GrDrawingManager.cpp | 15 | ||||
-rw-r--r-- | tests/DeferredDisplayListTest.cpp | 16 |
2 files changed, 26 insertions, 5 deletions
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp index d4f7888e3a..8ebcc85455 100644 --- a/src/gpu/GrDrawingManager.cpp +++ b/src/gpu/GrDrawingManager.cpp @@ -123,6 +123,10 @@ GrSemaphoresSubmitted GrDrawingManager::internalFlush(GrSurfaceProxy*, if (fFlushing || this->wasAbandoned()) { return GrSemaphoresSubmitted::kNo; } + GrGpu* gpu = fContext->contextPriv().getGpu(); + if (!gpu) { + return GrSemaphoresSubmitted::kNo; // Can't flush while DDL recording + } fFlushing = true; for (int i = 0; i < fOpLists.count(); ++i) { @@ -155,8 +159,6 @@ GrSemaphoresSubmitted GrDrawingManager::internalFlush(GrSurfaceProxy*, SkASSERT(result); } - GrGpu* gpu = fContext->contextPriv().getGpu(); - GrOpFlushState flushState(gpu, fContext->contextPriv().resourceProvider(), &fTokenTracker); @@ -333,6 +335,11 @@ GrSemaphoresSubmitted GrDrawingManager::prepareSurfaceForExternalIO( } SkASSERT(proxy); + GrGpu* gpu = fContext->contextPriv().getGpu(); + if (!gpu) { + return GrSemaphoresSubmitted::kNo; // Can't flush while DDL recording + } + GrSemaphoresSubmitted result = GrSemaphoresSubmitted::kNo; if (proxy->priv().hasPendingIO() || numSemaphores) { result = this->flush(proxy, numSemaphores, backendSemaphores); @@ -342,10 +349,8 @@ GrSemaphoresSubmitted GrDrawingManager::prepareSurfaceForExternalIO( return result; } - GrGpu* gpu = fContext->contextPriv().getGpu(); GrSurface* surface = proxy->priv().peekSurface(); - - if (gpu && surface->asRenderTarget()) { + if (surface->asRenderTarget()) { gpu->resolveRenderTarget(surface->asRenderTarget()); } return result; diff --git a/tests/DeferredDisplayListTest.cpp b/tests/DeferredDisplayListTest.cpp index b85388f9c9..f17957c9c8 100644 --- a/tests/DeferredDisplayListTest.cpp +++ b/tests/DeferredDisplayListTest.cpp @@ -445,5 +445,21 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLInvalidRecorder, reporter, ctxInfo) { } +// Ensure that flushing while DDL recording doesn't cause a crash +DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLFlushWhileRecording, reporter, ctxInfo) { + GrContext* context = ctxInfo.grContext(); + + SkImageInfo ii = SkImageInfo::MakeN32Premul(32, 32); + sk_sp<SkSurface> s = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, ii); + + SkSurfaceCharacterization characterization; + SkAssertResult(s->characterize(&characterization)); + + SkDeferredDisplayListRecorder recorder(characterization); + SkCanvas* canvas = recorder.getCanvas(); + + canvas->flush(); + canvas->getGrContext()->flush(); +} #endif |