diff --git a/tools/skqp/gm_knowledge.cpp b/tools/skqp/gm_knowledge.cpp
index 8bbac6e5c5..51f0d8f85a 100644
--- a/tools/skqp/gm_knowledge.cpp
+++ b/tools/skqp/gm_knowledge.cpp
@@ -31,6 +31,7 @@
#define PATH_IMG_PNG "image.png"
#define PATH_ERR_PNG "errors.png"
#define PATH_REPORT "report.html"
+#define PATH_CSV "out.csv"
////////////////////////////////////////////////////////////////////////////////
@@ -199,71 +200,93 @@ float Check(const uint32_t* pixels,
return (float)badness;
}
+static constexpr char kDocHead[] =
+ "\n"
+ "\n"
+ "
\n"
+ "\n"
+ "SkQP Report\n"
+ "\n"
+ "\n"
+ "\n"
+ "\n"
+ "SkQP Report
\n"
+ "
\n"
+ "\n"
+ "\n";
+
+static void write(SkWStream* wStream, const SkString& text) {
+ wStream->write(text.c_str(), text.size());
+}
+
bool MakeReport(const char* report_directory_path) {
SkASSERT_RELEASE(sk_isdir(report_directory_path));
std::lock_guard lock(gMutex);
- {
- SkFILEWStream csvOut(SkOSPath::Join(report_directory_path, "out.csv").c_str());
- SkASSERT_RELEASE(csvOut.isValid());
- if (!csvOut.isValid()) {
- return false;
- }
- for (const Run& run : gErrors) {
- SkString line = SkStringPrintf("\"%s\",\"%s\",%d,%d\n",
- run.fBackend.c_str(), run.fGM.c_str(),
- run.fMaxerror, run.fBadpixels);
- csvOut.write(line.c_str(), line.size());
- }
- }
-
- SkFILEWStream out(SkOSPath::Join(report_directory_path, PATH_REPORT).c_str());
- if (!out.isValid()) {
+ SkFILEWStream csvOut(SkOSPath::Join(report_directory_path, PATH_CSV).c_str());
+ SkFILEWStream htmOut(SkOSPath::Join(report_directory_path, PATH_REPORT).c_str());
+ SkASSERT_RELEASE(csvOut.isValid());
+ if (!csvOut.isValid() || !htmOut.isValid()) {
return false;
}
- out.writeText(
- "\n"
- "\n"
- "\n"
- "\n"
- "SkQP Report\n"
- "\n"
- "\n"
- "\n"
- "SkQP Report
\n"
- "
\n");
+ htmOut.writeText(kDocHead);
for (const Run& run : gErrors) {
- const SkString& backend = run.fBackend;
- const SkString& gm = run.fGM;
- int maxerror = run.fMaxerror;
- int badpixels = run.fBadpixels;
- if (maxerror == 0 && badpixels == 0) {
+ write(&csvOut, SkStringPrintf("\"%s\",\"%s\",%d,%d\n",
+ run.fBackend.c_str(), run.fGM.c_str(),
+ run.fMaxerror, run.fBadpixels));
+ if (run.fMaxerror == 0 && run.fBadpixels == 0) {
continue;
}
- SkString rdir = SkOSPath::Join(backend.c_str(), gm.c_str());
- SkString text = SkStringPrintf(
- "%s
\n"
- "backend: %s\n
\n"
- "gm name: %s\n
\n"
- "maximum error: %d\n
\n"
- "bad pixel counts: %d\n
\n"
- ""
- "\n"
- ""
- "\n
\n"
- "max\n
\n"
- "min\n
\n\n",
- rdir.c_str(), backend.c_str(), gm.c_str(), maxerror, badpixels,
- rdir.c_str(), rdir.c_str(), rdir.c_str(),
- rdir.c_str(), rdir.c_str(), rdir.c_str());
- out.write(text.c_str(), text.size());
+ write(&htmOut, SkStringPrintf(" f(\"%s\", \"%s\", %d, %d);\n",
+ run.fBackend.c_str(), run.fGM.c_str(),
+ run.fMaxerror, run.fBadpixels));
}
- out.writeText("\n\n");
+ htmOut.writeText(kDocTail);
return true;
}
} // namespace gmkb