| Index: tools/skpdiff/SkPMetric.cpp
|
| diff --git a/tools/skpdiff/SkPMetric.cpp b/tools/skpdiff/SkPMetric.cpp
|
| index a19ed826f8f1cd344708a65dd51ade5beb4b6c0d..87296d90a6dcdb56c6429ae49e3c31aa46a71c86 100644
|
| --- a/tools/skpdiff/SkPMetric.cpp
|
| +++ b/tools/skpdiff/SkPMetric.cpp
|
| @@ -258,7 +258,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;
|
| @@ -316,7 +320,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 +414,7 @@ static double pmetric(const ImageLAB* baselineLAB, const ImageLAB* testLAB, SkTD
|
| }
|
|
|
| if (isFailure) {
|
| - failures++;
|
| - poi->push()->set(x, y);
|
| + (*poiCount)++;
|
| }
|
| }
|
| }
|
| @@ -421,24 +423,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 +445,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);
|
| -
|
| - 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();
|
| -}
|
| + result->poiCount = 0;
|
| + result->result = pmetric(&baselineLAB, &testLAB, &result->poiCount);
|
| + result->timeElapsed = get_seconds() - startTime;
|
|
|
| -SkIPoint* SkPMetric::getPointsOfInterest(int id) {
|
| - return fQueuedDiffs[id].poi.begin();
|
| + return true;
|
| }
|
|
|