Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Unified Diff: dm/DMWriteTask.cpp

Issue 702513003: Separate JSON functions from DMWriteTask. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Modify comment to be more accurate. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dm/DMWriteTask.h ('k') | gyp/dm.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMWriteTask.cpp
diff --git a/dm/DMWriteTask.cpp b/dm/DMWriteTask.cpp
index 35ae2a72097de79d75fbd3df060bfe00633a68b2..fa0d129d688628a4bfc69ce1a86af21f6172c512 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
« no previous file with comments | « dm/DMWriteTask.h ('k') | gyp/dm.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698