blob: 0ef7337b5d94728b5372f17ee2f3ad3c532afe7e [file] [log] [blame]
zachr@google.comd6585682013-07-17 19:29:19 +00001/*
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 SkDifferentPixelsMetric_DEFINED
9#define SkDifferentPixelsMetric_DEFINED
10
11#include "SkTDArray.h"
12
13#if SK_SUPPORT_OPENCL
14#include "SkCLImageDiffer.h"
15#else
16#include "SkImageDiffer.h"
17#endif
18
19/**
20 * A differ that measures the percentage of different corresponding pixels. If the two images are
21 * not the same size or have no pixels, the result will always be zero.
22 */
23class SkDifferentPixelsMetric :
24#if SK_SUPPORT_OPENCL
25 public SkCLImageDiffer {
26#else
27 public SkImageDiffer {
28#endif
29public:
mtklein72c9faa2015-01-09 10:06:39 -080030 const char* getName() const SK_OVERRIDE;
epoger54f1ad82014-07-02 07:43:04 -070031 virtual bool diff(SkBitmap* baseline, SkBitmap* test,
32 const BitmapsToCreate& bitmapsToCreate,
djsollen@google.comefc51b72013-11-12 18:29:17 +000033 Result* result) const SK_OVERRIDE;
zachr@google.comd6585682013-07-17 19:29:19 +000034
35protected:
36#if SK_SUPPORT_OPENCL
mtklein72c9faa2015-01-09 10:06:39 -080037 bool onInit() SK_OVERRIDE;
zachr@google.comd6585682013-07-17 19:29:19 +000038#endif
39
40private:
zachr@google.comd6585682013-07-17 19:29:19 +000041#if SK_SUPPORT_OPENCL
42 cl_kernel fKernel;
43
44 typedef SkCLImageDiffer INHERITED;
45#else
46 typedef SkImageDiffer INHERITED;
47#endif
48};
49
50#endif