SkQP: model-creation improvements

  - cut_release/find_commit: use cookies, handle errors.

  - tools/skqp/make_skqp_model.cpp: better error handling

Change-Id: I702e9a13d3a2123c30e3a870fcb942759cfc47c3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/257682
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
diff --git a/tools/skqp/make_skqp_model.cpp b/tools/skqp/make_skqp_model.cpp
index 62ae5d0..574e2e0 100644
--- a/tools/skqp/make_skqp_model.cpp
+++ b/tools/skqp/make_skqp_model.cpp
@@ -6,7 +6,7 @@
 #include "include/encode/SkPngEncoder.h"
 #include "src/core/SkOSFile.h"
 
-static void update(SkBitmap* maxBitmap, SkBitmap* minBitmap, const SkBitmap& bm) {
+static bool update(SkBitmap* maxBitmap, SkBitmap* minBitmap, const SkBitmap& bm) {
     SkASSERT(!bm.drawsNothing());
     SkASSERT(4 == bm.bytesPerPixel());
     if (maxBitmap->drawsNothing()) {
@@ -15,6 +15,9 @@
         minBitmap->allocPixels(bm.info());
         minBitmap->eraseColor(0xFFFFFFFF);
     }
+    if (maxBitmap->dimensions() != bm.dimensions()) {
+        return false;
+    }
     SkASSERT_RELEASE(maxBitmap->info() == bm.info());
     const SkPixmap& pmin = minBitmap->pixmap();
     const SkPixmap& pmax = maxBitmap->pixmap();
@@ -35,6 +38,7 @@
             memcpy(maxPtr, maxColor, 4);
         }
     }
+    return true;
 }
 
 static SkBitmap decode_to_srgb_8888_unpremul(const char* path) {
@@ -72,11 +76,21 @@
     while (iter.next(&name)) {
         name.prependf("%s/", src_dir);
         SkBitmap bm = decode_to_srgb_8888_unpremul(name.c_str());
-        if (!bm.drawsNothing()) {
-            update(&maxBitmap, &minBitmap, bm);
+        if (bm.drawsNothing()) {
+            SkDebugf("'%s' failed to decode.\n", name.c_str());
+            continue;
+        }
+        if (!update(&maxBitmap, &minBitmap, bm)) {
+            SkDebugf("'%s' has unmatched dimensions.\n", name.c_str());
+            continue;
         }
     }
     SkASSERT_RELEASE(sk_mkdir(dst_dir));
+    if ((maxBitmap.drawsNothing()) || (maxBitmap.drawsNothing())) {
+        SkDebugf("Failure: '%s' '%s'\n", src_dir, dst_dir);
+        return 1;
+    }
     encode_png(SkStringPrintf("%s/min.png", dst_dir).c_str(), minBitmap.pixmap());
     encode_png(SkStringPrintf("%s/max.png", dst_dir).c_str(), maxBitmap.pixmap());
+    return 0;
 }