Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(919)

Side by Side Diff: tools/skimage_main.cpp

Issue 18023008: Fix run_decoding_tests on xoom. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 static void write_expectations(const SkBitmap& bitmap, const char* filename) { 157 static void write_expectations(const SkBitmap& bitmap, const char* filename) {
158 if (!FLAGS_createExpectationsPath.isEmpty()) { 158 if (!FLAGS_createExpectationsPath.isEmpty()) {
159 // Creates an Expectations object, and add it to the list to write. 159 // Creates an Expectations object, and add it to the list to write.
160 skiagm::Expectations expectation(bitmap); 160 skiagm::Expectations expectation(bitmap);
161 Json::Value value = expectation.asJsonValue(); 161 Json::Value value = expectation.asJsonValue();
162 gExpectationsToWrite[filename] = value; 162 gExpectationsToWrite[filename] = value;
163 } 163 }
164 } 164 }
165 165
166 /** 166 /**
167 * Return true if this filename is a known failure, and therefore a failure
168 * to decode should be ignored.
169 */
170 static bool expect_to_fail(const char* filename) {
171 if (NULL == gJsonExpectations.get()) {
172 return false;
173 }
174 skiagm::Expectations jsExpectations = gJsonExpectations->get(filename);
175 return jsExpectations.ignoreFailure();
176 }
177
178 /**
167 * Compare against an expectation for this filename, if there is one. 179 * Compare against an expectation for this filename, if there is one.
168 * @param bitmap SkBitmap to compare to the expected value. 180 * @param bitmap SkBitmap to compare to the expected value.
169 * @param filename String used to find the expected value. 181 * @param filename String used to find the expected value.
170 * @return bool True in any of these cases: 182 * @return bool True in any of these cases:
171 * - the bitmap matches the expectation. 183 * - the bitmap matches the expectation.
172 * False in any of these cases: 184 * False in any of these cases:
173 * - there is no expectations file. 185 * - there is no expectations file.
174 * - there is an expectations file, but no expectation for this bitmap. 186 * - there is an expectations file, but no expectation for this bitmap.
175 * - there is an expectation for this bitmap, but it did not ma tch. 187 * - there is an expectation for this bitmap, but it did not ma tch.
176 * - expectation could not be computed from the bitmap. 188 * - expectation could not be computed from the bitmap.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 304
293 SkImageDecoder* codec = SkImageDecoder::Factory(&stream); 305 SkImageDecoder* codec = SkImageDecoder::Factory(&stream);
294 if (NULL == codec) { 306 if (NULL == codec) {
295 gMissingCodecs.push_back().set(srcPath); 307 gMissingCodecs.push_back().set(srcPath);
296 return; 308 return;
297 } 309 }
298 310
299 SkAutoTDelete<SkImageDecoder> ad(codec); 311 SkAutoTDelete<SkImageDecoder> ad(codec);
300 312
301 stream.rewind(); 313 stream.rewind();
302 if (!codec->decode(&stream, &bitmap, SkBitmap::kARGB_8888_Config,
303 SkImageDecoder::kDecodePixels_Mode)) {
304 gDecodeFailures.push_back().set(srcPath);
305 return;
306 }
307 314
308 // Create a string representing just the filename itself, for use in json ex pectations. 315 // Create a string representing just the filename itself, for use in json ex pectations.
309 SkString basename = SkOSPath::SkBasename(srcPath); 316 SkString basename = SkOSPath::SkBasename(srcPath);
310 const char* filename = basename.c_str(); 317 const char* filename = basename.c_str();
311 318
319 if (!codec->decode(&stream, &bitmap, SkBitmap::kARGB_8888_Config,
320 SkImageDecoder::kDecodePixels_Mode)) {
321 if (expect_to_fail(filename)) {
322 gSuccessfulDecodes.push_back().appendf(
323 "failed to decode %s, which is a known failure.", srcPath);
324 } else {
325 gDecodeFailures.push_back().set(srcPath);
326 }
327 return;
328 }
329
312 if (compare_to_expectations_if_necessary(bitmap, filename, &gDecodeFailures) ) { 330 if (compare_to_expectations_if_necessary(bitmap, filename, &gDecodeFailures) ) {
313 gSuccessfulDecodes.push_back().printf("%s [%d %d]", srcPath, bitmap.widt h(), 331 gSuccessfulDecodes.push_back().printf("%s [%d %d]", srcPath, bitmap.widt h(),
314 bitmap.height()); 332 bitmap.height());
315 } else if (!FLAGS_mismatchPath.isEmpty()) { 333 } else if (!FLAGS_mismatchPath.isEmpty()) {
316 SkString outPath; 334 SkString outPath;
317 make_outname(&outPath, FLAGS_mismatchPath[0], srcPath, ".png"); 335 make_outname(&outPath, FLAGS_mismatchPath[0], srcPath, ".png");
318 if (write_bitmap(outPath.c_str(), bitmap)) { 336 if (write_bitmap(outPath.c_str(), bitmap)) {
319 gSuccessfulDecodes.push_back().appendf("\twrote %s", outPath.c_str() ); 337 gSuccessfulDecodes.push_back().appendf("\twrote %s", outPath.c_str() );
320 } else { 338 } else {
321 gEncodeFailures.push_back().set(outPath); 339 gEncodeFailures.push_back().set(outPath);
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 } 561 }
544 562
545 return failed ? -1 : 0; 563 return failed ? -1 : 0;
546 } 564 }
547 565
548 #if !defined SK_BUILD_FOR_IOS 566 #if !defined SK_BUILD_FOR_IOS
549 int main(int argc, char * const argv[]) { 567 int main(int argc, char * const argv[]) {
550 return tool_main(argc, (char**) argv); 568 return tool_main(argc, (char**) argv);
551 } 569 }
552 #endif 570 #endif
OLDNEW
« expectations/skimage/base-android-xoom.json ('K') | « expectations/skimage/base-android-xoom.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698