Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5277)

Unified Diff: cc/test/pixel_comparator.cc

Issue 371863002: cc: For cc pixel test, create data url for pngs and print bounding rect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | cc/test/pixel_test_utils.h » ('j') | cc/test/pixel_test_utils.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/test/pixel_comparator.cc
diff --git a/cc/test/pixel_comparator.cc b/cc/test/pixel_comparator.cc
index 44fa7dd21ac81e91c59cfdd6a6ae6de713ee32bc..bbfb6f7983bbbe0bae4ea3835f1a5d0d406e9b73 100644
--- a/cc/test/pixel_comparator.cc
+++ b/cc/test/pixel_comparator.cc
@@ -18,6 +18,11 @@ bool ExactPixelComparator::Compare(const SkBitmap& actual_bmp,
const SkBitmap& expected_bmp) const {
// Number of pixels with an error
int error_pixels_count = 0;
+ // Min/Max X,Y for bounding box
+ int minimum_difference_x = -99;
danakj 2014/07/07 16:07:02 Can you just use a gfx::Rect that starts empty and
sohanjg 2014/07/08 07:31:08 Done.
+ int minimum_difference_y = -99;
+ int maximum_difference_x = 0;
+ int maximum_difference_y = 0;
// Check that bitmaps have identical dimensions.
DCHECK(actual_bmp.width() == expected_bmp.width() &&
@@ -25,7 +30,6 @@ bool ExactPixelComparator::Compare(const SkBitmap& actual_bmp,
SkAutoLockPixels lock_actual_bmp(actual_bmp);
SkAutoLockPixels lock_expected_bmp(expected_bmp);
-
for (int x = 0; x < actual_bmp.width(); ++x) {
for (int y = 0; y < actual_bmp.height(); ++y) {
SkColor actual_color = actual_bmp.getColor(x, y);
@@ -34,26 +38,32 @@ bool ExactPixelComparator::Compare(const SkBitmap& actual_bmp,
actual_color = SkColorSetA(actual_color, 0);
expected_color = SkColorSetA(expected_color, 0);
}
-
if (actual_color != expected_color) {
++error_pixels_count;
- LOG(ERROR) << "Pixel error at x=" << x << " y=" << y << "; "
- << "actual RGBA=("
- << SkColorGetR(actual_color) << ","
- << SkColorGetG(actual_color) << ","
- << SkColorGetB(actual_color) << ","
- << SkColorGetA(actual_color) << "); "
- << "expected RGBA=("
- << SkColorGetR(expected_color) << ","
- << SkColorGetG(expected_color) << ","
- << SkColorGetB(expected_color) << ","
- << SkColorGetA(expected_color) << ")";
+ int difference_color = actual_color - expected_color;
+ if (difference_color < 0)
+ difference_color = 0 - difference_color;
+ if ((error_pixels_count == 1) ||
+ (x < minimum_difference_x && y < minimum_difference_y)) {
+ minimum_difference_x = x;
+ minimum_difference_y = y;
+ }
+ if (x > maximum_difference_x && y > maximum_difference_y) {
+ maximum_difference_x = x;
+ maximum_difference_y = y;
+ }
}
}
}
if (error_pixels_count != 0) {
LOG(ERROR) << "Number of pixel with an error: " << error_pixels_count;
+ LOG(ERROR) << "Error Bounding Box : "
+ << " Max X-Y Co-ordinates X = " << maximum_difference_x
danakj 2014/07/07 16:07:02 You can just use ToString() on the Rect if you use
sohanjg 2014/07/08 07:31:08 Done.
+ << " Y = " << maximum_difference_y;
+ LOG(ERROR) << "Error Bounding Box : "
+ << " Min X-Y Co-ordinates X = " << minimum_difference_x
+ << " Y = " << minimum_difference_y;
return false;
}
@@ -92,6 +102,12 @@ bool FuzzyPixelComparator::Compare(const SkBitmap& actual_bmp,
int max_abs_error_b = 0;
int max_abs_error_a = 0;
+ // Min/Max X,Y for bounding box
+ int minimum_difference_x = -99;
+ int minimum_difference_y = -99;
+ int maximum_difference_x = 0;
+ int maximum_difference_y = 0;
+
// Check that bitmaps have identical dimensions.
DCHECK(actual_bmp.width() == expected_bmp.width() &&
actual_bmp.height() == expected_bmp.height());
@@ -192,7 +208,7 @@ bool FuzzyPixelComparator::Compare(const SkBitmap& actual_bmp,
<< "G=" << max_abs_error_g << " "
<< "B=" << max_abs_error_b << " "
<< "A=" << max_abs_error_a;
-
+ error_pixels_count = 0;
for (int x = 0; x < actual_bmp.width(); ++x) {
for (int y = 0; y < actual_bmp.height(); ++y) {
SkColor actual_color = actual_bmp.getColor(x, y);
@@ -202,21 +218,28 @@ bool FuzzyPixelComparator::Compare(const SkBitmap& actual_bmp,
expected_color = SkColorSetA(expected_color, 0);
}
if (actual_color != expected_color) {
- LOG(ERROR) << "Pixel error at x=" << x << " y=" << y << "; "
- << "actual RGBA=("
- << SkColorGetR(actual_color) << ","
- << SkColorGetG(actual_color) << ","
- << SkColorGetB(actual_color) << ","
- << SkColorGetA(actual_color) << "); "
- << "expected RGBA=("
- << SkColorGetR(expected_color) << ","
- << SkColorGetG(expected_color) << ","
- << SkColorGetB(expected_color) << ","
- << SkColorGetA(expected_color) << ")";
+ ++error_pixels_count;
+ int difference_color = actual_color - expected_color;
+ if (difference_color < 0)
+ difference_color = 0 - difference_color;
+ if ((error_pixels_count == 1) ||
+ (x < minimum_difference_x && y < minimum_difference_y)) {
+ minimum_difference_x = x;
+ minimum_difference_y = y;
+ }
+ if (x > maximum_difference_x && y > maximum_difference_y) {
+ maximum_difference_x = x;
+ maximum_difference_y = y;
+ }
}
}
}
-
+ LOG(ERROR) << "Error Bounding Box : "
+ << " Max X-Y Co-ordinates X = " << maximum_difference_x
+ << " Y = " << maximum_difference_y;
+ LOG(ERROR) << "Error Bounding Box : "
+ << " Min X-Y Co-ordinates X = " << minimum_difference_x
+ << " Y = " << minimum_difference_y;
return false;
} else {
return true;
« no previous file with comments | « no previous file | cc/test/pixel_test_utils.h » ('j') | cc/test/pixel_test_utils.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698