| 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 SkImageDiffer_DEFINED | 8 #ifndef SkImageDiffer_DEFINED |
| 9 #define SkImageDiffer_DEFINED | 9 #define SkImageDiffer_DEFINED |
| 10 | 10 |
| 11 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * Encapsulates an image difference metric algorithm that can be potentially run
asynchronously. | 14 * Encapsulates an image difference metric algorithm that can be potentially run
asynchronously. |
| 15 */ | 15 */ |
| 16 class SkImageDiffer { | 16 class SkImageDiffer { |
| 17 public: | 17 public: |
| 18 SkImageDiffer(); | 18 SkImageDiffer(); |
| 19 virtual ~SkImageDiffer(); | 19 virtual ~SkImageDiffer(); |
| 20 | 20 |
| 21 static const double RESULT_CORRECT; | 21 static const double RESULT_CORRECT; |
| 22 static const double RESULT_INCORRECT; | 22 static const double RESULT_INCORRECT; |
| 23 | 23 |
| 24 struct Result { | 24 struct Result { |
| 25 double result; | 25 double result; |
| 26 int poiCount; | 26 int poiCount; |
| 27 SkBitmap poiAlphaMask; // optional | 27 SkBitmap poiAlphaMask; // optional |
| 28 SkBitmap rgbDiffBitmap; // optional |
| 29 SkBitmap whiteDiffBitmap; // optional |
| 30 int maxRedDiff; // optional |
| 31 int maxGreenDiff; // optional |
| 32 int maxBlueDiff; // optional |
| 28 double timeElapsed; // optional | 33 double timeElapsed; // optional |
| 29 }; | 34 }; |
| 30 | 35 |
| 31 /** | 36 /** |
| 32 * Gets a unique and descriptive name of this differ | 37 * Gets a unique and descriptive name of this differ |
| 33 * @return A statically allocated null terminated string that is the name of
this differ | 38 * @return A statically allocated null terminated string that is the name of
this differ |
| 34 */ | 39 */ |
| 35 virtual const char* getName() const = 0; | 40 virtual const char* getName() const = 0; |
| 36 | 41 |
| 37 /** | 42 /** |
| 38 * Gets if this differ needs to be initialized with and OpenCL device and co
ntext. | 43 * Gets if this differ needs to be initialized with and OpenCL device and co
ntext. |
| 39 */ | 44 */ |
| 40 virtual bool requiresOpenCL() const { return false; } | 45 virtual bool requiresOpenCL() const { return false; } |
| 41 | 46 |
| 42 /** | 47 /** |
| 43 * diff on a pair of bitmaps. | 48 * diff on a pair of bitmaps. |
| 44 * @param baseline The correct bitmap | 49 * @param baseline The correct bitmap |
| 45 * @param test The bitmap whose difference is being tested | 50 * @param test The bitmap whose difference is being tested |
| 46 * @param computeMask true if the differ is to attempt to create poiAlphaMa
sk | 51 * @param computeAlphaMask true if the differ is to attempt to create poiAl
phaMask |
| 52 * @param computeRgbDiff true if the differ is to attempt to create rgbDi
ffBitmap |
| 53 * @param computeWhiteDiff true if the differ is to attempt to create white
DiffBitmap |
| 47 * @return true on success, and false in the case of failure | 54 * @return true on success, and false in the case of failure |
| 48 */ | 55 */ |
| 49 virtual bool diff(SkBitmap* baseline, SkBitmap* test, bool computeMask, | 56 virtual bool diff(SkBitmap* baseline, SkBitmap* test, bool computeAlphaMask, |
| 50 Result* result) const = 0; | 57 bool computeRgbDiff, bool computeWhiteDiff, Result* result
) const = 0; |
| 51 }; | 58 }; |
| 52 | 59 |
| 53 #endif | 60 #endif |
| OLD | NEW |