| 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 class SkBitmap; | 11 class SkBitmap; |
| 12 struct SkIPoint; | 12 struct SkIPoint; |
| 13 | 13 |
| 14 /** | 14 /** |
| 15 * Encapsulates an image difference metric algorithm that can be potentially run
asynchronously. | 15 * Encapsulates an image difference metric algorithm that can be potentially run
asynchronously. |
| 16 */ | 16 */ |
| 17 class SkImageDiffer { | 17 class SkImageDiffer { |
| 18 public: | 18 public: |
| 19 SkImageDiffer(); | 19 SkImageDiffer(); |
| 20 virtual ~SkImageDiffer(); | 20 virtual ~SkImageDiffer(); |
| 21 | 21 |
| 22 static const double RESULT_CORRECT = 1.0f; |
| 23 static const double RESULT_INCORRECT = 0.0f; |
| 24 |
| 22 /** | 25 /** |
| 23 * Gets a unique and descriptive name of this differ | 26 * Gets a unique and descriptive name of this differ |
| 24 * @return A statically allocated null terminated string that is the name of
this differ | 27 * @return A statically allocated null terminated string that is the name of
this differ |
| 25 */ | 28 */ |
| 26 virtual const char* getName() = 0; | 29 virtual const char* getName() = 0; |
| 27 | 30 |
| 28 /** | 31 /** |
| 29 * Gets if this differ is in a usable state | 32 * Gets if this differ is in a usable state |
| 30 * @return True if this differ can be used, false otherwise | 33 * @return True if this differ can be used, false otherwise |
| 31 */ | 34 */ |
| 32 bool isGood() { return fIsGood; } | 35 bool isGood() { return fIsGood; } |
| 33 | 36 |
| 34 /** | 37 /** |
| 35 * Gets if this differ needs to be initialized with and OpenCL device and co
ntext. | 38 * Gets if this differ needs to be initialized with and OpenCL device and co
ntext. |
| 36 */ | 39 */ |
| 37 virtual bool requiresOpenCL() { return false; } | 40 virtual bool requiresOpenCL() { return false; } |
| 38 | 41 |
| 39 /** | 42 /** |
| 43 * Enables the generation of an alpha mask for all points of interest. |
| 44 * @return True if the differ supports generating an alpha mask and false ot
herwise. |
| 45 */ |
| 46 virtual bool enablePOIAlphaMask() { return false; } |
| 47 |
| 48 /** |
| 40 * Wraps a call to queueDiff by loading the given filenames into SkBitmaps | 49 * Wraps a call to queueDiff by loading the given filenames into SkBitmaps |
| 41 * @param baseline The file path of the baseline image | 50 * @param baseline The file path of the baseline image |
| 42 * @param test The file path of the test image | 51 * @param test The file path of the test image |
| 43 * @return The results of queueDiff with the loaded bitmaps | 52 * @return The results of queueDiff with the loaded bitmaps |
| 44 */ | 53 */ |
| 45 int queueDiffOfFile(const char baseline[], const char test[]); | 54 int queueDiffOfFile(const char baseline[], const char test[]); |
| 46 | 55 |
| 47 /** | 56 /** |
| 48 * Queues a diff on a pair of bitmaps to be done at some future time. | 57 * Queues a diff on a pair of bitmaps to be done at some future time. |
| 49 * @param baseline The correct bitmap | 58 * @param baseline The correct bitmap |
| (...skipping 30 matching lines...) Expand all Loading... |
| 80 */ | 89 */ |
| 81 virtual int getPointsOfInterestCount(int id) = 0; | 90 virtual int getPointsOfInterestCount(int id) = 0; |
| 82 | 91 |
| 83 /** | 92 /** |
| 84 * Gets an array of the points of interest for the diff of the given id. The
results are only | 93 * Gets an array of the points of interest for the diff of the given id. The
results are only |
| 85 * meaningful after the queued diff has finished. | 94 * meaningful after the queued diff has finished. |
| 86 * @param id The id of the queued diff to query | 95 * @param id The id of the queued diff to query |
| 87 */ | 96 */ |
| 88 virtual SkIPoint* getPointsOfInterest(int id) = 0; | 97 virtual SkIPoint* getPointsOfInterest(int id) = 0; |
| 89 | 98 |
| 99 /* |
| 100 * Gets a bitmap containing an alpha mask containing transparent pixels at t
he points of |
| 101 * interest for the diff of the given id. The results are only meaningful af
ter the |
| 102 * queued diff has finished. |
| 103 * @param id The id of the queued diff to query |
| 104 */ |
| 105 virtual SkBitmap* getPointsOfInterestAlphaMask(int id) { return NULL; } |
| 90 | 106 |
| 91 | 107 |
| 92 protected: | 108 protected: |
| 93 bool fIsGood; | 109 bool fIsGood; |
| 94 }; | 110 }; |
| 95 | 111 |
| 96 | 112 |
| 97 #endif | 113 #endif |
| OLD | NEW |