diff options
Diffstat (limited to 'dm/DMWriteTask.cpp')
-rw-r--r-- | dm/DMWriteTask.cpp | 54 |
1 files changed, 7 insertions, 47 deletions
diff --git a/dm/DMWriteTask.cpp b/dm/DMWriteTask.cpp index 35ae2a7209..fa0d129d68 100644 --- a/dm/DMWriteTask.cpp +++ b/dm/DMWriteTask.cpp @@ -1,5 +1,6 @@ #include "DMWriteTask.h" +#include "DMJsonWriter.h" #include "DMUtil.h" #include "SkColorPriv.h" #include "SkCommonFlags.h" @@ -91,16 +92,6 @@ static SkString get_md5(SkStreamAsset* stream) { return get_md5_string(&hasher); } -struct JsonData { - SkString name; // E.g. "ninepatch-stretch", "desk-gws_skp" - SkString config; // "gpu", "8888" - SkString mode; // "direct", "default-tilegrid", "pipe" - SkString sourceType; // "GM", "SKP" - SkString md5; // In ASCII, so 32 bytes long. -}; -SkTArray<JsonData> gJsonData; -SK_DECLARE_STATIC_MUTEX(gJsonDataLock); - void WriteTask::draw() { SkString md5; { @@ -116,10 +107,13 @@ void WriteTask::draw() { mode = fSuffixes.fromBack(1); } - JsonData entry = { fBaseName, config, mode, fSourceType, md5 }; { - SkAutoMutexAcquire lock(&gJsonDataLock); - gJsonData.push_back(entry); + const JsonWriter::BitmapResult entry = { fBaseName, + config, + mode, + fSourceType, + md5 }; + JsonWriter::AddBitmapResult(entry); } SkString dir(FLAGS_writePath[0]); @@ -178,38 +172,4 @@ bool WriteTask::shouldSkip() const { return FLAGS_writePath.isEmpty(); } -void WriteTask::DumpJson() { - if (FLAGS_writePath.isEmpty()) { - return; - } - - Json::Value root; - - for (int i = 1; i < FLAGS_properties.count(); i += 2) { - root[FLAGS_properties[i-1]] = FLAGS_properties[i]; - } - for (int i = 1; i < FLAGS_key.count(); i += 2) { - root["key"][FLAGS_key[i-1]] = FLAGS_key[i]; - } - - { - SkAutoMutexAcquire lock(&gJsonDataLock); - for (int i = 0; i < gJsonData.count(); i++) { - Json::Value result; - result["key"]["name"] = gJsonData[i].name.c_str(); - result["key"]["config"] = gJsonData[i].config.c_str(); - result["key"]["mode"] = gJsonData[i].mode.c_str(); - result["options"]["source_type"] = gJsonData[i].sourceType.c_str(); - result["md5"] = gJsonData[i].md5.c_str(); - - root["results"].append(result); - } - } - - SkString path = SkOSPath::Join(FLAGS_writePath[0], "dm.json"); - SkFILEWStream stream(path.c_str()); - stream.writeText(Json::StyledWriter().write(root).c_str()); - stream.flush(); -} - } // namespace DM |