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

Unified Diff: dm/DM.cpp

Issue 1059363002: Add --uninterestingHashesFile to DM (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DM.cpp
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 256014e5daabc979a0339b36086a230744700216..b5bf97934d87357de5089521ef1206d7b62a703b 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -17,8 +17,10 @@
#include "SkForceLinking.h"
#include "SkGraphics.h"
#include "SkInstCnt.h"
+#include "SkJSONCPP.h"
#include "SkMD5.h"
#include "SkOSFile.h"
+#include "SkTDict.h"
#include "SkTHash.h"
#include "SkTaskGroup.h"
#include "SkThreadUtils.h"
@@ -42,6 +44,10 @@ DEFINE_string(blacklist, "",
DEFINE_string2(readPath, r, "", "If set check for equality with golden results in this directory.");
+DEFINE_string(uninterestingHashesFile, "",
+ "JSON file containing a list of uninteresting hashes. If a result hashes to something in "
+ "this list, no image is written for that result.");
+
__SK_FORCE_IMAGE_DECODER_LINKING;
using namespace DM;
@@ -137,6 +143,32 @@ static void gather_gold() {
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+static SkTDict<bool> gUninterestingHashes(0);
mtklein 2015/04/03 19:58:04 Let's try: static SkTHashSet<SkString> gUnintere
borenet 2015/04/03 20:26:50 Done.
+
+static void gather_uninteresting_hashes() {
+ if (!FLAGS_uninterestingHashesFile.isEmpty()) {
+ SkString path(FLAGS_uninterestingHashesFile[0]);
+ SkAutoTUnref<SkData> json(SkData::NewFromFileName(path.c_str()));
+ if (!json) {
+ fail(SkStringPrintf("Couldn't read %s to get the list of uninteresting hashes.",
+ path.c_str()));
+ }
+
+ Json::Reader reader;
+ Json::Value root;
+ const char* data = (const char*)json->data();
+ if (!reader.parse(data, data+json->size(), root)) {
+ fail(SkStringPrintf("Couldn't parse JSON from %s.", path.c_str()));
+ }
+
+ for (unsigned i = 0; i < root.size(); i++) {
+ gUninterestingHashes.set(root[i].asCString(), true);
+ }
+ }
+}
+
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
template <typename T>
struct Tagged : public SkAutoTDelete<T> {
const char* tag;
@@ -435,7 +467,7 @@ struct Task {
FLAGS_readPath[0]));
}
- if (!FLAGS_writePath.isEmpty()) {
+ if (!FLAGS_writePath.isEmpty() && !gUninterestingHashes.find(md5.c_str(), md5.size())) {
const char* ext = task->sink->fileExtension();
if (data->getLength()) {
WriteToDisk(*task, md5, ext, data, data->getLength(), NULL);
@@ -625,6 +657,7 @@ int dm_main() {
start_keepalive();
gather_gold();
+ gather_uninteresting_hashes();
gather_srcs();
gather_sinks();
« 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