Prevent crash when flushing while DDL recording
Change-Id: I35e96d3c3020092b33d9b952394d40d4fd5a587b Reviewed-on: https://skia-review.googlesource.com/114685 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
91fba61f24
commit
874b5357da
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user