blob: 614f92035672b214ac7b886449fca6742acf4eb3 [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:
djsollen@google.com513a7bf2013-11-07 19:24:06 +000030 SkDifferentPixelsMetric() : fPOIAlphaMask(false) {}
31
zachr@google.comd6585682013-07-17 19:29:19 +000032 virtual const char* getName() SK_OVERRIDE;
djsollen@google.com513a7bf2013-11-07 19:24:06 +000033 virtual bool enablePOIAlphaMask() SK_OVERRIDE;
zachr@google.comd6585682013-07-17 19:29:19 +000034 virtual int queueDiff(SkBitmap* baseline, SkBitmap* test) SK_OVERRIDE;
35 virtual void deleteDiff(int id) SK_OVERRIDE;
36 virtual bool isFinished(int id) SK_OVERRIDE;
37 virtual double getResult(int id) SK_OVERRIDE;
38 virtual int getPointsOfInterestCount(int id) SK_OVERRIDE;
39 virtual SkIPoint* getPointsOfInterest(int id) SK_OVERRIDE;
djsollen@google.com513a7bf2013-11-07 19:24:06 +000040 virtual SkBitmap* getPointsOfInterestAlphaMask(int id) SK_OVERRIDE;
zachr@google.comd6585682013-07-17 19:29:19 +000041
42protected:
43#if SK_SUPPORT_OPENCL
44 virtual bool onInit() SK_OVERRIDE;
45#endif
46
47private:
djsollen@google.com513a7bf2013-11-07 19:24:06 +000048 bool fPOIAlphaMask;
zachr@google.comd6585682013-07-17 19:29:19 +000049
djsollen@google.com513a7bf2013-11-07 19:24:06 +000050 struct QueuedDiff;
zachr@google.comd6585682013-07-17 19:29:19 +000051 SkTDArray<QueuedDiff> fQueuedDiffs;
52
53#if SK_SUPPORT_OPENCL
54 cl_kernel fKernel;
55
56 typedef SkCLImageDiffer INHERITED;
57#else
58 typedef SkImageDiffer INHERITED;
59#endif
60};
61
62#endif