Chromium Code Reviews| Index: cc/test/pixel_comparator.cc |
| diff --git a/cc/test/pixel_comparator.cc b/cc/test/pixel_comparator.cc |
| index 44fa7dd21ac81e91c59cfdd6a6ae6de713ee32bc..b3213d4110f6b18de8634b9d0f05518f062247b3 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 { |
| @@ -19,6 +20,8 @@ bool ExactPixelComparator::Compare(const SkBitmap& actual_bmp, |
| // Number of pixels with an error |
| int error_pixels_count = 0; |
| + gfx::Rect error_bounding_rect = gfx::Rect(); |
| + |
| // Check that bitmaps have identical dimensions. |
| DCHECK(actual_bmp.width() == expected_bmp.width() && |
| actual_bmp.height() == expected_bmp.height()); |
| @@ -34,26 +37,25 @@ 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) << ")"; |
| + error_bounding_rect.set_x(std::min(x, error_bounding_rect.x())); |
|
danakj
2014/07/08 16:46:47
Sorry, I had asked about this earlier and missed a
sohanjg
2014/07/09 05:25:52
Done.
Sorry i missed it, this essentially was doin
|
| + error_bounding_rect.set_y(std::min(y, error_bounding_rect.y())); |
| + error_bounding_rect.set_width( |
| + std::max(x, |
| + (error_bounding_rect.x() + error_bounding_rect.width())) - |
| + error_bounding_rect.x()); |
| + error_bounding_rect.set_height( |
| + std::max(y, |
| + (error_bounding_rect.y() + error_bounding_rect.bottom())) - |
| + error_bounding_rect.y()); |
| } |
| } |
| } |
| if (error_pixels_count != 0) { |
| LOG(ERROR) << "Number of pixel with an error: " << error_pixels_count; |
| + LOG(ERROR) << "Error Bounding Box : " << error_bounding_rect.ToString(); |
| return false; |
| } |
| @@ -92,6 +94,8 @@ bool FuzzyPixelComparator::Compare(const SkBitmap& actual_bmp, |
| int max_abs_error_b = 0; |
| int max_abs_error_a = 0; |
| + gfx::Rect error_bounding_rect = gfx::Rect(); |
| + |
| // Check that bitmaps have identical dimensions. |
| DCHECK(actual_bmp.width() == expected_bmp.width() && |
| actual_bmp.height() == expected_bmp.height()); |
| @@ -202,21 +206,22 @@ 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_bounding_rect.set_x(std::min(x, error_bounding_rect.x())); |
| + error_bounding_rect.set_y(std::min(y, error_bounding_rect.y())); |
| + error_bounding_rect.set_width( |
| + std::max( |
| + x, |
| + (error_bounding_rect.x() + error_bounding_rect.width())) - |
| + error_bounding_rect.x()); |
| + error_bounding_rect.set_height( |
| + std::max( |
| + y, |
| + (error_bounding_rect.y() + error_bounding_rect.bottom())) - |
| + error_bounding_rect.y()); |
| } |
| } |
| } |
| - |
| + LOG(ERROR) << "Error Bounding Box : " << error_bounding_rect.ToString(); |
| return false; |
| } else { |
| return true; |