2014-11-04 15:21:10 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2014 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DMJsonWriter_DEFINED
|
|
|
|
#define DMJsonWriter_DEFINED
|
|
|
|
|
2019-03-25 15:54:59 +00:00
|
|
|
#include "CommandLineFlags.h"
|
2014-11-04 15:21:10 +00:00
|
|
|
#include "SkString.h"
|
|
|
|
|
|
|
|
namespace DM {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class for collecting results from DM and writing to a json file.
|
|
|
|
* All methods are thread-safe.
|
|
|
|
*/
|
|
|
|
class JsonWriter {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Info describing a single run.
|
|
|
|
*/
|
|
|
|
struct BitmapResult {
|
2015-01-15 18:56:12 +00:00
|
|
|
SkString name; // E.g. "ninepatch-stretch", "desk_gws.skp"
|
|
|
|
SkString config; // "gpu", "8888", "serialize", "pipe"
|
|
|
|
SkString sourceType; // "gm", "skp", "image"
|
2015-04-03 14:24:48 +00:00
|
|
|
SkString sourceOptions; // "image", "codec", "subset", "scanline"
|
2014-11-04 15:21:10 +00:00
|
|
|
SkString md5; // In ASCII, so 32 bytes long.
|
2015-01-15 18:56:12 +00:00
|
|
|
SkString ext; // Extension of file we wrote: "png", "pdf", ...
|
2019-02-12 18:03:54 +00:00
|
|
|
SkString gamut;
|
|
|
|
SkString transferFn;
|
2019-03-06 15:57:49 +00:00
|
|
|
SkString colorType;
|
|
|
|
SkString alphaType;
|
2019-03-07 20:11:16 +00:00
|
|
|
SkString colorDepth;
|
2014-11-04 15:21:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a result to the end of the list of results.
|
|
|
|
*/
|
|
|
|
static void AddBitmapResult(const BitmapResult&);
|
|
|
|
|
|
|
|
/**
|
2019-03-25 15:54:59 +00:00
|
|
|
* Write all collected results to the file dir/dm.json.
|
2014-11-04 15:21:10 +00:00
|
|
|
*/
|
2019-03-25 15:54:59 +00:00
|
|
|
static void DumpJson(const char* dir,
|
|
|
|
CommandLineFlags::StringArray key,
|
|
|
|
CommandLineFlags::StringArray properties);
|
2019-01-25 18:02:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Read JSON file at path written by DumpJson, calling callback for each
|
|
|
|
* BitmapResult recorded in the file. Return success.
|
|
|
|
*/
|
|
|
|
static bool ReadJson(const char* path, void(*callback)(BitmapResult));
|
2014-11-04 15:21:10 +00:00
|
|
|
};
|
|
|
|
|
2015-01-27 22:46:26 +00:00
|
|
|
|
2014-11-04 15:21:10 +00:00
|
|
|
} // namespace DM
|
|
|
|
#endif // DMJsonWriter_DEFINED
|