| 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 // TODO(djsollen): Figure out a way that the differ can report which of
the |
| 28 // optional fields it has filled in. See http://skbug.com/2712 ('allow |
| 29 // skpdiff to report different sets of result fields for different compa
rison algorithms') |
| 27 SkBitmap poiAlphaMask; // optional | 30 SkBitmap poiAlphaMask; // optional |
| 31 SkBitmap rgbDiffBitmap; // optional |
| 32 SkBitmap whiteDiffBitmap; // optional |
| 33 int maxRedDiff; // optional |
| 34 int maxGreenDiff; // optional |
| 35 int maxBlueDiff; // optional |
| 28 double timeElapsed; // optional | 36 double timeElapsed; // optional |
| 29 }; | 37 }; |
| 30 | 38 |
| 39 // A bitfield indicating which bitmap types we want a differ to create. |
| 40 // |
| 41 // TODO(epoger): Remove whiteDiffBitmap, because alphaMask can provide |
| 42 // the same functionality and more. |
| 43 // It will be a little bit tricky, because the rebaseline_server client |
| 44 // and server side code will both need to change to use the alphaMask. |
| 45 struct BitmapsToCreate { |
| 46 bool alphaMask; |
| 47 bool rgbDiff; |
| 48 bool whiteDiff; |
| 49 }; |
| 50 |
| 31 /** | 51 /** |
| 32 * Gets a unique and descriptive name of this differ | 52 * Gets a unique and descriptive name of this differ |
| 33 * @return A statically allocated null terminated string that is the name of
this differ | 53 * @return A statically allocated null terminated string that is the name of
this differ |
| 34 */ | 54 */ |
| 35 virtual const char* getName() const = 0; | 55 virtual const char* getName() const = 0; |
| 36 | 56 |
| 37 /** | 57 /** |
| 38 * Gets if this differ needs to be initialized with and OpenCL device and co
ntext. | 58 * Gets if this differ needs to be initialized with and OpenCL device and co
ntext. |
| 39 */ | 59 */ |
| 40 virtual bool requiresOpenCL() const { return false; } | 60 virtual bool requiresOpenCL() const { return false; } |
| 41 | 61 |
| 42 /** | 62 /** |
| 43 * diff on a pair of bitmaps. | 63 * diff on a pair of bitmaps. |
| 44 * @param baseline The correct bitmap | 64 * @param baseline The correct bitmap |
| 45 * @param test The bitmap whose difference is being tested | 65 * @param test The bitmap whose difference is being tested |
| 46 * @param computeMask true if the differ is to attempt to create poiAlphaMa
sk | 66 * @param bitmapsToCreate Which bitmaps the differ should attempt to creat
e |
| 47 * @return true on success, and false in the case of failure | 67 * @return true on success, and false in the case of failure |
| 48 */ | 68 */ |
| 49 virtual bool diff(SkBitmap* baseline, SkBitmap* test, bool computeMask, | 69 virtual bool diff(SkBitmap* baseline, SkBitmap* test, const BitmapsToCreate&
bitmapsToCreate, |
| 50 Result* result) const = 0; | 70 Result* result) const = 0; |
| 51 }; | 71 }; |
| 52 | 72 |
| 53 #endif | 73 #endif |
| OLD | NEW |