From 84a1802b072d76657261eada3018955283ab29d2 Mon Sep 17 00:00:00 2001 From: "epoger@google.com" Date: Fri, 1 Feb 2013 20:39:15 +0000 Subject: gm: report max-pixel-error if comparing against PNG files (not checksums) Review URL: https://codereview.appspot.com/7241064 git-svn-id: http://skia.googlecode.com/svn/trunk@7526 2bbb7eff-a529-9590-31e7-b0007b416f81 --- gm/gm_expectations.h | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'gm/gm_expectations.h') diff --git a/gm/gm_expectations.h b/gm/gm_expectations.h index 59a0c1c697..07f0e60dbd 100644 --- a/gm/gm_expectations.h +++ b/gm/gm_expectations.h @@ -8,6 +8,7 @@ #define gm_expectations_DEFINED #include "gm.h" +#include "SkBitmap.h" #include "SkBitmapChecksummer.h" #include "SkImageDecoder.h" #include "SkOSFile.h" @@ -62,14 +63,15 @@ namespace skiagm { } /** - * Allow exactly one checksum (appropriate for the case when we + * Expect exactly one image (appropriate for the case when we * are comparing against a single PNG file). * * By default, DO NOT ignore failures. */ - Expectations(Checksum singleChecksum, bool ignoreFailure=false) { + Expectations(const SkBitmap& bitmap, bool ignoreFailure=false) { + fBitmap = bitmap; fIgnoreFailure = ignoreFailure; - fAllowedChecksums.push_back() = singleChecksum; + fAllowedChecksums.push_back() = SkBitmapChecksummer::Compute64(bitmap); } /** @@ -97,6 +99,16 @@ namespace skiagm { return false; } + /** + * If this Expectation is based on a single SkBitmap, return a + * pointer to that SkBitmap. Otherwise (if the Expectation is + * empty, or if it was based on a list of checksums rather + * than a single bitmap), returns NULL. + */ + const SkBitmap *asBitmap() const { + return (SkBitmap::kNo_Config == fBitmap.config()) ? NULL : &fBitmap; + } + /** * Return a JSON representation of the allowed checksums. * This does NOT include any information about whether to @@ -116,6 +128,7 @@ namespace skiagm { private: SkTArray fAllowedChecksums; bool fIgnoreFailure; + SkBitmap fBitmap; }; /** @@ -154,9 +167,7 @@ namespace skiagm { SkImageDecoder::kDecodePixels_Mode, NULL); if (decodedReferenceBitmap) { - Checksum checksum = SkBitmapChecksummer::Compute64( - referenceBitmap); - return Expectations(checksum); + return Expectations(referenceBitmap); } else { if (fNotifyOfMissingFiles) { fprintf(stderr, "FAILED to read %s\n", path.c_str()); -- cgit v1.2.3