Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1348)

Unified Diff: gm/gmmain.cpp

Issue 7238043: output max-pixel-err if we're comparing against known PNG files. Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 12 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« gm/gm_expectations.h ('K') | « gm/gm_expectations.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/gmmain.cpp
===================================================================
--- gm/gmmain.cpp (revision 7412)
+++ gm/gmmain.cpp (working copy)
@@ -195,6 +195,36 @@
| SkGPipeWriter::kSharedAddressSpace_Flag }
};
+static int brute_force_bitmap_compare(const SkBitmap& a, const SkBitmap& b) {
+ SkAutoLockPixels alp0(a);
+ SkAutoLockPixels alp1(b);
+
+ if (a.width() != b.width() || a.height() != b.height()) {
+ return -1;
epoger 2013/01/30 16:46:50 This is OK, but it would be better to report ERROR
+ }
+ if (a.config() != SkBitmap::kARGB_8888_Config ||
+ b.config() != SkBitmap::kARGB_8888_Config) {
+ return -2;
epoger 2013/01/30 16:46:50 Do we not care at all about non-8888 images?
+ }
+
+ int err = 0;
+ for (int y = 0; y < a.height(); ++y) {
+ const SkPMColor* pa = a.getAddr32(0, y);
+ const SkPMColor* pb = b.getAddr32(0, y);
+ for (int x = 0; x < a.width(); ++x) {
+ SkPMColor ca = *pa++;
+ SkPMColor cb = *pb++;
+ if (ca == cb) {
+ continue;
+ }
+ err = SkMax32(err, SkAbs32((int)SkGetPackedR32(ca) - (int)SkGetPackedR32(cb)));
bsalomon 2013/01/28 20:14:43 We've had images differ only in alpha in the past.
epoger 2013/01/30 16:46:50 Right. See http://code.google.com/p/skia/source/d
+ err = SkMax32(err, SkAbs32((int)SkGetPackedG32(ca) - (int)SkGetPackedG32(cb)));
+ err = SkMax32(err, SkAbs32((int)SkGetPackedB32(ca) - (int)SkGetPackedB32(cb)));
+ }
+ }
+ return err;
+}
+
class GMMain {
public:
GMMain() {
@@ -676,7 +706,18 @@
* force_all_opaque().
* See comments above get_checksum() for more detail.
*/
- Expectations expectations = expectationsSource->get(name.c_str());
+ SkBitmap expectedBitmap;
+ Expectations expectations = expectationsSource->get(name.c_str(),
+ &expectedBitmap);
+
+ int maxErr = 0;
+ if (!expectedBitmap.isNull()) {
+ maxErr = brute_force_bitmap_compare(actualBitmap, expectedBitmap);
+ }
+ if (maxErr) {
+ SkDebugf("--- bitmap compare failed with max component difference %d\n", maxErr);
+ }
+
retval |= compare_to_expectations(expectations, actualBitmap,
name, "", true);
} else {
« gm/gm_expectations.h ('K') | « gm/gm_expectations.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b