| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkCLImageDiffer_DEFINED | 8 #ifndef SkCLImageDiffer_DEFINED |
| 9 #define SkCLImageDiffer_DEFINED | 9 #define SkCLImageDiffer_DEFINED |
| 10 | 10 |
| 11 #include <CL/cl.h> | 11 #include <CL/cl.h> |
| 12 #include "SkTDArray.h" | 12 #include "SkTDArray.h" |
| 13 | 13 |
| 14 #include "SkImageDiffer.h" | 14 #include "SkImageDiffer.h" |
| 15 | 15 |
| 16 class SkStream; | 16 class SkStream; |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * An SkImageDiffer that requires initialization with an OpenCL device and conte
xt. | 19 * An SkImageDiffer that requires initialization with an OpenCL device and conte
xt. |
| 20 */ | 20 */ |
| 21 class SkCLImageDiffer : public SkImageDiffer { | 21 class SkCLImageDiffer : public SkImageDiffer { |
| 22 public: | 22 public: |
| 23 SkCLImageDiffer(); | 23 SkCLImageDiffer(); |
| 24 | 24 |
| 25 virtual bool requiresOpenCL() SK_OVERRIDE { return true; } |
| 26 |
| 25 /** | 27 /** |
| 26 * Initializes the OpenCL resources this differ needs to work | 28 * Initializes the OpenCL resources this differ needs to work |
| 27 * @param device An OpenCL device | 29 * @param device An OpenCL device |
| 28 * @param context An OpenCL context of the given device | 30 * @param context An OpenCL context of the given device |
| 29 * @return True on success, false otherwise | 31 * @return True on success, false otherwise |
| 30 */ | 32 */ |
| 31 virtual bool init(cl_device_id device, cl_context context); | 33 virtual bool init(cl_device_id device, cl_context context); |
| 32 | 34 |
| 33 protected: | 35 protected: |
| 34 /** | 36 /** |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 80 |
| 79 cl_device_id fDevice; | 81 cl_device_id fDevice; |
| 80 cl_context fContext; | 82 cl_context fContext; |
| 81 cl_command_queue fCommandQueue; | 83 cl_command_queue fCommandQueue; |
| 82 | 84 |
| 83 private: | 85 private: |
| 84 | 86 |
| 85 typedef SkImageDiffer INHERITED; | 87 typedef SkImageDiffer INHERITED; |
| 86 }; | 88 }; |
| 87 | 89 |
| 88 /** | |
| 89 * A OpenCL differ that measures the percentage of different corresponding pixel
s. If the two images | |
| 90 * are not the same size or have no pixels, the result will always be zero. | |
| 91 */ | |
| 92 class SkDifferentPixelsImageDiffer : public SkCLImageDiffer { | |
| 93 public: | |
| 94 virtual const char* getName() SK_OVERRIDE; | |
| 95 virtual int queueDiff(SkBitmap* baseline, SkBitmap* test) SK_OVERRIDE; | |
| 96 virtual void deleteDiff(int id) SK_OVERRIDE; | |
| 97 virtual bool isFinished(int id) SK_OVERRIDE; | |
| 98 virtual double getResult(int id) SK_OVERRIDE; | |
| 99 virtual int getPointsOfInterestCount(int id) SK_OVERRIDE; | |
| 100 virtual SkIPoint* getPointsOfInterest(int id) SK_OVERRIDE; | |
| 101 | |
| 102 protected: | |
| 103 virtual bool onInit() SK_OVERRIDE; | |
| 104 | |
| 105 private: | |
| 106 struct QueuedDiff; | |
| 107 | |
| 108 SkTDArray<QueuedDiff> fQueuedDiffs; | |
| 109 cl_kernel fKernel; | |
| 110 | |
| 111 typedef SkCLImageDiffer INHERITED; | |
| 112 }; | |
| 113 | |
| 114 #endif | 90 #endif |
| OLD | NEW |