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 #include <cstring> | 8 #include <cstring> |
9 | 9 |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 SkDebugf("Failed to read kernel source file"); | 53 SkDebugf("Failed to read kernel source file"); |
54 return false; | 54 return false; |
55 } | 55 } |
56 | 56 |
57 return loadKernelSource(sourceString.c_str(), name, kernel); | 57 return loadKernelSource(sourceString.c_str(), name, kernel); |
58 } | 58 } |
59 | 59 |
60 bool SkCLImageDiffer::loadKernelSource(const char source[], const char name[], c
l_kernel* kernel) { | 60 bool SkCLImageDiffer::loadKernelSource(const char source[], const char name[], c
l_kernel* kernel) { |
61 // Build the kernel source | 61 // Build the kernel source |
62 size_t sourceLen = strlen(source); | 62 size_t sourceLen = strlen(source); |
63 cl_program program = clCreateProgramWithSource(fContext, 1, &source, &source
Len, NULL); | 63 cl_program program = clCreateProgramWithSource(fContext, 1, &source, &source
Len, nullptr); |
64 cl_int programErr = clBuildProgram(program, 1, &fDevice, "", NULL, NULL); | 64 cl_int programErr = clBuildProgram(program, 1, &fDevice, "", nullptr, nullpt
r); |
65 if (CL_SUCCESS != programErr) { | 65 if (CL_SUCCESS != programErr) { |
66 SkDebugf("Program creation failed: %s\n", cl_error_to_string(programErr)
); | 66 SkDebugf("Program creation failed: %s\n", cl_error_to_string(programErr)
); |
67 | 67 |
68 // Attempt to get information about why the build failed | 68 // Attempt to get information about why the build failed |
69 char buildLog[4096]; | 69 char buildLog[4096]; |
70 clGetProgramBuildInfo(program, fDevice, CL_PROGRAM_BUILD_LOG, sizeof(bui
ldLog), | 70 clGetProgramBuildInfo(program, fDevice, CL_PROGRAM_BUILD_LOG, sizeof(bui
ldLog), |
71 buildLog, NULL); | 71 buildLog, nullptr); |
72 SkDebugf("Build log: %s\n", buildLog); | 72 SkDebugf("Build log: %s\n", buildLog); |
73 | 73 |
74 return false; | 74 return false; |
75 } | 75 } |
76 | 76 |
77 cl_int kernelErr; | 77 cl_int kernelErr; |
78 *kernel = clCreateKernel(program, name, &kernelErr); | 78 *kernel = clCreateKernel(program, name, &kernelErr); |
79 if (CL_SUCCESS != kernelErr) { | 79 if (CL_SUCCESS != kernelErr) { |
80 SkDebugf("Kernel creation failed: %s\n", cl_error_to_string(kernelErr)); | 80 SkDebugf("Kernel creation failed: %s\n", cl_error_to_string(kernelErr)); |
81 return false; | 81 return false; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 &imageErr); | 113 &imageErr); |
114 bitmap->unlockPixels(); | 114 bitmap->unlockPixels(); |
115 | 115 |
116 if (CL_SUCCESS != imageErr) { | 116 if (CL_SUCCESS != imageErr) { |
117 SkDebugf("Input image creation failed: %s\n", cl_error_to_string(imageEr
r)); | 117 SkDebugf("Input image creation failed: %s\n", cl_error_to_string(imageEr
r)); |
118 return false; | 118 return false; |
119 } | 119 } |
120 | 120 |
121 return true; | 121 return true; |
122 } | 122 } |
OLD | NEW |