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 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:
30    virtual const char* getName() const SK_OVERRIDE;
31    virtual bool diff(SkBitmap* baseline, SkBitmap* test, bool computeMask,
32                      Result* result) const SK_OVERRIDE;
33
34protected:
35#if SK_SUPPORT_OPENCL
36    virtual bool onInit() SK_OVERRIDE;
37#endif
38
39private:
40#if SK_SUPPORT_OPENCL
41    cl_kernel fKernel;
42
43    typedef SkCLImageDiffer INHERITED;
44#else
45    typedef SkImageDiffer INHERITED;
46#endif
47};
48
49#endif
50