commit-bot@chromium.org | be19b9e | 2013-06-14 17:26:54 +0000 | [diff] [blame] | 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 SkImageDiffer_DEFINED |
| 9 | #define SkImageDiffer_DEFINED |
| 10 | |
djsollen@google.com | efc51b7 | 2013-11-12 18:29:17 +0000 | [diff] [blame] | 11 | #include "SkBitmap.h" |
commit-bot@chromium.org | be19b9e | 2013-06-14 17:26:54 +0000 | [diff] [blame] | 12 | |
| 13 | /** |
| 14 | * Encapsulates an image difference metric algorithm that can be potentially run asynchronously. |
| 15 | */ |
| 16 | class SkImageDiffer { |
| 17 | public: |
| 18 | SkImageDiffer(); |
| 19 | virtual ~SkImageDiffer(); |
| 20 | |
djsollen@google.com | 2761b30d | 2013-11-07 19:40:35 +0000 | [diff] [blame] | 21 | static const double RESULT_CORRECT; |
| 22 | static const double RESULT_INCORRECT; |
djsollen@google.com | 513a7bf | 2013-11-07 19:24:06 +0000 | [diff] [blame] | 23 | |
djsollen@google.com | efc51b7 | 2013-11-12 18:29:17 +0000 | [diff] [blame] | 24 | struct Result { |
| 25 | double result; |
| 26 | int poiCount; |
| 27 | SkBitmap poiAlphaMask; // optional |
| 28 | double timeElapsed; // optional |
| 29 | }; |
| 30 | |
commit-bot@chromium.org | be19b9e | 2013-06-14 17:26:54 +0000 | [diff] [blame] | 31 | /** |
| 32 | * Gets a unique and descriptive name of this differ |
| 33 | * @return A statically allocated null terminated string that is the name of this differ |
| 34 | */ |
djsollen@google.com | efc51b7 | 2013-11-12 18:29:17 +0000 | [diff] [blame] | 35 | virtual const char* getName() const = 0; |
commit-bot@chromium.org | be19b9e | 2013-06-14 17:26:54 +0000 | [diff] [blame] | 36 | |
| 37 | /** |
zachr@google.com | d658568 | 2013-07-17 19:29:19 +0000 | [diff] [blame] | 38 | * Gets if this differ needs to be initialized with and OpenCL device and context. |
| 39 | */ |
djsollen@google.com | efc51b7 | 2013-11-12 18:29:17 +0000 | [diff] [blame] | 40 | virtual bool requiresOpenCL() const { return false; } |
zachr@google.com | d658568 | 2013-07-17 19:29:19 +0000 | [diff] [blame] | 41 | |
| 42 | /** |
djsollen@google.com | efc51b7 | 2013-11-12 18:29:17 +0000 | [diff] [blame] | 43 | * diff on a pair of bitmaps. |
| 44 | * @param baseline The correct bitmap |
| 45 | * @param test The bitmap whose difference is being tested |
| 46 | * @param computeMask true if the differ is to attempt to create poiAlphaMask |
| 47 | * @return true on success, and false in the case of failure |
djsollen@google.com | 513a7bf | 2013-11-07 19:24:06 +0000 | [diff] [blame] | 48 | */ |
djsollen@google.com | efc51b7 | 2013-11-12 18:29:17 +0000 | [diff] [blame] | 49 | virtual bool diff(SkBitmap* baseline, SkBitmap* test, bool computeMask, |
| 50 | Result* result) const = 0; |
commit-bot@chromium.org | be19b9e | 2013-06-14 17:26:54 +0000 | [diff] [blame] | 51 | }; |
| 52 | |
commit-bot@chromium.org | be19b9e | 2013-06-14 17:26:54 +0000 | [diff] [blame] | 53 | #endif |