Chromium Code Reviews| Index: experimental/skpdiff/SkDiffContext.h |
| diff --git a/experimental/skpdiff/SkDiffContext.h b/experimental/skpdiff/SkDiffContext.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..44c8a1438b67555c9fa586143c9c7abc25b0bed7 |
| --- /dev/null |
| +++ b/experimental/skpdiff/SkDiffContext.h |
| @@ -0,0 +1,84 @@ |
| +/* |
| + * Copyright 2013 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#ifndef SkDiffContext_DEFINED |
| +#define SkDiffContext_DEFINED |
| + |
| +#include "SkString.h" |
| +#include "SkTArray.h" |
| +#include "SkTDArray.h" |
| + |
| +class SkWStream; |
| +class SkImageDiffer; |
| + |
| +/** |
| + * Collects records of diffs and outputs them as JSON. |
| + */ |
| +class SkDiffContext { |
| +public: |
| + SkDiffContext(); |
| + ~SkDiffContext(); |
| + |
| + /** |
| + * Sets the differs to be used in each diff. Already started diffs will not retroactively use |
| + * these. |
| + * @param differs An array of differs to use. The array is copied, but not the differs |
| + * themselves. |
| + */ |
| + void setDiffers(const SkTDArray<SkImageDiffer*>& differs); |
| + |
| + /** |
| + * Compares two directories of images with the given differ |
| + * @param baselinePath The baseline directory's path |
| + * @param testPath The test directory's path |
| + */ |
| + void diffDirectories(const char baselinePath[], const char testPath[]); |
| + |
| + /** |
| + * Compares two sets of images identified by glob style patterns with the given differ |
| + * @param baselinePattern A pattern for baseline files |
| + * @param testPattern A pattern for test files that matches each file of the baseline file |
| + */ |
| + void diffPatterns(const char baselinePattern[], const char testPattern[]); |
| + |
| + /** |
| + * Compares the images at the given paths |
| + * @param baselinePath The baseline file path |
| + * @param testPath The matching test file path |
| + */ |
| + void addDiff(const char* baselinePath, const char* testPath); |
| + |
| + /** |
| + * Output the records of each diff in JSON |
| + * @param stream The stream to output the diff to |
| + */ |
| + void outputRecords(SkWStream& stream); |
| + |
| +private: |
| + struct DiffData { |
| + const char* fDiffName; |
| + double fResult; |
| + SkTDArray<SkIPoint> fPointsOfInterest; |
| + }; |
| + |
| + struct DiffRecord { |
| + SkString fBaselinePath; |
| + SkString fTestPath; |
| + SkTArray<DiffData> fDiffs; |
| + DiffRecord* fNext; |
| + }; |
| + |
| + // We use linked list for the records so that their pointers remain stable. A resizable array |
| + // might change its pointers, which would make it harder for async diffs to record their |
| + // results. |
| + DiffRecord * fRecords; |
| + |
| + SkImageDiffer** fDiffers; |
| + size_t fDifferCount; |
|
bsalomon
2013/07/02 13:37:15
Does this really need to be 64 bits on a 64 bit ma
|
| +}; |
| + |
| +#endif |