Add handling for instantiate failure up the call stack
The following two CLs were created via grep:
https://skia-review.googlesource.com/c/4929/ (Guard against instantiate & accessRenderTarget failures)
https://skia-review.googlesource.com/c/4961/ (Remove accessRenderTarget call in SkGpuDevice ctor)
This CL was created by running through all the tests and having instantiate fail so it catches up-stack failures to handle a null return.
BUG=665681,665500,665621
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4991
Change-Id: I6611eec8d36679123eef140538ee2526fb18628f
Reviewed-on: https://skia-review.googlesource.com/4991
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index 778eb24..f99d3c2 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -46,6 +46,9 @@
GrBackendObject SkSurface_Gpu::onGetTextureHandle(BackendHandleAccess access) {
GrRenderTarget* rt = prepare_rt_for_external_access(this, access);
+ if (!rt) {
+ return 0;
+ }
GrTexture* texture = rt->asTexture();
if (texture) {
return texture->getTextureHandle();
@@ -55,6 +58,9 @@
bool SkSurface_Gpu::onGetRenderTargetHandle(GrBackendObject* obj, BackendHandleAccess access) {
GrRenderTarget* rt = prepare_rt_for_external_access(this, access);
+ if (!rt) {
+ return false;
+ }
*obj = rt->getRenderTargetHandle();
return true;
}