Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2013 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 SkDiffContext_DEFINED | |
| 9 #define SkDiffContext_DEFINED | |
| 10 | |
| 11 #include "SkString.h" | |
| 12 #include "SkTArray.h" | |
| 13 #include "SkTDArray.h" | |
| 14 | |
| 15 class SkWStream; | |
| 16 class SkImageDiffer; | |
| 17 | |
| 18 /** | |
| 19 * Collects records of diffs and outputs them as JSON. | |
| 20 */ | |
| 21 class SkDiffContext { | |
| 22 public: | |
| 23 SkDiffContext(); | |
| 24 ~SkDiffContext(); | |
| 25 | |
| 26 /** | |
| 27 * Sets the differs to be used in each diff. Already started diffs will not retroactively use | |
| 28 * these. | |
| 29 * @param differs An array of differs to use. The array is copied, but not t he differs | |
| 30 * themselves. | |
| 31 */ | |
| 32 void setDiffers(const SkTDArray<SkImageDiffer*>& differs); | |
| 33 | |
| 34 /** | |
| 35 * Compares two directories of images with the given differ | |
| 36 * @param baselinePath The baseline directory's path | |
| 37 * @param testPath The test directory's path | |
| 38 */ | |
| 39 void diffDirectories(const char baselinePath[], const char testPath[]); | |
| 40 | |
| 41 /** | |
| 42 * Compares two sets of images identified by glob style patterns with the gi ven differ | |
| 43 * @param baselinePattern A pattern for baseline files | |
| 44 * @param testPattern A pattern for test files that matches each file of the baseline file | |
| 45 */ | |
| 46 void diffPatterns(const char baselinePattern[], const char testPattern[]); | |
| 47 | |
| 48 /** | |
| 49 * Compares the images at the given paths | |
| 50 * @param baselinePath The baseline file path | |
| 51 * @param testPath The matching test file path | |
| 52 */ | |
| 53 void addDiff(const char* baselinePath, const char* testPath); | |
| 54 | |
| 55 /** | |
| 56 * Output the records of each diff in JSON | |
| 57 * @param stream The stream to output the diff to | |
| 58 */ | |
| 59 void outputRecords(SkWStream& stream); | |
| 60 | |
| 61 private: | |
| 62 struct DiffData { | |
| 63 const char* fDiffName; | |
| 64 double fResult; | |
| 65 SkTDArray<SkIPoint> fPointsOfInterest; | |
| 66 }; | |
| 67 | |
| 68 struct DiffRecord { | |
| 69 SkString fBaselinePath; | |
| 70 SkString fTestPath; | |
| 71 SkTArray<DiffData> fDiffs; | |
| 72 DiffRecord* fNext; | |
| 73 }; | |
| 74 | |
| 75 // We use linked list for the records so that their pointers remain stable. A resizable array | |
| 76 // might change its pointers, which would make it harder for async diffs to record their | |
| 77 // results. | |
| 78 DiffRecord * fRecords; | |
| 79 | |
| 80 SkImageDiffer** fDiffers; | |
| 81 size_t fDifferCount; | |
|
bsalomon
2013/07/02 13:37:15
Does this really need to be 64 bits on a 64 bit ma
| |
| 82 }; | |
| 83 | |
| 84 #endif | |
| OLD | NEW |