Avoid crash in wacky_yuv GMs with --preAbandonGpuContext

TBR: egdaniel@google.com

Change-Id: Ia4e0c977fab68e56e3c43fe1b6e0796923d49f77
Reviewed-on: https://skia-review.googlesource.com/c/188022
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Brian Salomon 2019-01-30 09:13:31 -05:00 committed by Skia Commit-Bot
parent a150aa33b3
commit f2580c0c76

View File

@ -797,7 +797,9 @@ protected:
for (int i = 0; i < numTextures; ++i) {
yuvaTextures[i] = create_yuva_texture(gpu, resultBMs[i],
yuvaIndices, i);
fBackendTextures.push_back(yuvaTextures[i]);
if (yuvaTextures[i].isValid()) {
fBackendTextures.push_back(yuvaTextures[i]);
}
yuvaPixmaps[i] = resultBMs[i].pixmap();
}
@ -874,14 +876,16 @@ protected:
}
}
if (auto context = canvas->getGrContext()) {
context->flush();
GrGpu* gpu = context->contextPriv().getGpu();
SkASSERT(gpu);
gpu->testingOnly_flushGpuAndSync();
for (const auto& tex : fBackendTextures) {
gpu->deleteTestingOnlyBackendTexture(tex);
if (!context->abandoned()) {
context->flush();
GrGpu* gpu = context->contextPriv().getGpu();
SkASSERT(gpu);
gpu->testingOnly_flushGpuAndSync();
for (const auto& tex : fBackendTextures) {
gpu->deleteTestingOnlyBackendTexture(tex);
}
fBackendTextures.reset();
}
fBackendTextures.reset();
}
SkASSERT(!fBackendTextures.count());
}