OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkDiffContext_DEFINED | 8 #ifndef SkDiffContext_DEFINED |
9 #define SkDiffContext_DEFINED | 9 #define SkDiffContext_DEFINED |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 * Collects records of diffs and outputs them as JSON. | 21 * Collects records of diffs and outputs them as JSON. |
22 */ | 22 */ |
23 class SkDiffContext { | 23 class SkDiffContext { |
24 public: | 24 public: |
25 SkDiffContext(); | 25 SkDiffContext(); |
26 ~SkDiffContext(); | 26 ~SkDiffContext(); |
27 | 27 |
28 void setThreadCount(int threadCount) { fThreadCount = threadCount; } | 28 void setThreadCount(int threadCount) { fThreadCount = threadCount; } |
29 | 29 |
30 /** | 30 /** |
31 * Creates the directory if it does not exist and uses it to store differenc
es | 31 * Sets the directory within which to store alphaMasks (images that |
32 * between images. | 32 * are transparent for each pixel that differs between baseline and test). |
| 33 * |
| 34 * If the directory does not exist yet, it will be created. |
33 */ | 35 */ |
34 void setDifferenceDir(const SkString& directory); | 36 void setAlphaMaskDir(const SkString& directory); |
| 37 |
| 38 /** |
| 39 * Sets the directory within which to store rgbDiffs (images showing the |
| 40 * per-channel difference between baseline and test at each pixel). |
| 41 * |
| 42 * If the directory does not exist yet, it will be created. |
| 43 */ |
| 44 void setRgbDiffDir(const SkString& directory); |
| 45 |
| 46 /** |
| 47 * Sets the directory within which to store whiteDiffs (images showing white |
| 48 * for each pixel that differs between baseline and test). |
| 49 * |
| 50 * If the directory does not exist yet, it will be created. |
| 51 */ |
| 52 void setWhiteDiffDir(const SkString& directory); |
35 | 53 |
36 /** | 54 /** |
37 * Sets the differs to be used in each diff. Already started diffs will not
retroactively use | 55 * Sets the differs to be used in each diff. Already started diffs will not
retroactively use |
38 * these. | 56 * these. |
39 * @param differs An array of differs to use. The array is copied, but not t
he differs | 57 * @param differs An array of differs to use. The array is copied, but not t
he differs |
40 * themselves. | 58 * themselves. |
41 */ | 59 */ |
42 void setDiffers(const SkTDArray<SkImageDiffer*>& differs); | 60 void setDiffers(const SkTDArray<SkImageDiffer*>& differs); |
43 | 61 |
44 /** | 62 /** |
(...skipping 22 matching lines...) Expand all Loading... |
67 * | 85 * |
68 * The format of the JSON document is one top level array named "records". | 86 * The format of the JSON document is one top level array named "records". |
69 * Each record in the array is an object with the following values: | 87 * Each record in the array is an object with the following values: |
70 * "commonName" : string containing the common prefix of the baseline
Path | 88 * "commonName" : string containing the common prefix of the baseline
Path |
71 * and testPath filenames | 89 * and testPath filenames |
72 * "baselinePath" : string containing the path to the baseline image | 90 * "baselinePath" : string containing the path to the baseline image |
73 * "testPath" : string containing the path to the test image | 91 * "testPath" : string containing the path to the test image |
74 * "differencePath" : (optional) string containing the path to an alpha | 92 * "differencePath" : (optional) string containing the path to an alpha |
75 * mask of the pixel difference between the baseline | 93 * mask of the pixel difference between the baseline |
76 * and test images | 94 * and test images |
| 95 * TODO(epoger): consider renaming this "alphaMaskPath
" |
| 96 * to distinguish from other difference types? |
| 97 * "rgbDiffPath" : (optional) string containing the path to a bitmap |
| 98 * showing per-channel differences between the |
| 99 * baseline and test images at each pixel |
| 100 * "whiteDiffPath" : (optional) string containing the path to a bitmap |
| 101 * showing every pixel that differs between the |
| 102 * baseline and test images as white |
77 * | 103 * |
78 * They also have an array named "diffs" with each element being one diff re
cord for the two | 104 * They also have an array named "diffs" with each element being one diff re
cord for the two |
79 * images indicated in the above field. | 105 * images indicated in the above field. |
80 * A diff record includes: | 106 * A diff record includes: |
81 * "differName" : string name of the diff metric used | 107 * "differName" : string name of the diff metric used |
82 * "result" : numerical result of the diff | 108 * "result" : numerical result of the diff |
83 * | 109 * |
84 * Here is an example: | 110 * Here is an example: |
85 * | 111 * |
86 * { | 112 * { |
(...skipping 23 matching lines...) Expand all Loading... |
110 void outputCsv(SkWStream& stream); | 136 void outputCsv(SkWStream& stream); |
111 | 137 |
112 | 138 |
113 private: | 139 private: |
114 struct DiffData { | 140 struct DiffData { |
115 const char* fDiffName; | 141 const char* fDiffName; |
116 SkImageDiffer::Result fResult; | 142 SkImageDiffer::Result fResult; |
117 }; | 143 }; |
118 | 144 |
119 struct DiffRecord { | 145 struct DiffRecord { |
| 146 // TODO(djsollen): Some of these fields are required, while others are o
ptional |
| 147 // (e.g., fRgbDiffPath is only filled in if SkDifferentPixelsMetric |
| 148 // was run). Figure out a way to note that. See http://skbug.com/2712 |
| 149 // ('allow skpdiff to report different sets of result fields for |
| 150 // different comparison algorithms') |
120 SkString fCommonName; | 151 SkString fCommonName; |
121 SkString fDifferencePath; | 152 SkString fAlphaMaskPath; |
| 153 SkString fRgbDiffPath; |
| 154 SkString fWhiteDiffPath; |
122 SkString fBaselinePath; | 155 SkString fBaselinePath; |
123 SkString fTestPath; | 156 SkString fTestPath; |
| 157 SkISize fSize; |
| 158 int fMaxRedDiff; |
| 159 int fMaxGreenDiff; |
| 160 int fMaxBlueDiff; |
124 SkTArray<DiffData> fDiffs; | 161 SkTArray<DiffData> fDiffs; |
125 }; | 162 }; |
126 | 163 |
127 // Used to protect access to fRecords and ensure only one thread is | 164 // Used to protect access to fRecords and ensure only one thread is |
128 // adding new entries at a time. | 165 // adding new entries at a time. |
129 SkMutex fRecordMutex; | 166 SkMutex fRecordMutex; |
130 | 167 |
131 // We use linked list for the records so that their pointers remain stable.
A resizable array | 168 // We use linked list for the records so that their pointers remain stable.
A resizable array |
132 // might change its pointers, which would make it harder for async diffs to
record their | 169 // might change its pointers, which would make it harder for async diffs to
record their |
133 // results. | 170 // results. |
134 SkTLList<DiffRecord> fRecords; | 171 SkTLList<DiffRecord> fRecords; |
135 | 172 |
136 SkImageDiffer** fDiffers; | 173 SkImageDiffer** fDiffers; |
137 int fDifferCount; | 174 int fDifferCount; |
138 int fThreadCount; | 175 int fThreadCount; |
139 | 176 |
140 SkString fDifferenceDir; | 177 SkString fAlphaMaskDir; |
| 178 SkString fRgbDiffDir; |
| 179 SkString fWhiteDiffDir; |
141 }; | 180 }; |
142 | 181 |
143 #endif | 182 #endif |
OLD | NEW |