| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include <cstring> | 9 #include <cstring> |
| 10 | 10 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 } | 180 } |
| 181 | 181 |
| 182 // This makes things totally synchronous. Actual queue is not ready yet | 182 // This makes things totally synchronous. Actual queue is not ready yet |
| 183 clWaitForEvents(1, &event); | 183 clWaitForEvents(1, &event); |
| 184 diff->finished = true; | 184 diff->finished = true; |
| 185 | 185 |
| 186 // Immediate read back the results | 186 // Immediate read back the results |
| 187 clEnqueueReadBuffer(fCommandQueue, diff->resultsBuffer, CL_TRUE, 0, sizeof(i
nt), &numDiffPixels, 0, NULL, NULL); | 187 clEnqueueReadBuffer(fCommandQueue, diff->resultsBuffer, CL_TRUE, 0, sizeof(i
nt), &numDiffPixels, 0, NULL, NULL); |
| 188 diff->result *= (double)numDiffPixels; | 188 diff->result *= (double)numDiffPixels; |
| 189 diff->result = (1.0 - diff->result); | 189 diff->result = (1.0 - diff->result); |
| 190 |
| 191 // Release all the buffers created |
| 192 clReleaseMemObject(diff->resultsBuffer); |
| 193 clReleaseMemObject(diff->baseline); |
| 194 clReleaseMemObject(diff->test); |
| 195 |
| 190 SkDebugf("Time: %f\n", (get_seconds() - startTime)); | 196 SkDebugf("Time: %f\n", (get_seconds() - startTime)); |
| 191 | 197 |
| 192 return diffID; | 198 return diffID; |
| 193 } | 199 } |
| 194 | 200 |
| 195 bool SkDifferentPixelsImageDiffer::isFinished(int id) { | 201 bool SkDifferentPixelsImageDiffer::isFinished(int id) { |
| 196 return fQueuedDiffs[id].finished; | 202 return fQueuedDiffs[id].finished; |
| 197 } | 203 } |
| 198 | 204 |
| 199 double SkDifferentPixelsImageDiffer::getResult(int id) { | 205 double SkDifferentPixelsImageDiffer::getResult(int id) { |
| 200 return fQueuedDiffs[id].result; | 206 return fQueuedDiffs[id].result; |
| 201 } | 207 } |
| 202 | 208 |
| 203 | 209 |
| 204 bool SkDifferentPixelsImageDiffer::onInit() { | 210 bool SkDifferentPixelsImageDiffer::onInit() { |
| 205 if (!loadKernelFile("experimental/skpdiff/diff_pixels.cl", "diff", &fKernel)
) { | 211 if (!loadKernelFile("experimental/skpdiff/diff_pixels.cl", "diff", &fKernel)
) { |
| 206 return false; | 212 return false; |
| 207 } | 213 } |
| 208 | 214 |
| 209 return true; | 215 return true; |
| 210 } | 216 } |
| OLD | NEW |