Handle invalid DDLRecorder case

Prior to this CL, if we failed to create the DDL Recorder's target
proxy while creating the target surface we could create an invalid
DDL.

The specific repro case involved too big of an target proxy but
many other scenarios could result in the same behavior.

Bug: 1105903
Change-Id: I519a072600c168aa590fbe920f4029d08fe29e6f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/309777
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrContextThreadSafeProxy.cpp b/src/gpu/GrContextThreadSafeProxy.cpp
index 1642c92..8514ff5 100644
--- a/src/gpu/GrContextThreadSafeProxy.cpp
+++ b/src/gpu/GrContextThreadSafeProxy.cpp
@@ -50,45 +50,50 @@
                                      GrProtected isProtected) {
     SkASSERT(fCaps);
     if (!backendFormat.isValid()) {
-        return SkSurfaceCharacterization(); // return an invalid characterization
+        return {};
     }
 
     SkASSERT(isTextureable || !isMipMapped);
 
     if (GrBackendApi::kOpenGL != backendFormat.backend() && willUseGLFBO0) {
         // The willUseGLFBO0 flags can only be used for a GL backend.
-        return SkSurfaceCharacterization(); // return an invalid characterization
+        return {};
     }
 
     if (!fCaps->mipmapSupport()) {
         isMipMapped = false;
     }
 
+    if (ii.width()  < 1 || ii.width()  > fCaps->maxRenderTargetSize() ||
+        ii.height() < 1 || ii.height() > fCaps->maxRenderTargetSize()) {
+        return {};
+    }
+
     GrColorType grColorType = SkColorTypeToGrColorType(ii.colorType());
 
     if (!fCaps->areColorTypeAndFormatCompatible(grColorType, backendFormat)) {
-        return SkSurfaceCharacterization(); // return an invalid characterization
+        return {};
     }
 
     if (!fCaps->isFormatAsColorTypeRenderable(grColorType, backendFormat, sampleCnt)) {
-        return SkSurfaceCharacterization(); // return an invalid characterization
+        return {};
     }
 
     sampleCnt = fCaps->getRenderTargetSampleCount(sampleCnt, backendFormat);
     SkASSERT(sampleCnt);
 
     if (willUseGLFBO0 && isTextureable) {
-        return SkSurfaceCharacterization(); // return an invalid characterization
+        return {};
     }
 
     if (isTextureable && !fCaps->isFormatTexturable(backendFormat)) {
         // Skia doesn't agree that this is textureable.
-        return SkSurfaceCharacterization(); // return an invalid characterization
+        return {};
     }
 
     if (GrBackendApi::kVulkan == backendFormat.backend()) {
         if (GrBackendApi::kVulkan != fBackend) {
-            return SkSurfaceCharacterization(); // return an invalid characterization
+            return {};
         }
 
 #ifdef SK_VULKAN
@@ -96,7 +101,7 @@
 
         // The protection status of the characterization and the context need to match
         if (isProtected != GrProtected(vkCaps->supportsProtectedMemory())) {
-            return SkSurfaceCharacterization(); // return an invalid characterization
+            return {};
         }
 #endif
     }