2 * Copyright 2013 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef SkImageDiffer_DEFINED
9 #define SkImageDiffer_DEFINED
14 * Encapsulates an image difference metric algorithm that can be potentially run asynchronously.
19 virtual ~SkImageDiffer();
21 static const double RESULT_CORRECT;
22 static const double RESULT_INCORRECT;
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 comparison algorithms')
30 SkBitmap poiAlphaMask; // optional
31 SkBitmap rgbDiffBitmap; // optional
32 SkBitmap whiteDiffBitmap; // optional
33 int maxRedDiff; // optional
34 int maxGreenDiff; // optional
35 int maxBlueDiff; // optional
36 double timeElapsed; // optional
39 // A bitfield indicating which bitmap types we want a differ to create.
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 {
52 * Gets a unique and descriptive name of this differ
53 * @return A statically allocated null terminated string that is the name of this differ
55 virtual const char* getName() const = 0;
58 * Gets if this differ needs to be initialized with and OpenCL device and context.
60 virtual bool requiresOpenCL() const { return false; }
63 * diff on a pair of bitmaps.
64 * @param baseline The correct bitmap
65 * @param test The bitmap whose difference is being tested
66 * @param bitmapsToCreate Which bitmaps the differ should attempt to create
67 * @return true on success, and false in the case of failure
69 virtual bool diff(SkBitmap* baseline, SkBitmap* test, const BitmapsToCreate& bitmapsToCreate,
70 Result* result) const = 0;