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

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: use gfx::Rect instead of max co-ordinates 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') | no next file with comments »
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..a1d142cb6978ba87952fccc6b6a2c70c372b61af 100644
--- a/cc/test/pixel_comparator.cc
+++ b/cc/test/pixel_comparator.cc
@@ -7,6 +7,7 @@
#include <algorithm>
#include "base/logging.h"
+#include "ui/gfx/rect.h"
namespace cc {
@@ -18,6 +19,8 @@ bool ExactPixelComparator::Compare(const SkBitmap& actual_bmp,
const SkBitmap& expected_bmp) const {
// Number of pixels with an error
int error_pixels_count = 0;
+ // Bounding box for error
danakj 2014/07/08 16:08:34 nit: comments are sentences including periods. bu
sohanjg 2014/07/08 16:20:34 Done.
+ gfx::Rect bounding_rect = gfx::Rect();
// Check that bitmaps have identical dimensions.
DCHECK(actual_bmp.width() == expected_bmp.width() &&
@@ -34,26 +37,23 @@ 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) << ")";
+ bounding_rect.set_x(std::min(x, bounding_rect.x()));
+ bounding_rect.set_y(std::min(y, bounding_rect.y()));
+ bounding_rect.set_width(
+ std::max(x, (bounding_rect.x() + bounding_rect.width())) -
+ bounding_rect.x());
+ bounding_rect.set_height(
+ std::max(y, (bounding_rect.y() + bounding_rect.bottom())) -
+ bounding_rect.y());
}
}
}
if (error_pixels_count != 0) {
LOG(ERROR) << "Number of pixel with an error: " << error_pixels_count;
+ LOG(ERROR) << "Error Bounding Box : " << bounding_rect.ToString();
return false;
}
@@ -91,6 +91,8 @@ bool FuzzyPixelComparator::Compare(const SkBitmap& actual_bmp,
int max_abs_error_g = 0;
int max_abs_error_b = 0;
int max_abs_error_a = 0;
+ // Bounding box for error
+ gfx::Rect bounding_rect = gfx::Rect();
// Check that bitmaps have identical dimensions.
DCHECK(actual_bmp.width() == expected_bmp.width() &&
@@ -202,21 +204,18 @@ 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) << ")";
+ bounding_rect.set_x(std::min(x, bounding_rect.x()));
+ bounding_rect.set_y(std::min(y, bounding_rect.y()));
+ bounding_rect.set_width(
+ std::max(x, (bounding_rect.x() + bounding_rect.width())) -
+ bounding_rect.x());
+ bounding_rect.set_height(
+ std::max(y, (bounding_rect.y() + bounding_rect.bottom())) -
+ bounding_rect.y());
}
}
}
-
+ LOG(ERROR) << "Error Bounding Box : " << bounding_rect.ToString();
return false;
} else {
return true;
« no previous file with comments | « no previous file | cc/test/pixel_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698