Make ManagedBackendTexture fail on invalid GrBackendTexture

Makes it more sensible.

A bunch of call sites we're already written to expect this. Update
some others.

Change-Id: I77c28045ebf01e6aa9d92d2ebc37287604ec10c9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332544
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/tests/GrMipMappedTest.cpp b/tests/GrMipMappedTest.cpp
index 104449c..35e038a 100644
--- a/tests/GrMipMappedTest.cpp
+++ b/tests/GrMipMappedTest.cpp
@@ -55,6 +55,10 @@
                                                                          mipMapped,
                                                                          renderable,
                                                                          GrProtected::kNo);
+            if (!mbet) {
+                ERRORF(reporter, "Could not make texture.");
+                return;
+            }
 
             sk_sp<GrTextureProxy> proxy;
             sk_sp<SkImage> image;
diff --git a/tests/GrPorterDuffTest.cpp b/tests/GrPorterDuffTest.cpp
index c7f2a44..0adb595 100644
--- a/tests/GrPorterDuffTest.cpp
+++ b/tests/GrPorterDuffTest.cpp
@@ -1001,6 +1001,10 @@
 
     auto mbet = sk_gpu_test::ManagedBackendTexture::MakeWithoutData(
             ctx, 100, 100, kRGBA_8888_SkColorType, GrMipmapped::kNo, GrRenderable::kNo);
+    if (!mbet) {
+        ERRORF(reporter, "Could not make texture.");
+        return;
+    }
     GrXferProcessor::DstProxyView fakeDstProxyView;
     {
         sk_sp<GrTextureProxy> proxy = proxyProvider->wrapBackendTexture(
diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp
index 49078e1..41ef478 100644
--- a/tests/GrSurfaceTest.cpp
+++ b/tests/GrSurfaceTest.cpp
@@ -361,6 +361,10 @@
     for (auto ioType : {kRead_GrIOType, kRW_GrIOType}) {
         auto mbet = sk_gpu_test::ManagedBackendTexture::MakeWithData(
                 dContext, srcPixmap, GrRenderable::kNo, GrProtected::kNo);
+        if (!mbet) {
+            ERRORF(reporter, "Could not make texture.");
+            return;
+        }
         auto proxy = proxyProvider->wrapBackendTexture(mbet->texture(), kBorrow_GrWrapOwnership,
                                                        GrWrapCacheable::kNo, ioType,
                                                        mbet->refCountedCallback());
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index a9b0482..a77bd47 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -489,12 +489,11 @@
 
         auto mbet = sk_gpu_test::ManagedBackendTexture::MakeWithoutData(
                 dContext, kSize, kSize, colorType, GrMipmapped::kNo, GrRenderable::kNo);
-        if (!mbet) {
-            ERRORF(reporter, "Could not create texture with color type %d.", colorType);
-            continue;
+        sk_sp<SkImage> img;
+        if (mbet) {
+            img = SkImage::MakeFromTexture(dContext, mbet->texture(), kTopLeft_GrSurfaceOrigin,
+                                           colorType, kOpaque_SkAlphaType, nullptr);
         }
-        auto img = SkImage::MakeFromTexture(dContext, mbet->texture(), kTopLeft_GrSurfaceOrigin,
-                                            colorType, kOpaque_SkAlphaType, nullptr);
         REPORTER_ASSERT(reporter, can == SkToBool(img),
                         "colorTypeSupportedAsImage:%d, actual:%d, ct:%d", can, SkToBool(img),
                         colorType);
@@ -839,6 +838,7 @@
                                                                     GrProtected::kNo);
     if (!mbet) {
         ERRORF(reporter, "couldn't create backend texture\n");
+        return;
     }
 
     TextureReleaseChecker releaseChecker;