| 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 #if SK_BUILD_FOR_MAC | 11 #if SK_BUILD_FOR_MAC |
| 12 # include <OpenCL/cl.h> | 12 # include <OpenCL/cl.h> |
| 13 #else | 13 #else |
| 14 # include <CL/cl.h> | 14 # include <CL/cl.h> |
| 15 #endif | 15 #endif |
| 16 #include "SkTDArray.h" | 16 #include "SkTDArray.h" |
| 17 | 17 |
| 18 #include "SkImageDiffer.h" | 18 #include "SkImageDiffer.h" |
| 19 | 19 |
| 20 class SkStream; | 20 class SkStream; |
| 21 | 21 |
| 22 /** | 22 /** |
| 23 * An SkImageDiffer that requires initialization with an OpenCL device and conte
xt. | 23 * An SkImageDiffer that requires initialization with an OpenCL device and conte
xt. |
| 24 */ | 24 */ |
| 25 class SkCLImageDiffer : public SkImageDiffer { | 25 class SkCLImageDiffer : public SkImageDiffer { |
| 26 public: | 26 public: |
| 27 SkCLImageDiffer(); | 27 SkCLImageDiffer(); |
| 28 | 28 |
| 29 virtual bool requiresOpenCL() SK_OVERRIDE { return true; } | 29 virtual bool requiresOpenCL() const SK_OVERRIDE { return true; } |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * Initializes the OpenCL resources this differ needs to work | 32 * Initializes the OpenCL resources this differ needs to work |
| 33 * @param device An OpenCL device | 33 * @param device An OpenCL device |
| 34 * @param context An OpenCL context of the given device | 34 * @param context An OpenCL context of the given device |
| 35 * @return True on success, false otherwise | 35 * @return True on success, false otherwise |
| 36 */ | 36 */ |
| 37 virtual bool init(cl_device_id device, cl_context context); | 37 virtual bool init(cl_device_id device, cl_context context); |
| 38 | 38 |
| 39 protected: | 39 protected: |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 */ | 73 */ |
| 74 bool loadKernelSource(const char source[], const char name[], cl_kernel* ker
nel); | 74 bool loadKernelSource(const char source[], const char name[], cl_kernel* ker
nel); |
| 75 | 75 |
| 76 /** | 76 /** |
| 77 * Loads a read only copy of the given bitmap into device memory and returns
the block of | 77 * Loads a read only copy of the given bitmap into device memory and returns
the block of |
| 78 * memory. This only works after init is called. | 78 * memory. This only works after init is called. |
| 79 * @param bitmap The bitmap to load into memory | 79 * @param bitmap The bitmap to load into memory |
| 80 * @param image A pointer to return the allocated image to | 80 * @param image A pointer to return the allocated image to |
| 81 * @return True on success, false otherwise | 81 * @return True on success, false otherwise |
| 82 */ | 82 */ |
| 83 bool makeImage2D(SkBitmap* bitmap, cl_mem* image); | 83 bool makeImage2D(SkBitmap* bitmap, cl_mem* image) const; |
| 84 | 84 |
| 85 cl_device_id fDevice; | 85 cl_device_id fDevice; |
| 86 cl_context fContext; | 86 cl_context fContext; |
| 87 cl_command_queue fCommandQueue; | 87 cl_command_queue fCommandQueue; |
| 88 | 88 |
| 89 protected: |
| 90 bool fIsGood; |
| 91 |
| 89 private: | 92 private: |
| 90 | 93 |
| 91 typedef SkImageDiffer INHERITED; | 94 typedef SkImageDiffer INHERITED; |
| 92 }; | 95 }; |
| 93 | 96 |
| 94 #endif | 97 #endif |
| OLD | NEW |