scroggo | 7a10fb6 | 2014-11-04 07:21:10 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef DMJsonWriter_DEFINED |
| 9 | #define DMJsonWriter_DEFINED |
| 10 | |
| 11 | #include "SkString.h" |
scroggo | 0ee2627 | 2014-11-07 06:07:32 -0800 | [diff] [blame] | 12 | #include "Test.h" |
scroggo | 7a10fb6 | 2014-11-04 07:21:10 -0800 | [diff] [blame] | 13 | |
| 14 | namespace DM { |
| 15 | |
| 16 | /** |
| 17 | * Class for collecting results from DM and writing to a json file. |
| 18 | * All methods are thread-safe. |
| 19 | */ |
| 20 | class JsonWriter { |
| 21 | public: |
| 22 | /** |
| 23 | * Info describing a single run. |
| 24 | */ |
| 25 | struct BitmapResult { |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 26 | SkString name; // E.g. "ninepatch-stretch", "desk_gws.skp" |
| 27 | SkString config; // "gpu", "8888", "serialize", "pipe" |
| 28 | SkString sourceType; // "gm", "skp", "image" |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 29 | SkString sourceOptions; // "image", "codec", "subset", "scanline" |
scroggo | 7a10fb6 | 2014-11-04 07:21:10 -0800 | [diff] [blame] | 30 | SkString md5; // In ASCII, so 32 bytes long. |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 31 | SkString ext; // Extension of file we wrote: "png", "pdf", ... |
Mike Klein | 66f09a7 | 2019-02-12 13:03:54 -0500 | [diff] [blame] | 32 | SkString gamut; |
| 33 | SkString transferFn; |
Mike Klein | 0abbaca | 2019-03-06 09:57:49 -0600 | [diff] [blame^] | 34 | SkString colorType; |
| 35 | SkString alphaType; |
scroggo | 7a10fb6 | 2014-11-04 07:21:10 -0800 | [diff] [blame] | 36 | }; |
| 37 | |
| 38 | /** |
| 39 | * Add a result to the end of the list of results. |
| 40 | */ |
| 41 | static void AddBitmapResult(const BitmapResult&); |
| 42 | |
| 43 | /** |
scroggo | 0ee2627 | 2014-11-07 06:07:32 -0800 | [diff] [blame] | 44 | * Add a Failure from a Test. |
| 45 | */ |
| 46 | static void AddTestFailure(const skiatest::Failure&); |
| 47 | |
| 48 | /** |
scroggo | 7a10fb6 | 2014-11-04 07:21:10 -0800 | [diff] [blame] | 49 | * Write all collected results to the file FLAGS_writePath[0]/dm.json. |
| 50 | */ |
| 51 | static void DumpJson(); |
Brian Osman | 57796b3 | 2019-01-25 18:02:59 +0000 | [diff] [blame] | 52 | |
| 53 | /** |
| 54 | * Read JSON file at path written by DumpJson, calling callback for each |
| 55 | * BitmapResult recorded in the file. Return success. |
| 56 | */ |
| 57 | static bool ReadJson(const char* path, void(*callback)(BitmapResult)); |
scroggo | 7a10fb6 | 2014-11-04 07:21:10 -0800 | [diff] [blame] | 58 | }; |
| 59 | |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 60 | |
scroggo | 7a10fb6 | 2014-11-04 07:21:10 -0800 | [diff] [blame] | 61 | } // namespace DM |
| 62 | #endif // DMJsonWriter_DEFINED |