Index: tools/skpdiff/SkPMetric.cpp |
diff --git a/tools/skpdiff/SkPMetric.cpp b/tools/skpdiff/SkPMetric.cpp |
index 5120e129b96b41a270d8dfd3af52a8110cec0c2a..22337d854dea8ce471bbb8d2c4844a19b4c30dfc 100644 |
--- a/tools/skpdiff/SkPMetric.cpp |
+++ b/tools/skpdiff/SkPMetric.cpp |
@@ -265,7 +265,11 @@ static void convolve(const ImageL* imageL, bool vertical, ImageL* outImageL) { |
} |
} |
-static double pmetric(const ImageLAB* baselineLAB, const ImageLAB* testLAB, SkTDArray<SkIPoint>* poi) { |
+static double pmetric(const ImageLAB* baselineLAB, const ImageLAB* testLAB, int* poiCount) { |
+ SkASSERT(baselineLAB); |
+ SkASSERT(testLAB); |
+ SkASSERT(poiCount); |
+ |
int width = baselineLAB->width; |
int height = baselineLAB->height; |
int maxLevels = 0; |
@@ -329,7 +333,6 @@ static double pmetric(const ImageLAB* baselineLAB, const ImageLAB* testLAB, SkTD |
contrast_sensitivity(cpd, 100.0f); |
} |
- int failures = 0; |
// Calculate F |
for (int y = 0; y < height; y++) { |
for (int x = 0; x < width; x++) { |
@@ -424,8 +427,7 @@ static double pmetric(const ImageLAB* baselineLAB, const ImageLAB* testLAB, SkTD |
} |
if (isFailure) { |
- failures++; |
- poi->push()->set(x, y); |
+ (*poiCount)++; |
} |
} |
} |
@@ -434,57 +436,28 @@ static double pmetric(const ImageLAB* baselineLAB, const ImageLAB* testLAB, SkTD |
SkDELETE_ARRAY(contrast); |
SkDELETE_ARRAY(thresholdFactorFrequency); |
SkDELETE_ARRAY(contrastSensitivityTable); |
- return 1.0 - (double)failures / (width * height); |
-} |
- |
-const char* SkPMetric::getName() { |
- return "perceptual"; |
+ return 1.0 - (double)(*poiCount) / (width * height); |
} |
-int SkPMetric::queueDiff(SkBitmap* baseline, SkBitmap* test) { |
+bool SkPMetric::diff(SkBitmap* baseline, SkBitmap* test, bool computeMask, Result* result) const { |
double startTime = get_seconds(); |
- int diffID = fQueuedDiffs.count(); |
- QueuedDiff& diff = fQueuedDiffs.push_back(); |
- diff.result = 0.0; |
// Ensure the images are comparable |
if (baseline->width() != test->width() || baseline->height() != test->height() || |
baseline->width() <= 0 || baseline->height() <= 0) { |
- diff.finished = true; |
- return diffID; |
+ return false; |
} |
ImageLAB baselineLAB(baseline->width(), baseline->height()); |
ImageLAB testLAB(baseline->width(), baseline->height()); |
if (!bitmap_to_cielab(baseline, &baselineLAB) || !bitmap_to_cielab(test, &testLAB)) { |
- return diffID; |
+ return true; |
} |
- diff.result = pmetric(&baselineLAB, &testLAB, &diff.poi); |
+ result->poiCount = 0; |
+ result->result = pmetric(&baselineLAB, &testLAB, &result->poiCount); |
+ result->timeElapsed = get_seconds() - startTime; |
- SkDebugf("Time: %f\n", (get_seconds() - startTime)); |
- |
- return diffID; |
-} |
- |
- |
-void SkPMetric::deleteDiff(int id) { |
- |
-} |
- |
-bool SkPMetric::isFinished(int id) { |
- return fQueuedDiffs[id].finished; |
-} |
- |
-double SkPMetric::getResult(int id) { |
- return fQueuedDiffs[id].result; |
-} |
- |
-int SkPMetric::getPointsOfInterestCount(int id) { |
- return fQueuedDiffs[id].poi.count(); |
-} |
- |
-SkIPoint* SkPMetric::getPointsOfInterest(int id) { |
- return fQueuedDiffs[id].poi.begin(); |
+ return true; |
} |