Better handle context-loss in MakeBackendTextureFromSkImage
In context-loss situations, SkImage::getTexture may return nullptr, even if SkImage::isTextureBacked() is true. Handle these cases without crashing. R=bsalomon@google.com Bug: 803796 Change-Id: Ia877124160fb1893af08f839e43e3ee83c1b93ff Reviewed-on: https://skia-review.googlesource.com/97341 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
81fe2a1413
commit
36591e5ffe
@ -1041,7 +1041,10 @@ bool SkImage::MakeBackendTextureFromSkImage(GrContext* ctx,
|
||||
}
|
||||
}
|
||||
GrTexture* texture = image->getTexture();
|
||||
SkASSERT(texture);
|
||||
if (!texture) {
|
||||
// In context-loss cases, we may not have a texture.
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the image's context doesn't match the provided context, fail.
|
||||
if (texture->getContext() != ctx) {
|
||||
@ -1063,7 +1066,9 @@ bool SkImage::MakeBackendTextureFromSkImage(GrContext* ctx,
|
||||
}
|
||||
|
||||
texture = image->getTexture();
|
||||
SkASSERT(texture);
|
||||
if (!texture) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Flush to ensure that the copy is completed before we return the texture.
|
||||
ctx->contextPriv().prepareSurfaceForExternalIO(as_IB(image)->peekProxy());
|
||||
|
Loading…
Reference in New Issue
Block a user