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

Side by Side Diff: dm/DMWriteTask.cpp

Issue 586533005: Add a "mode" tag to key in DM json output. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "DMWriteTask.h" 1 #include "DMWriteTask.h"
2 2
3 #include "DMUtil.h" 3 #include "DMUtil.h"
4 #include "SkColorPriv.h" 4 #include "SkColorPriv.h"
5 #include "SkCommonFlags.h" 5 #include "SkCommonFlags.h"
6 #include "SkData.h" 6 #include "SkData.h"
7 #include "SkImageEncoder.h" 7 #include "SkImageEncoder.h"
8 #include "SkMD5.h" 8 #include "SkMD5.h"
9 #include "SkMallocPixelRef.h" 9 #include "SkMallocPixelRef.h"
10 #include "SkOSFile.h" 10 #include "SkOSFile.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 hasher.finish(digest); 71 hasher.finish(digest);
72 72
73 SkString md5; 73 SkString md5;
74 for (int i = 0; i < 16; i++) { 74 for (int i = 0; i < 16; i++) {
75 md5.appendf("%02x", digest.data[i]); 75 md5.appendf("%02x", digest.data[i]);
76 } 76 }
77 return md5; 77 return md5;
78 } 78 }
79 79
80 struct JsonData { 80 struct JsonData {
81 SkString name; // E.g. "ninepatch-stretch", "desk-gws_skp" 81 SkString name; // E.g. "ninepatch-stretch", "desk-gws_skp"
82 SkString config; // "gpu", "8888" 82 SkString config; // "gpu", "8888"
83 SkString sourceType; // "GM", "SKP" 83 SkString mode; // "direct", "default-tilegrid", "pipe"
84 SkString md5; // In ASCII, so 32 bytes long. 84 SkString sourceType; // "GM", "SKP"
85 SkString md5; // In ASCII, so 32 bytes long.
85 }; 86 };
86 SkTArray<JsonData> gJsonData; 87 SkTArray<JsonData> gJsonData;
87 SK_DECLARE_STATIC_MUTEX(gJsonDataLock); 88 SK_DECLARE_STATIC_MUTEX(gJsonDataLock);
88 89
89 void WriteTask::draw() { 90 void WriteTask::draw() {
90 SkString md5; 91 SkString md5;
91 { 92 {
92 SkAutoLockPixels lock(fBitmap); 93 SkAutoLockPixels lock(fBitmap);
93 md5 = fData ? get_md5(fData->getMemoryBase(), fData->getLength()) 94 md5 = fData ? get_md5(fData->getMemoryBase(), fData->getLength())
94 : get_md5(fBitmap.getPixels(), fBitmap.getSize()); 95 : get_md5(fBitmap.getPixels(), fBitmap.getSize());
95 } 96 }
96 97
97 JsonData entry = { fBaseName, fSuffixes[0], fSourceType, md5 }; 98 SkASSERT(fSuffixes.count() > 0);
99 SkString config = fSuffixes.back();
100 SkString mode("direct");
101 if (fSuffixes.count() > 1) {
102 mode = fSuffixes.fromBack(1);
103 }
104
105 JsonData entry = { fBaseName, config, mode, fSourceType, md5 };
98 { 106 {
99 SkAutoMutexAcquire lock(&gJsonDataLock); 107 SkAutoMutexAcquire lock(&gJsonDataLock);
100 gJsonData.push_back(entry); 108 gJsonData.push_back(entry);
101 } 109 }
102 110
103 SkString dir(FLAGS_writePath[0]); 111 SkString dir(FLAGS_writePath[0]);
104 #if SK_BUILD_FOR_IOS 112 #if SK_BUILD_FOR_IOS
105 if (dir.equals("@")) { 113 if (dir.equals("@")) {
106 dir.set(FLAGS_resourcePath[0]); 114 dir.set(FLAGS_resourcePath[0]);
107 } 115 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 for (int i = 1; i < FLAGS_key.count(); i += 2) { 177 for (int i = 1; i < FLAGS_key.count(); i += 2) {
170 root["key"][FLAGS_key[i-1]] = FLAGS_key[i]; 178 root["key"][FLAGS_key[i-1]] = FLAGS_key[i];
171 } 179 }
172 180
173 { 181 {
174 SkAutoMutexAcquire lock(&gJsonDataLock); 182 SkAutoMutexAcquire lock(&gJsonDataLock);
175 for (int i = 0; i < gJsonData.count(); i++) { 183 for (int i = 0; i < gJsonData.count(); i++) {
176 Json::Value result; 184 Json::Value result;
177 result["key"]["name"] = gJsonData[i].name.c_str(); 185 result["key"]["name"] = gJsonData[i].name.c_str();
178 result["key"]["config"] = gJsonData[i].config.c_str(); 186 result["key"]["config"] = gJsonData[i].config.c_str();
187 result["key"]["mode"] = gJsonData[i].mode.c_str();
179 result["options"]["source_type"] = gJsonData[i].sourceType.c_str(); 188 result["options"]["source_type"] = gJsonData[i].sourceType.c_str();
180 result["md5"] = gJsonData[i].md5.c_str(); 189 result["md5"] = gJsonData[i].md5.c_str();
181 190
182 root["results"].append(result); 191 root["results"].append(result);
183 } 192 }
184 } 193 }
185 194
186 SkString path = SkOSPath::Join(FLAGS_writePath[0], "dm.json"); 195 SkString path = SkOSPath::Join(FLAGS_writePath[0], "dm.json");
187 SkFILEWStream stream(path.c_str()); 196 SkFILEWStream stream(path.c_str());
188 stream.writeText(Json::StyledWriter().write(root).c_str()); 197 stream.writeText(Json::StyledWriter().write(root).c_str());
189 stream.flush(); 198 stream.flush();
190 } 199 }
191 200
192 } // namespace DM 201 } // namespace DM
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698