From 3425e22b9e9781570db306dfa70a47e34824be9e Mon Sep 17 00:00:00 2001 From: Florin Malita Date: Tue, 19 Jun 2018 10:52:20 -0400 Subject: 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 Commit-Queue: Florin Malita --- tools/get_images_from_skps.cpp | 60 ++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 20 deletions(-) (limited to 'tools/get_images_from_skps.cpp') 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; } -- cgit v1.2.3