Generate platform specific fontmgr gm.
authorcaryclark <caryclark@google.com>
Mon, 20 Jul 2015 20:38:56 +0000 (13:38 -0700)
committerCommit bot <commit-bot@chromium.org>
Mon, 20 Jul 2015 20:38:56 +0000 (13:38 -0700)
The gm output on different font platforms is so different
that comparing images in Gold has little value. Separate the
images by appending platform information to the gm name to
group somewhat similar images together.

Note that this does not attempt to make sure that all images
generated by Gold are nearly pixel identical; it only reduces
the number of nonsensical comparisons.

R=bungeman@google.com

Review URL: https://codereview.chromium.org/1245643002

gm/fontmgr.cpp
samplecode/SampleApp.cpp
tools/VisualBench/VisualBench.cpp
tools/sk_tool_utils.cpp
tools/sk_tool_utils.h

index 14ea7ea..35914e7 100644 (file)
@@ -65,6 +65,8 @@ public:
         } else {
             fFM.reset(SkFontMgr::RefDefault());
         }
+        fName.append(sk_tool_utils::platform_os_name());
+        fName.append(sk_tool_utils::platform_extra_config("GDI"));
     }
 
 protected:
@@ -131,7 +133,10 @@ public:
 
 protected:
     SkString onShortName() override {
-        return SkString("fontmgr_match");
+        SkString name("fontmgr_match");
+        name.append(sk_tool_utils::platform_os_name());
+        name.append(sk_tool_utils::platform_extra_config("GDI"));
+        return name;
     }
 
     SkISize onISize() override {
@@ -218,6 +223,8 @@ public:
         if (scale != 1 || skew != 0) {
             fName.appendf("_%g_%g", scale, skew);
         }
+        fName.append(sk_tool_utils::platform_os_name());
+        fName.append(sk_tool_utils::platform_extra_config("GDI"));
         fFM.reset(SkFontMgr::RefDefault());
     }
 
index 508ff63..318a822 100644 (file)
@@ -700,6 +700,7 @@ DEFINE_string(pictureDir, "", "Read pictures from here.");
 DEFINE_string(picture, "", "Path to single picture.");
 DEFINE_bool(sort, false, "Sort samples by title.");
 DEFINE_bool(list, false, "List samples?");
+DEFINE_string(key, "", "");  // dummy to enable gm tests that have platform-specific names
 #ifdef SAMPLE_PDF_FILE_VIEWER
 DEFINE_string(pdfPath, "", "Path to direcotry of pdf files.");
 #endif
index 895569c..3a6cb50 100644 (file)
@@ -35,6 +35,7 @@ DEFINE_double(loopMs, 5, "Target loop time in millseconds.");
 DEFINE_int32(msaa, 0, "Number of msaa samples.");
 DEFINE_bool2(fullscreen, f, true, "Run fullscreen.");
 DEFINE_bool2(verbose, v, false, "enable verbose output from the test driver.");
+DEFINE_string(key, "", "");  // dummy to enable gm tests that have platform-specific names
 
 static SkString humanize(double ms) {
     if (FLAGS_verbose) {
index 4d0e0bd..b06fcda 100644 (file)
@@ -10,6 +10,7 @@
 
 #include "SkBitmap.h"
 #include "SkCanvas.h"
+#include "SkCommonFlags.h"
 #include "SkShader.h"
 #include "SkTestScalerContext.h"
 #include "SkTextBlob.h"
@@ -19,6 +20,25 @@ DEFINE_bool(resourceFonts, false, "Use resource fonts");
 
 namespace sk_tool_utils {
 
+const char* platform_os_name() {
+    for (int index = 0; index < FLAGS_key.count(); index += 2) {
+        if (!strcmp("os", FLAGS_key[index])) {
+            return FLAGS_key[index + 1];
+        }
+    }
+    // when running SampleApp or dm without a --key pair, omit the platform name
+    return "";
+}
+
+const char* platform_extra_config(const char* config) {
+    for (int index = 0; index < FLAGS_key.count(); index += 2) {
+        if (!strcmp("extra_config", FLAGS_key[index]) && !strcmp(config, FLAGS_key[index + 1])) {
+            return config;
+        }
+    }
+    return "";
+}
+
 const char* colortype_name(SkColorType ct) {
     switch (ct) {
         case kUnknown_SkColorType:      return "Unknown";
index 4bf9ad6..864c33d 100644 (file)
@@ -25,6 +25,8 @@ namespace sk_tool_utils {
 
     const char* colortype_name(SkColorType);
     SkColor color_to_565(SkColor color);
+    const char* platform_os_name();
+    const char* platform_extra_config(const char* config);
 
     /**
      * Sets the paint to use a platform-independent text renderer if FLAGS_portableFonts is set.