2013-06-14 17:26:54 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkImageDiffer_DEFINED
|
|
|
|
#define SkImageDiffer_DEFINED
|
|
|
|
|
2013-11-12 18:29:17 +00:00
|
|
|
#include "SkBitmap.h"
|
2013-06-14 17:26:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Encapsulates an image difference metric algorithm that can be potentially run asynchronously.
|
|
|
|
*/
|
|
|
|
class SkImageDiffer {
|
|
|
|
public:
|
|
|
|
SkImageDiffer();
|
|
|
|
virtual ~SkImageDiffer();
|
|
|
|
|
2013-11-07 19:40:35 +00:00
|
|
|
static const double RESULT_CORRECT;
|
|
|
|
static const double RESULT_INCORRECT;
|
2013-11-07 19:24:06 +00:00
|
|
|
|
2013-11-12 18:29:17 +00:00
|
|
|
struct Result {
|
|
|
|
double result;
|
|
|
|
int poiCount;
|
2014-07-02 14:43:04 +00:00
|
|
|
// TODO(djsollen): Figure out a way that the differ can report which of the
|
2015-11-07 13:29:00 +00:00
|
|
|
// optional fields it has filled in. See https://bug.skia.org/2712 ('allow
|
2014-07-02 14:43:04 +00:00
|
|
|
// skpdiff to report different sets of result fields for different comparison algorithms')
|
2013-11-12 18:29:17 +00:00
|
|
|
SkBitmap poiAlphaMask; // optional
|
2014-07-02 14:43:04 +00:00
|
|
|
SkBitmap rgbDiffBitmap; // optional
|
|
|
|
SkBitmap whiteDiffBitmap; // optional
|
|
|
|
int maxRedDiff; // optional
|
|
|
|
int maxGreenDiff; // optional
|
|
|
|
int maxBlueDiff; // optional
|
2013-11-12 18:29:17 +00:00
|
|
|
double timeElapsed; // optional
|
|
|
|
};
|
|
|
|
|
2014-07-02 14:43:04 +00:00
|
|
|
// A bitfield indicating which bitmap types we want a differ to create.
|
|
|
|
//
|
|
|
|
// TODO(epoger): Remove whiteDiffBitmap, because alphaMask can provide
|
|
|
|
// the same functionality and more.
|
|
|
|
// It will be a little bit tricky, because the rebaseline_server client
|
|
|
|
// and server side code will both need to change to use the alphaMask.
|
|
|
|
struct BitmapsToCreate {
|
|
|
|
bool alphaMask;
|
|
|
|
bool rgbDiff;
|
|
|
|
bool whiteDiff;
|
|
|
|
};
|
|
|
|
|
2013-06-14 17:26:54 +00:00
|
|
|
/**
|
|
|
|
* Gets a unique and descriptive name of this differ
|
|
|
|
* @return A statically allocated null terminated string that is the name of this differ
|
|
|
|
*/
|
2013-11-12 18:29:17 +00:00
|
|
|
virtual const char* getName() const = 0;
|
2013-06-14 17:26:54 +00:00
|
|
|
|
2013-07-17 19:29:19 +00:00
|
|
|
/**
|
|
|
|
* Gets if this differ needs to be initialized with and OpenCL device and context.
|
|
|
|
*/
|
2013-11-12 18:29:17 +00:00
|
|
|
virtual bool requiresOpenCL() const { return false; }
|
2013-06-28 16:27:33 +00:00
|
|
|
|
2013-06-14 17:26:54 +00:00
|
|
|
/**
|
2013-11-12 18:29:17 +00:00
|
|
|
* diff on a pair of bitmaps.
|
|
|
|
* @param baseline The correct bitmap
|
|
|
|
* @param test The bitmap whose difference is being tested
|
2014-07-02 14:43:04 +00:00
|
|
|
* @param bitmapsToCreate Which bitmaps the differ should attempt to create
|
2013-11-12 18:29:17 +00:00
|
|
|
* @return true on success, and false in the case of failure
|
2013-06-14 17:26:54 +00:00
|
|
|
*/
|
2014-07-02 14:43:04 +00:00
|
|
|
virtual bool diff(SkBitmap* baseline, SkBitmap* test, const BitmapsToCreate& bitmapsToCreate,
|
2013-11-12 18:29:17 +00:00
|
|
|
Result* result) const = 0;
|
2013-06-14 17:26:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|