add flags for clipping to FM

tabl_mozilla.skp is uselessly large without a clip.

Change-Id: I6e8ab8c31e790b6629be01e6eeb2e8d60c6ff56f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/378360
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/infra/bots/task_drivers/fm_driver/fm_driver.go b/infra/bots/task_drivers/fm_driver/fm_driver.go
index 468f13f..7cb50e1 100644
--- a/infra/bots/task_drivers/fm_driver/fm_driver.go
+++ b/infra/bots/task_drivers/fm_driver/fm_driver.go
@@ -431,7 +431,7 @@
 			run(gms, "")
 			run(imgs, "")
 			run(svgs, "")
-			run(skps, "")
+			run(skps, "--clipW 1000 --clipH 1000")
 			run(tests, "")
 
 			if model == "GCE" {
diff --git a/tools/fm/fm.cpp b/tools/fm/fm.cpp
index a09226c..e91c034 100644
--- a/tools/fm/fm.cpp
+++ b/tools/fm/fm.cpp
@@ -33,6 +33,7 @@
 
 #include <chrono>
 #include <functional>
+#include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -75,6 +76,9 @@
                      "DPI for rasterized content in vector backends like --backend pdf.");
 static DEFINE_bool(PDFA, false, "Create PDF/A with --backend pdf?");
 
+static DEFINE_int(clipW, INT_MAX, "Limit source width.");
+static DEFINE_int(clipH, INT_MAX, "Limit source height.");
+
 static DEFINE_bool   (cpuDetect, true, "Detect CPU features for runtime optimizations?");
 static DEFINE_string2(writePath, w, "", "Write .pngs to this directory if set.");
 static DEFINE_bool   (quick, false, "Skip image hashing and encoding?");
@@ -549,7 +553,10 @@
         AutoreleasePool pool;
         const auto start = std::chrono::steady_clock::now();
 
-        const SkImageInfo info = SkImageInfo::Make(source.size, color_info);
+        auto [w,h] = source.size;
+        w = std::min(w, FLAGS_clipW);
+        h = std::min(h, FLAGS_clipH);
+        const SkImageInfo info = SkImageInfo::Make({w,h}, color_info);
 
         auto draw = [&source](SkCanvas* canvas) {
             Result result = source.draw(canvas);