Chromium Code Reviews| 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: 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 | |
|
djsollen
2014/06/12 13:27:00
Why do you need a whiteDiffPath? It stores the ex
epoger
2014/06/12 14:02:34
I'll try that. A big concern for me is making it
| |
| 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 24 matching lines...) Expand all Loading... | |
| 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 { |
| 120 SkString fCommonName; | 146 SkString fCommonName; |
| 121 SkString fDifferencePath; | 147 SkString fAlphaMaskPath; |
| 148 SkString fRgbDiffPath; | |
| 149 SkString fWhiteDiffPath; | |
| 122 SkString fBaselinePath; | 150 SkString fBaselinePath; |
| 123 SkString fTestPath; | 151 SkString fTestPath; |
| 152 int fWidth; | |
| 153 int fHeight; | |
| 154 int fMaxRedDiff; | |
| 155 int fMaxGreenDiff; | |
| 156 int fMaxBlueDiff; | |
| 124 SkTArray<DiffData> fDiffs; | 157 SkTArray<DiffData> fDiffs; |
| 125 }; | 158 }; |
| 126 | 159 |
| 127 // Used to protect access to fRecords and ensure only one thread is | 160 // Used to protect access to fRecords and ensure only one thread is |
| 128 // adding new entries at a time. | 161 // adding new entries at a time. |
| 129 SkMutex fRecordMutex; | 162 SkMutex fRecordMutex; |
| 130 | 163 |
| 131 // We use linked list for the records so that their pointers remain stable. A resizable array | 164 // 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 | 165 // might change its pointers, which would make it harder for async diffs to record their |
| 133 // results. | 166 // results. |
| 134 SkTLList<DiffRecord> fRecords; | 167 SkTLList<DiffRecord> fRecords; |
| 135 | 168 |
| 136 SkImageDiffer** fDiffers; | 169 SkImageDiffer** fDiffers; |
| 137 int fDifferCount; | 170 int fDifferCount; |
| 138 int fThreadCount; | 171 int fThreadCount; |
| 139 | 172 |
| 140 SkString fDifferenceDir; | 173 SkString fAlphaMaskDir; |
| 174 SkString fRgbDiffDir; | |
| 175 SkString fWhiteDiffDir; | |
| 141 }; | 176 }; |
| 142 | 177 |
| 143 #endif | 178 #endif |
| OLD | NEW |