aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2018-06-19 10:52:20 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-19 20:06:36 +0000
commit3425e22b9e9781570db306dfa70a47e34824be9e (patch)
tree25d2344a607694bd78307afbdb28c1627f08b726
parentebf0cf5af3c88ee370d3b59fef7557dbfe6b4a9c (diff)
Use SkJSONWriter for get_images_from_skps stats reporting
Remove JsonCPP dependency. Change-Id: I3e86334e27b325cb06fd01d3c61661a9687c3a7f Reviewed-on: https://skia-review.googlesource.com/135710 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
-rw-r--r--BUILD.gn1
-rw-r--r--tools/get_images_from_skps.cpp60
2 files changed, 40 insertions, 21 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 0dd4fb1c62..94ac8f5dc5 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1675,7 +1675,6 @@ if (skia_enable_tools) {
deps = [
":flags",
":skia",
- "//third_party/jsoncpp",
]
}
diff --git a/tools/get_images_from_skps.cpp b/tools/get_images_from_skps.cpp
index 3c15403d6d..486781810d 100644
--- a/tools/get_images_from_skps.cpp
+++ b/tools/get_images_from_skps.cpp
@@ -10,7 +10,7 @@
#include "SkColorSpace.h"
#include "SkCommandLineFlags.h"
#include "SkData.h"
-#include "SkJSONCPP.h"
+#include "SkJSONWriter.h"
#include "SkMD5.h"
#include "SkOSFile.h"
#include "SkOSPath.h"
@@ -181,33 +181,53 @@ int main(int argc, char** argv) {
"totalSuccesses": 21,
}
*/
- Json::Value fRoot;
- int totalFailures = 0;
- for(auto it = gSkpToUnknownCount.cbegin(); it != gSkpToUnknownCount.cend(); ++it)
+
+ unsigned int totalFailures = 0,
+ totalUnsupported = 0;
+ SkDynamicMemoryWStream memStream;
+ SkJSONWriter writer(&memStream, SkJSONWriter::Mode::kPretty);
+ writer.beginObject();
{
- SkDebugf("%s %d\n", it->first.c_str(), it->second);
- totalFailures += it->second;
- fRoot["failures"][it->first.c_str()] = it->second;
- }
- fRoot["totalFailures"] = totalFailures;
- int totalUnsupported = 0;
+ writer.beginObject("failures");
+ {
+ for(const auto& failure : gSkpToUnknownCount) {
+ SkDebugf("%s %d\n", failure.first.c_str(), failure.second);
+ totalFailures += failure.second;
+ writer.appendU32(failure.first.c_str(), failure.second);
+ }
+ }
+ writer.endObject();
+ writer.appendU32("totalFailures", totalFailures);
+
#ifdef SK_DEBUG
- for (const auto& unsupported : gSkpToUnsupportedCount) {
- SkDebugf("%s %d\n", unsupported.first.c_str(), unsupported.second);
- totalUnsupported += unsupported.second;
- fRoot["unsupported"][unsupported.first] = unsupported.second;
- }
- fRoot["totalUnsupported"] = totalUnsupported;
+ writer.beginObject("unsupported");
+ {
+ for (const auto& unsupported : gSkpToUnsupportedCount) {
+ SkDebugf("%s %d\n", unsupported.first.c_str(), unsupported.second);
+ totalUnsupported += unsupported.second;
+ writer.appendHexU32(unsupported.first.c_str(), unsupported.second);
+ }
+
+ }
+ writer.endObject();
+ writer.appendU32("totalUnsupported", totalUnsupported);
#endif
- fRoot["totalSuccesses"] = gKnown;
- SkDebugf("%d known, %d failures, %d unsupported\n", gKnown, totalFailures, totalUnsupported);
+
+ writer.appendS32("totalSuccesses", gKnown);
+ SkDebugf("%d known, %d failures, %d unsupported\n",
+ gKnown, totalFailures, totalUnsupported);
+ }
+ writer.endObject();
+ writer.flush();
+
if (totalFailures > 0 || totalUnsupported > 0) {
if (!FLAGS_failuresJsonPath.isEmpty()) {
SkDebugf("Writing failures to %s\n", FLAGS_failuresJsonPath[0]);
SkFILEWStream stream(FLAGS_failuresJsonPath[0]);
- stream.writeText(Json::StyledWriter().write(fRoot).c_str());
- stream.flush();
+ auto jsonStream = memStream.detachAsStream();
+ stream.writeStream(jsonStream.get(), jsonStream->getLength());
}
}
+
return 0;
}