add color_depth field in DM/Gold

I think I'd expect images to look the same in Gold when sliced by

    (name, color_depth, alpha_type, gamut, transfer_fn)

And sometimes OS.

Change-Id: Ia6c08c7611d1622014a0842bf685d1b161d5ebf5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/198762
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 7d602fb..462033f 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -1236,6 +1236,28 @@
         return SkString("non-numeric");
     }
 
+    // Equivalence class to slice color type by in Gold.
+    // Basically the same as color type ignoring channel order.
+    static const char* color_depth(SkColorType ct) {
+        switch (ct) {
+            case kUnknown_SkColorType: break;
+
+            case kAlpha_8_SkColorType:      return "A8";
+            case kRGB_565_SkColorType:      return "565";
+            case kARGB_4444_SkColorType:    return "4444";
+            case kRGBA_8888_SkColorType:    return "8888";
+            case kRGB_888x_SkColorType:     return "888";
+            case kBGRA_8888_SkColorType:    return "8888";
+            case kRGBA_1010102_SkColorType: return "1010102";
+            case kRGB_101010x_SkColorType:  return "101010";
+            case kGray_8_SkColorType:       return "G8";
+            case kRGBA_F16Norm_SkColorType: return "F16Norm";  // TODO: "F16"?
+            case kRGBA_F16_SkColorType:     return "F16";
+            case kRGBA_F32_SkColorType:     return "F32";
+        }
+        return "Unknown";
+    }
+
     static void WriteToDisk(const Task& task,
                             SkString md5,
                             const char* ext,
@@ -1254,6 +1276,7 @@
             result.transferFn    = identify_transfer_fn         (bitmap->colorSpace());
             result.colorType     = sk_tool_utils::colortype_name(bitmap->colorType ());
             result.alphaType     = sk_tool_utils::alphatype_name(bitmap->alphaType ());
+            result.colorDepth    = color_depth                  (bitmap->colorType());
         }
         JsonWriter::AddBitmapResult(result);