Stop creating CodecSrcs with unused scale

Only JPEG and WEBP support native scaling, so only create a CodecSrc
with a scale for those types.

If I run

    dm --src image --images resources

this cuts down the number of Srcs from 11063 to 8032. All of these
trimmed Srcs would have failed quickly for each Sink (3 Sinks with the
above flags), but this will avoid creating them.

It drops the runtime on my mac from 13.2s to 11.4s, for about a 14%
speedup.

BUG=skia:5307
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1999103002

Review-Url: https://codereview.chromium.org/1999103002
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 9051d5b..bb53638 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -481,9 +481,8 @@
         return;
     }
 
-    // Native Scales
-    // SkJpegCodec natively supports scaling to: 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875
-    const float nativeScales[] = { 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.750f, 0.875f, 1.0f };
+    // native scaling is only supported by WEBP and JPEG
+    bool supportsNativeScaling = false;
 
     SkTArray<CodecSrc::Mode> nativeModes;
     nativeModes.push_back(CodecSrc::kCodec_Mode);
@@ -493,9 +492,11 @@
             nativeModes.push_back(CodecSrc::kScanline_Mode);
             nativeModes.push_back(CodecSrc::kStripe_Mode);
             nativeModes.push_back(CodecSrc::kCroppedScanline_Mode);
+            supportsNativeScaling = true;
             break;
         case SkEncodedFormat::kWEBP_SkEncodedFormat:
             nativeModes.push_back(CodecSrc::kSubset_Mode);
+            supportsNativeScaling = true;
             break;
         case SkEncodedFormat::kDNG_SkEncodedFormat:
             break;
@@ -529,24 +530,26 @@
     }
 
     for (CodecSrc::Mode mode : nativeModes) {
-        for (float scale : nativeScales) {
-            for (CodecSrc::DstColorType colorType : colorTypes) {
-                for (SkAlphaType alphaType : alphaModes) {
-                    // Only test kCroppedScanline_Mode when the alpha type is opaque.  The test is
-                    // slow and won't be interestingly different with different alpha types.
-                    if (CodecSrc::kCroppedScanline_Mode == mode &&
-                            kOpaque_SkAlphaType != alphaType) {
-                        continue;
-                    }
+        for (CodecSrc::DstColorType colorType : colorTypes) {
+            for (SkAlphaType alphaType : alphaModes) {
+                // Only test kCroppedScanline_Mode when the alpha type is opaque.  The test is
+                // slow and won't be interestingly different with different alpha types.
+                if (CodecSrc::kCroppedScanline_Mode == mode &&
+                        kOpaque_SkAlphaType != alphaType) {
+                    continue;
+                }
 
-                    // Skip kNonNative on different native scales.  It won't be interestingly
-                    // different.
-                    if (CodecSrc::kNonNative8888_Always_DstColorType == colorType && 1.0f != scale)
-                    {
-                        continue;
-                    }
+                push_codec_src(path, mode, colorType, alphaType, 1.0f);
 
-                    push_codec_src(path, mode, colorType, alphaType, scale);
+                // Skip kNonNative on different native scales.  It won't be interestingly
+                // different.
+                if (supportsNativeScaling &&
+                        CodecSrc::kNonNative8888_Always_DstColorType == colorType) {
+                    // Native Scales
+                    // SkJpegCodec natively supports scaling to the following:
+                    for (auto scale : { 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.750f, 0.875f }) {
+                        push_codec_src(path, mode, colorType, alphaType, scale);
+                    }
                 }
             }
         }