aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/skpdiff/SkDifferentPixelsMetric.h
blob: 0ef7337b5d94728b5372f17ee2f3ad3c532afe7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
 * 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 SkDifferentPixelsMetric_DEFINED
#define SkDifferentPixelsMetric_DEFINED

#include "SkTDArray.h"

#if SK_SUPPORT_OPENCL
#include "SkCLImageDiffer.h"
#else
#include "SkImageDiffer.h"
#endif

/**
 * A differ that measures the percentage of different corresponding pixels. If the two images are
 * not the same size or have no pixels, the result will always be zero.
 */
class SkDifferentPixelsMetric :
#if SK_SUPPORT_OPENCL
    public SkCLImageDiffer {
#else
    public SkImageDiffer {
#endif
public:
    const char* getName() const SK_OVERRIDE;
    virtual bool diff(SkBitmap* baseline, SkBitmap* test,
                      const BitmapsToCreate& bitmapsToCreate,
                      Result* result) const SK_OVERRIDE;

protected:
#if SK_SUPPORT_OPENCL
    bool onInit() SK_OVERRIDE;
#endif

private:
#if SK_SUPPORT_OPENCL
    cl_kernel fKernel;

    typedef SkCLImageDiffer INHERITED;
#else
    typedef SkImageDiffer INHERITED;
#endif
};

#endif