aboutsummaryrefslogtreecommitdiffhomepage
path: root/dm
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2014-09-09 07:59:46 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-09-09 07:59:46 -0700
commitea65bfa8ded918b908287e3e3474aaf5cbd12fea (patch)
tree466469207e976828154517fe8201f8032d9e0433 /dm
parent197ceda92966359962c51923a01dd2b0018b080f (diff)
Update DM JSON format.
Ex. dm --match patch -w bad --key arch x86 gpu nvidia model z620 --properties git_hash abcd build_number 20 -> { "build_number" : "20", "git_hash" : "abcd", "key" : { "arch" : "x86", "gpu" : "nvidia", "model" : "z620" }, "results" : [ { "key" : { "config" : "565", "name" : "ninepatch-stretch" }, "md5" : "f78cfafcbabaf815f3dfcf61fb59acc7", "options" : { "source_type" : "GM" } }, { "key" : { "config" : "8888", "name" : "ninepatch-stretch" }, "md5" : "3e8a42f35a1e76f00caa191e6310d789", "options" : { "source_type" : "GM" } }, ... This breaks -r, but that's okay. Going to follow up this CL with one that removes that entirely. BUG=skia: R=stephana@google.com, jcgregorio@google.com, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/551873003
Diffstat (limited to 'dm')
-rw-r--r--dm/DMCpuGMTask.cpp2
-rw-r--r--dm/DMGpuGMTask.cpp2
-rw-r--r--dm/DMPDFRasterizeTask.cpp2
-rw-r--r--dm/DMPDFTask.cpp3
-rw-r--r--dm/DMPipeTask.cpp2
-rw-r--r--dm/DMQuiltTask.cpp2
-rw-r--r--dm/DMSKPTask.cpp2
-rw-r--r--dm/DMSerializeTask.cpp2
-rw-r--r--dm/DMWriteTask.cpp46
-rw-r--r--dm/DMWriteTask.h14
10 files changed, 49 insertions, 28 deletions
diff --git a/dm/DMCpuGMTask.cpp b/dm/DMCpuGMTask.cpp
index da650c454b..63a3c424c8 100644
--- a/dm/DMCpuGMTask.cpp
+++ b/dm/DMCpuGMTask.cpp
@@ -43,7 +43,7 @@ void CpuGMTask::draw() {
SPAWN(SerializeTask, fGMFactory(NULL), bm, SerializeTask::kNormal_Mode);
SPAWN(SerializeTask, fGMFactory(NULL), bm, SerializeTask::kSkRecord_Mode);
- SPAWN(WriteTask, bm);
+ SPAWN(WriteTask, "GM", bm);
#undef SPAWN
}
diff --git a/dm/DMGpuGMTask.cpp b/dm/DMGpuGMTask.cpp
index 63c9649037..3178fd6d99 100644
--- a/dm/DMGpuGMTask.cpp
+++ b/dm/DMGpuGMTask.cpp
@@ -44,7 +44,7 @@ void GpuGMTask::draw(GrContextFactory* grFactory) {
bitmap.setInfo(info);
canvas->readPixels(&bitmap, 0, 0);
- this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
+ this->spawnChild(SkNEW_ARGS(WriteTask, (*this, "GM", bitmap)));
}
bool GpuGMTask::shouldSkip() const {
diff --git a/dm/DMPDFRasterizeTask.cpp b/dm/DMPDFRasterizeTask.cpp
index f9573e4912..d32178b78b 100644
--- a/dm/DMPDFRasterizeTask.cpp
+++ b/dm/DMPDFRasterizeTask.cpp
@@ -29,7 +29,7 @@ void PDFRasterizeTask::draw() {
SkBitmap bitmap;
if (fRasterize(fPdf.get(), &bitmap)) {
- this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
+ this->spawnChild(SkNEW_ARGS(WriteTask, (*this, "PDF", bitmap)));
} else {
this->fail();
}
diff --git a/dm/DMPDFTask.cpp b/dm/DMPDFTask.cpp
index c047771587..c996aae53c 100644
--- a/dm/DMPDFTask.cpp
+++ b/dm/DMPDFTask.cpp
@@ -86,8 +86,9 @@ void PDFTask::draw() {
this->spawnChild(SkNEW_ARGS(PDFRasterizeTask,
(*this, pdfData->duplicate(), fRasterize)));
}
+ const char* sourceType = fGM.get() ? "GM" : "SKP";
this->spawnChild(SkNEW_ARGS(WriteTask,
- (*this, pdfData->duplicate(), ".pdf")));
+ (*this, sourceType, pdfData->duplicate(), ".pdf")));
}
bool PDFTask::shouldSkip() const {
diff --git a/dm/DMPipeTask.cpp b/dm/DMPipeTask.cpp
index 22404ec083..c7c64bd578 100644
--- a/dm/DMPipeTask.cpp
+++ b/dm/DMPipeTask.cpp
@@ -61,7 +61,7 @@ void PipeTask::draw() {
if (!BitmapsEqual(bitmap, fReference)) {
this->fail();
- this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
+ this->spawnChild(SkNEW_ARGS(WriteTask, (*this, "GM", bitmap)));
}
}
diff --git a/dm/DMQuiltTask.cpp b/dm/DMQuiltTask.cpp
index 6ffe360ea8..9898dda74a 100644
--- a/dm/DMQuiltTask.cpp
+++ b/dm/DMQuiltTask.cpp
@@ -107,7 +107,7 @@ void QuiltTask::draw() {
if (!BitmapsEqual(full, fReference)) {
this->fail();
- this->spawnChild(SkNEW_ARGS(WriteTask, (*this, full)));
+ this->spawnChild(SkNEW_ARGS(WriteTask, (*this, "GM", full)));
}
}
diff --git a/dm/DMSKPTask.cpp b/dm/DMSKPTask.cpp
index 21bd9b13fd..d633594ffc 100644
--- a/dm/DMSKPTask.cpp
+++ b/dm/DMSKPTask.cpp
@@ -25,7 +25,7 @@ void SKPTask::draw() {
AllocatePixels(kN32_SkColorType, width, height, &bitmap);
DrawPicture(*fPicture, &bitmap);
- this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
+ this->spawnChild(SkNEW_ARGS(WriteTask, (*this, "SKP", bitmap)));
}
} // namespace DM
diff --git a/dm/DMSerializeTask.cpp b/dm/DMSerializeTask.cpp
index 1ffe3ca8fd..8116a2ea51 100644
--- a/dm/DMSerializeTask.cpp
+++ b/dm/DMSerializeTask.cpp
@@ -39,7 +39,7 @@ void SerializeTask::draw() {
DrawPicture(*reconstructed, &bitmap);
if (!BitmapsEqual(bitmap, fReference)) {
this->fail();
- this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
+ this->spawnChild(SkNEW_ARGS(WriteTask, (*this, "GM", bitmap)));
}
}
diff --git a/dm/DMWriteTask.cpp b/dm/DMWriteTask.cpp
index f8073e3390..95f162d313 100644
--- a/dm/DMWriteTask.cpp
+++ b/dm/DMWriteTask.cpp
@@ -36,26 +36,22 @@ inline static SkString find_base_name(const Task& parent, SkTArray<SkString>* su
return SkString(name.c_str(), name.size() - totalSuffixLength);
}
-struct JsonData {
- SkString name;
- SkString md5; // In ASCII, so 32 bytes long.
-};
-SkTArray<JsonData> gJsonData;
-SK_DECLARE_STATIC_MUTEX(gJsonDataLock);
-
-WriteTask::WriteTask(const Task& parent, SkBitmap bitmap)
+WriteTask::WriteTask(const Task& parent, const char* sourceType, SkBitmap bitmap)
: CpuTask(parent)
- , fFullName(parent.name())
, fBaseName(find_base_name(parent, &fSuffixes))
+ , fSourceType(sourceType)
, fBitmap(bitmap)
, fData(NULL)
, fExtension(".png") {
}
-WriteTask::WriteTask(const Task& parent, SkStreamAsset *data, const char* ext)
+WriteTask::WriteTask(const Task& parent,
+ const char* sourceType,
+ SkStreamAsset *data,
+ const char* ext)
: CpuTask(parent)
- , fFullName(parent.name())
, fBaseName(find_base_name(parent, &fSuffixes))
+ , fSourceType(sourceType)
, fData(data)
, fExtension(ext) {
SkASSERT(fData.get());
@@ -90,6 +86,15 @@ static SkString get_md5(SkStreamAsset* src) {
return md5;
}
+struct JsonData {
+ SkString name; // E.g. "ninepatch-stretch", "desk-gws_skp"
+ SkString config; // "gpu", "8888"
+ SkString sourceType; // "GM", "SKP"
+ SkString md5; // In ASCII, so 32 bytes long.
+};
+SkTArray<JsonData> gJsonData;
+SK_DECLARE_STATIC_MUTEX(gJsonDataLock);
+
void WriteTask::draw() {
if (!fData.get()) {
fData.reset(encode_to_png(fBitmap));
@@ -98,7 +103,7 @@ void WriteTask::draw() {
}
}
- JsonData entry = { fFullName, get_md5(fData) };
+ JsonData entry = { fBaseName, fSuffixes[0], fSourceType, get_md5(fData) };
{
SkAutoMutexAcquire lock(&gJsonDataLock);
gJsonData.push_back(entry);
@@ -164,12 +169,25 @@ void WriteTask::DumpJson() {
return;
}
- // FIXME: This JSON format is a complete MVP strawman.
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++) {
- root[gJsonData[i].name.c_str()] = gJsonData[i].md5.c_str();
+ Json::Value result;
+ result["key"]["name"] = gJsonData[i].name.c_str();
+ result["key"]["config"] = gJsonData[i].config.c_str();
+ result["options"]["source_type"] = gJsonData[i].sourceType.c_str();
+ result["md5"] = gJsonData[i].md5.c_str();
+
+ root["results"].append(result);
}
}
diff --git a/dm/DMWriteTask.h b/dm/DMWriteTask.h
index f83289ca2e..d2403adfc5 100644
--- a/dm/DMWriteTask.h
+++ b/dm/DMWriteTask.h
@@ -16,13 +16,15 @@ namespace DM {
class WriteTask : public CpuTask {
public:
- WriteTask(const Task& parent, // WriteTask must be a child task.
- SkBitmap bitmap); // Bitmap to encode to PNG and write to disk.
+ WriteTask(const Task& parent, // WriteTask must be a child task.
+ const char* sourceType, // E.g. "GM", "SKP". For humans.
+ SkBitmap bitmap); // Bitmap to encode to PNG and write to disk.
// Takes ownership of SkStreamAsset
- WriteTask(const Task& parent, // WriteTask must be a child task.
- SkStreamAsset* data, // Pre-encoded data to write to disk.
- const char* ext); // File extension.
+ WriteTask(const Task& parent, // WriteTask must be a child task.
+ const char* sourceType, // E.g. "GM", "SKP". For humans.
+ SkStreamAsset* data, // Pre-encoded data to write to disk.
+ const char* ext); // File extension.
virtual void draw() SK_OVERRIDE;
virtual bool shouldSkip() const SK_OVERRIDE;
@@ -32,8 +34,8 @@ public:
private:
SkTArray<SkString> fSuffixes;
- const SkString fFullName;
const SkString fBaseName;
+ const SkString fSourceType;
const SkBitmap fBitmap;
SkAutoTDelete<SkStreamAsset> fData;
const char* fExtension;