Index: tools/skpdiff/SkPMetric.cpp |
diff --git a/tools/skpdiff/SkPMetric.cpp b/tools/skpdiff/SkPMetric.cpp |
index a19ed826f8f1cd344708a65dd51ade5beb4b6c0d..447f255c9443685e504e8b21235045ffd4e3d726 100644 |
--- a/tools/skpdiff/SkPMetric.cpp |
+++ b/tools/skpdiff/SkPMetric.cpp |
@@ -258,7 +258,7 @@ 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) { |
scroggo
2013/11/07 21:43:23
Can we assert that the parameters are not NULL?
djsollen
2013/11/07 21:53:57
Done.
|
int width = baselineLAB->width; |
int height = baselineLAB->height; |
int maxLevels = 0; |
@@ -316,7 +316,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++) { |
@@ -411,8 +410,7 @@ static double pmetric(const ImageLAB* baselineLAB, const ImageLAB* testLAB, SkTD |
} |
if (isFailure) { |
- failures++; |
- poi->push()->set(x, y); |
+ (*poiCount)++; |
} |
} |
} |
@@ -421,24 +419,20 @@ 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); |
+ return 1.0 - (double)(*poiCount) / (width * height); |
} |
const char* SkPMetric::getName() { |
return "perceptual"; |
} |
-int SkPMetric::queueDiff(SkBitmap* baseline, SkBitmap* test) { |
+bool SkPMetric::diff(SkBitmap* baseline, SkBitmap* test, Result* result) { |
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()); |
@@ -447,30 +441,9 @@ int SkPMetric::queueDiff(SkBitmap* baseline, SkBitmap* test) { |
bitmap_to_cielab(baseline, &baselineLAB); |
bitmap_to_cielab(test, &testLAB); |
- 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; |
} |