Chromium Code Reviews| 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
| 9 | 9 |
| 10 #include "SkDifferentPixelsMetric.h" | 10 #include "SkDifferentPixelsMetric.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 | 45 |
| 46 const char* SkDifferentPixelsMetric::getName() { | 46 const char* SkDifferentPixelsMetric::getName() { |
| 47 return "different_pixels"; | 47 return "different_pixels"; |
| 48 } | 48 } |
| 49 | 49 |
| 50 bool SkDifferentPixelsMetric::enablePOIAlphaMask() { | 50 bool SkDifferentPixelsMetric::enablePOIAlphaMask() { |
| 51 return false; | 51 return false; |
| 52 } | 52 } |
| 53 | 53 |
| 54 int SkDifferentPixelsMetric::queueDiff(SkBitmap* baseline, SkBitmap* test) { | 54 int SkDifferentPixelsMetric::queueDiff(SkBitmap* baseline, SkBitmap* test) { |
| 55 double startTime = get_seconds(); | |
| 56 | |
| 57 // since we currently synchronously do the diff within queueDiff we only nee d | |
| 58 // to protect the createion of the ID and queuedDiff object. | |
|
scroggo
2013/11/07 21:43:23
creation*
| |
| 59 SkAutoMutexAcquire queueLock(fQueueMutex); | |
| 55 int diffID = fQueuedDiffs.count(); | 60 int diffID = fQueuedDiffs.count(); |
| 56 double startTime = get_seconds(); | |
| 57 QueuedDiff* diff = fQueuedDiffs.push(); | 61 QueuedDiff* diff = fQueuedDiffs.push(); |
| 62 queueLock.release(); | |
| 58 | 63 |
| 59 // If we never end up running the kernel, include some safe defaults in the result. | 64 // If we never end up running the kernel, include some safe defaults in the result. |
| 60 diff->finished = false; | 65 diff->finished = false; |
| 61 diff->result = -1.0; | 66 diff->result = -1.0; |
| 62 diff->numDiffPixels = 0; | 67 diff->numDiffPixels = 0; |
| 63 diff->poi = NULL; | 68 diff->poi = NULL; |
| 64 | 69 |
| 65 // Ensure the images are comparable | 70 // Ensure the images are comparable |
| 66 if (baseline->width() != test->width() || baseline->height() != test->height () || | 71 if (baseline->width() != test->width() || baseline->height() != test->height () || |
| 67 baseline->width() <= 0 || baseline->height() <= 0 || | 72 baseline->width() <= 0 || baseline->height() <= 0 || |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 return fQueuedDiffs[id].poi; | 170 return fQueuedDiffs[id].poi; |
| 166 } | 171 } |
| 167 | 172 |
| 168 bool SkDifferentPixelsMetric::onInit() { | 173 bool SkDifferentPixelsMetric::onInit() { |
| 169 if (!this->loadKernelSource(kDifferentPixelsKernelSource, "diff", &fKernel)) { | 174 if (!this->loadKernelSource(kDifferentPixelsKernelSource, "diff", &fKernel)) { |
| 170 return false; | 175 return false; |
| 171 } | 176 } |
| 172 | 177 |
| 173 return true; | 178 return true; |
| 174 } | 179 } |
| OLD | NEW |