| 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 | 7 |
| 8 #include "gm_expectations.h" | 8 #include "gm_expectations.h" |
| 9 #include "SkBitmapHasher.h" | 9 #include "SkBitmapHasher.h" |
| 10 #include "SkImageDecoder.h" | 10 #include "SkImageDecoder.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 | 196 |
| 197 Json::Value jsonExpectations; | 197 Json::Value jsonExpectations; |
| 198 jsonExpectations[kJsonKey_ExpectedResults_AllowedDigests] = allowedDiges
tArray; | 198 jsonExpectations[kJsonKey_ExpectedResults_AllowedDigests] = allowedDiges
tArray; |
| 199 jsonExpectations[kJsonKey_ExpectedResults_IgnoreFailure] = this->ignore
Failure(); | 199 jsonExpectations[kJsonKey_ExpectedResults_IgnoreFailure] = this->ignore
Failure(); |
| 200 return jsonExpectations; | 200 return jsonExpectations; |
| 201 } | 201 } |
| 202 | 202 |
| 203 | 203 |
| 204 // IndividualImageExpectationsSource class... | 204 // IndividualImageExpectationsSource class... |
| 205 | 205 |
| 206 Expectations IndividualImageExpectationsSource::get(const char *testName) { | 206 Expectations IndividualImageExpectationsSource::get(const char *testName) co
nst { |
| 207 SkString path = SkOSPath::SkPathJoin(fRootDir.c_str(), testName); | 207 SkString path = SkOSPath::SkPathJoin(fRootDir.c_str(), testName); |
| 208 SkBitmap referenceBitmap; | 208 SkBitmap referenceBitmap; |
| 209 bool decodedReferenceBitmap = | 209 bool decodedReferenceBitmap = |
| 210 SkImageDecoder::DecodeFile(path.c_str(), &referenceBitmap, | 210 SkImageDecoder::DecodeFile(path.c_str(), &referenceBitmap, |
| 211 SkBitmap::kARGB_8888_Config, | 211 SkBitmap::kARGB_8888_Config, |
| 212 SkImageDecoder::kDecodePixels_Mode, | 212 SkImageDecoder::kDecodePixels_Mode, |
| 213 NULL); | 213 NULL); |
| 214 if (decodedReferenceBitmap) { | 214 if (decodedReferenceBitmap) { |
| 215 return Expectations(referenceBitmap); | 215 return Expectations(referenceBitmap); |
| 216 } else { | 216 } else { |
| 217 return Expectations(); | 217 return Expectations(); |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 | 220 |
| 221 | 221 |
| 222 // JsonExpectationsSource class... | 222 // JsonExpectationsSource class... |
| 223 | 223 |
| 224 JsonExpectationsSource::JsonExpectationsSource(const char *jsonPath) { | 224 JsonExpectationsSource::JsonExpectationsSource(const char *jsonPath) { |
| 225 Parse(jsonPath, &fJsonRoot); | 225 Parse(jsonPath, &fJsonRoot); |
| 226 fJsonExpectedResults = fJsonRoot[kJsonKey_ExpectedResults]; | 226 fJsonExpectedResults = fJsonRoot[kJsonKey_ExpectedResults]; |
| 227 } | 227 } |
| 228 | 228 |
| 229 Expectations JsonExpectationsSource::get(const char *testName) { | 229 Expectations JsonExpectationsSource::get(const char *testName) const { |
| 230 return Expectations(fJsonExpectedResults[testName]); | 230 return Expectations(fJsonExpectedResults[testName]); |
| 231 } | 231 } |
| 232 | 232 |
| 233 /*static*/ SkData* JsonExpectationsSource::ReadIntoSkData(SkStream &stream,
size_t maxBytes) { | 233 /*static*/ SkData* JsonExpectationsSource::ReadIntoSkData(SkStream &stream,
size_t maxBytes) { |
| 234 if (0 == maxBytes) { | 234 if (0 == maxBytes) { |
| 235 return SkData::NewEmpty(); | 235 return SkData::NewEmpty(); |
| 236 } | 236 } |
| 237 char* bufStart = reinterpret_cast<char *>(sk_malloc_throw(maxBytes)); | 237 char* bufStart = reinterpret_cast<char *>(sk_malloc_throw(maxBytes)); |
| 238 char* bufPtr = bufStart; | 238 char* bufPtr = bufStart; |
| 239 size_t bytesRemaining = maxBytes; | 239 size_t bytesRemaining = maxBytes; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 268 Json::Reader reader; | 268 Json::Reader reader; |
| 269 if (!reader.parse(bytes, bytes+size, *jsonRoot)) { | 269 if (!reader.parse(bytes, bytes+size, *jsonRoot)) { |
| 270 gm_fprintf(stderr, "error parsing JSON file %s\n", jsonPath); | 270 gm_fprintf(stderr, "error parsing JSON file %s\n", jsonPath); |
| 271 DEBUGFAIL_SEE_STDERR; | 271 DEBUGFAIL_SEE_STDERR; |
| 272 return false; | 272 return false; |
| 273 } | 273 } |
| 274 return true; | 274 return true; |
| 275 } | 275 } |
| 276 | 276 |
| 277 } | 277 } |
| OLD | NEW |