Add a "mode" tag to key in DM json output.

This lets us distinguish the original ("direct") runs from their replay modes.

There was a bit of a bug in here now fixed: we used the first entry in
fSuffixes as the config.  Actually, the last entry in suffixes is the
config.  This is moot when there's only one suffix (direct drawing), but
for mode drawing we were recording the mode as config!  Now it's correct.

Here's some example output where I rigged a bunch of modes to fail:

{
   "results" : [
      {
         "key" : {
            "config" : "565",
            "mode" : "default-nobbh",
            "name" : "xfermodes2"
         },
         "md5" : "2daf6f7e2b8e56543b92068a10d2179e",
         "options" : {
            "source_type" : "GM"
         }
      },
      {
         "key" : {
            "config" : "8888",
            "mode" : "default-nobbh",
            "name" : "xfermodes2"
         },
         "md5" : "490361e8a52800d29558bc23876da8c6",
         "options" : {
            "source_type" : "GM"
         }
      },
...
      {
         "key" : {
            "config" : "565",
            "mode" : "direct",
            "name" : "xfermodes2"
         },
         "md5" : "92a3801d5914d6c2662904a3bb50d2b9",
         "options" : {
            "source_type" : "GM"
         }
      },
...
      {
         "key" : {
            "config" : "8888",
            "mode" : "direct",
            "name" : "xfermodes2"
         },
         "md5" : "e7e8b3e9d31e601acaaff4633ed5f63a",
         "options" : {
            "source_type" : "GM"
         }
      },

BUG=skia:
R=jcgregorio@google.com, mtklein@google.com

Author: mtklein@chromium.org

Review URL: https://codereview.chromium.org/586533005
This commit is contained in:
mtklein 2014-09-19 10:35:07 -07:00 committed by Commit bot
parent 3bc25e7247
commit 87e2437fe5

View File

@ -78,10 +78,11 @@ static SkString get_md5(const void* ptr, size_t len) {
}
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.
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);
@ -94,7 +95,14 @@ void WriteTask::draw() {
: get_md5(fBitmap.getPixels(), fBitmap.getSize());
}
JsonData entry = { fBaseName, fSuffixes[0], fSourceType, md5 };
SkASSERT(fSuffixes.count() > 0);
SkString config = fSuffixes.back();
SkString mode("direct");
if (fSuffixes.count() > 1) {
mode = fSuffixes.fromBack(1);
}
JsonData entry = { fBaseName, config, mode, fSourceType, md5 };
{
SkAutoMutexAcquire lock(&gJsonDataLock);
gJsonData.push_back(entry);
@ -176,6 +184,7 @@ void WriteTask::DumpJson() {
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();