| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 #ifndef gm_expectations_DEFINED | 7 #ifndef gm_expectations_DEFINED |
| 8 #define gm_expectations_DEFINED | 8 #define gm_expectations_DEFINED |
| 9 | 9 |
| 10 #include <stdarg.h> | 10 #include <stdarg.h> |
| 11 #include "gm.h" | 11 #include "gm.h" |
| 12 #include "SkBitmap.h" | 12 #include "SkBitmap.h" |
| 13 #include "SkBitmapChecksummer.h" | 13 #include "SkBitmapHasher.h" |
| 14 #include "SkData.h" | 14 #include "SkData.h" |
| 15 #include "SkImageDecoder.h" | 15 #include "SkImageDecoder.h" |
| 16 #include "SkOSFile.h" | 16 #include "SkOSFile.h" |
| 17 #include "SkRefCnt.h" | 17 #include "SkRefCnt.h" |
| 18 #include "SkStream.h" | 18 #include "SkStream.h" |
| 19 #include "SkTArray.h" | 19 #include "SkTArray.h" |
| 20 | 20 |
| 21 #ifdef SK_BUILD_FOR_WIN | 21 #ifdef SK_BUILD_FOR_WIN |
| 22 // json includes xlocale which generates warning 4530 because we're compilin
g without | 22 // json includes xlocale which generates warning 4530 because we're compilin
g without |
| 23 // exceptions; see https://code.google.com/p/skia/issues/detail?id=1067 | 23 // exceptions; see https://code.google.com/p/skia/issues/detail?id=1067 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 fIgnoreFailure = ignoreFailure; | 87 fIgnoreFailure = ignoreFailure; |
| 88 } | 88 } |
| 89 | 89 |
| 90 /** | 90 /** |
| 91 * Expect exactly one image (appropriate for the case when we | 91 * Expect exactly one image (appropriate for the case when we |
| 92 * are comparing against a single PNG file). | 92 * are comparing against a single PNG file). |
| 93 */ | 93 */ |
| 94 Expectations(const SkBitmap& bitmap, bool ignoreFailure=kDefaultIgnoreFa
ilure) { | 94 Expectations(const SkBitmap& bitmap, bool ignoreFailure=kDefaultIgnoreFa
ilure) { |
| 95 fBitmap = bitmap; | 95 fBitmap = bitmap; |
| 96 fIgnoreFailure = ignoreFailure; | 96 fIgnoreFailure = ignoreFailure; |
| 97 fAllowedChecksums.push_back() = SkBitmapChecksummer::Compute64(bitma
p); | 97 SkHashDigest digest; |
| 98 // TODO(epoger): Better handling for error returned by ComputeDigest
()? |
| 99 // For now, we just report a digest of 0 in error cases, like before
. |
| 100 if (!SkBitmapHasher::ComputeDigest(bitmap, &digest)) { |
| 101 digest = 0; |
| 102 } |
| 103 fAllowedChecksums.push_back() = digest; |
| 98 } | 104 } |
| 99 | 105 |
| 100 /** | 106 /** |
| 101 * Create Expectations from a JSON element as found within the | 107 * Create Expectations from a JSON element as found within the |
| 102 * kJsonKey_ExpectedResults section. | 108 * kJsonKey_ExpectedResults section. |
| 103 * | 109 * |
| 104 * It's fine if the jsonElement is null or empty; in that case, we just | 110 * It's fine if the jsonElement is null or empty; in that case, we just |
| 105 * don't have any expectations. | 111 * don't have any expectations. |
| 106 */ | 112 */ |
| 107 Expectations(Json::Value jsonElement) { | 113 Expectations(Json::Value jsonElement) { |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 } | 363 } |
| 358 return true; | 364 return true; |
| 359 } | 365 } |
| 360 | 366 |
| 361 Json::Value fJsonRoot; | 367 Json::Value fJsonRoot; |
| 362 Json::Value fJsonExpectedResults; | 368 Json::Value fJsonExpectedResults; |
| 363 }; | 369 }; |
| 364 | 370 |
| 365 } | 371 } |
| 366 #endif | 372 #endif |
| OLD | NEW |