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

Side by Side Diff: tools/skdiff_main.cpp

Issue 2206633004: Move off SK_SUPPORT_LEGACY_DATA_FACTORIES. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Gotta catch 'em all. Created 4 years, 4 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
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 #include "skdiff.h" 7 #include "skdiff.h"
8 #include "skdiff_html.h" 8 #include "skdiff_html.h"
9 #include "skdiff_utils.h" 9 #include "skdiff_utils.h"
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 fDrp->fDifference.fBitmap.setPixelRef(nullptr); 336 fDrp->fDifference.fBitmap.setPixelRef(nullptr);
337 fDrp->fWhite.fBitmap.setPixelRef(nullptr); 337 fDrp->fWhite.fBitmap.setPixelRef(nullptr);
338 } 338 }
339 339
340 private: 340 private:
341 DiffRecord* fDrp; 341 DiffRecord* fDrp;
342 }; 342 };
343 343
344 static void get_bounds(DiffResource& resource, const char* name) { 344 static void get_bounds(DiffResource& resource, const char* name) {
345 if (resource.fBitmap.empty() && !DiffResource::isStatusFailed(resource.fStat us)) { 345 if (resource.fBitmap.empty() && !DiffResource::isStatusFailed(resource.fStat us)) {
346 SkAutoDataUnref fileBits(read_file(resource.fFullPath.c_str())); 346 sk_sp<SkData> fileBits(read_file(resource.fFullPath.c_str()));
347 if (nullptr == fileBits) { 347 if (fileBits) {
348 get_bitmap(fileBits.get(), resource, true);
349 } else {
348 SkDebugf("WARNING: couldn't read %s file <%s>\n", name, resource.fFu llPath.c_str()); 350 SkDebugf("WARNING: couldn't read %s file <%s>\n", name, resource.fFu llPath.c_str());
349 resource.fStatus = DiffResource::kCouldNotRead_Status; 351 resource.fStatus = DiffResource::kCouldNotRead_Status;
350 } else {
351 get_bitmap(fileBits, resource, true);
352 } 352 }
353 } 353 }
354 } 354 }
355 355
356 static void get_bounds(DiffRecord& drp) { 356 static void get_bounds(DiffRecord& drp) {
357 get_bounds(drp.fBase, "base"); 357 get_bounds(drp.fBase, "base");
358 get_bounds(drp.fComparison, "comparison"); 358 get_bounds(drp.fComparison, "comparison");
359 } 359 }
360 360
361 #ifdef SK_OS_WIN 361 #ifdef SK_OS_WIN
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 comparisonPath.append(*comparisonFiles[j]); 465 comparisonPath.append(*comparisonFiles[j]);
466 466
467 drp->fBase.fFilename = *baseFiles[i]; 467 drp->fBase.fFilename = *baseFiles[i];
468 drp->fBase.fFullPath = basePath; 468 drp->fBase.fFullPath = basePath;
469 drp->fBase.fStatus = DiffResource::kExists_Status; 469 drp->fBase.fStatus = DiffResource::kExists_Status;
470 470
471 drp->fComparison.fFilename = *comparisonFiles[j]; 471 drp->fComparison.fFilename = *comparisonFiles[j];
472 drp->fComparison.fFullPath = comparisonPath; 472 drp->fComparison.fFullPath = comparisonPath;
473 drp->fComparison.fStatus = DiffResource::kExists_Status; 473 drp->fComparison.fStatus = DiffResource::kExists_Status;
474 474
475 SkAutoDataUnref baseFileBits(read_file(drp->fBase.fFullPath.c_str()) ); 475 sk_sp<SkData> baseFileBits(read_file(drp->fBase.fFullPath.c_str()));
476 if (baseFileBits) { 476 if (baseFileBits) {
477 drp->fBase.fStatus = DiffResource::kRead_Status; 477 drp->fBase.fStatus = DiffResource::kRead_Status;
478 } 478 }
479 SkAutoDataUnref comparisonFileBits(read_file(drp->fComparison.fFullP ath.c_str())); 479 sk_sp<SkData> comparisonFileBits(read_file(drp->fComparison.fFullPat h.c_str()));
480 if (comparisonFileBits) { 480 if (comparisonFileBits) {
481 drp->fComparison.fStatus = DiffResource::kRead_Status; 481 drp->fComparison.fStatus = DiffResource::kRead_Status;
482 } 482 }
483 if (nullptr == baseFileBits || nullptr == comparisonFileBits) { 483 if (nullptr == baseFileBits || nullptr == comparisonFileBits) {
484 if (nullptr == baseFileBits) { 484 if (nullptr == baseFileBits) {
485 drp->fBase.fStatus = DiffResource::kCouldNotRead_Status; 485 drp->fBase.fStatus = DiffResource::kCouldNotRead_Status;
486 VERBOSE_STATUS("READ FAIL", ANSI_COLOR_RED, baseFiles[i]); 486 VERBOSE_STATUS("READ FAIL", ANSI_COLOR_RED, baseFiles[i]);
487 } 487 }
488 if (nullptr == comparisonFileBits) { 488 if (nullptr == comparisonFileBits) {
489 drp->fComparison.fStatus = DiffResource::kCouldNotRead_Statu s; 489 drp->fComparison.fStatus = DiffResource::kCouldNotRead_Statu s;
490 VERBOSE_STATUS("READ FAIL", ANSI_COLOR_RED, comparisonFiles[ j]); 490 VERBOSE_STATUS("READ FAIL", ANSI_COLOR_RED, comparisonFiles[ j]);
491 } 491 }
492 drp->fResult = DiffRecord::kCouldNotCompare_Result; 492 drp->fResult = DiffRecord::kCouldNotCompare_Result;
493 493
494 } else if (are_buffers_equal(baseFileBits, comparisonFileBits)) { 494 } else if (are_buffers_equal(baseFileBits.get(), comparisonFileBits. get())) {
495 drp->fResult = DiffRecord::kEqualBits_Result; 495 drp->fResult = DiffRecord::kEqualBits_Result;
496 VERBOSE_STATUS("MATCH", ANSI_COLOR_GREEN, baseFiles[i]); 496 VERBOSE_STATUS("MATCH", ANSI_COLOR_GREEN, baseFiles[i]);
497 } else { 497 } else {
498 AutoReleasePixels arp(drp); 498 AutoReleasePixels arp(drp);
499 get_bitmap(baseFileBits, drp->fBase, false); 499 get_bitmap(baseFileBits.get(), drp->fBase, false);
500 get_bitmap(comparisonFileBits, drp->fComparison, false); 500 get_bitmap(comparisonFileBits.get(), drp->fComparison, false);
501 VERBOSE_STATUS("DIFFERENT", ANSI_COLOR_RED, baseFiles[i]); 501 VERBOSE_STATUS("DIFFERENT", ANSI_COLOR_RED, baseFiles[i]);
502 if (DiffResource::kDecoded_Status == drp->fBase.fStatus && 502 if (DiffResource::kDecoded_Status == drp->fBase.fStatus &&
503 DiffResource::kDecoded_Status == drp->fComparison.fStatus) { 503 DiffResource::kDecoded_Status == drp->fComparison.fStatus) {
504 create_and_write_diff_image(drp, dmp, colorThreshold, 504 create_and_write_diff_image(drp, dmp, colorThreshold,
505 outputDir, drp->fBase.fFilename) ; 505 outputDir, drp->fBase.fFilename) ;
506 } else { 506 } else {
507 drp->fResult = DiffRecord::kCouldNotCompare_Result; 507 drp->fResult = DiffRecord::kCouldNotCompare_Result;
508 } 508 }
509 } 509 }
510 510
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 // range [0...255] are wrapped (mod 256). Do the conversion ourselves, to 853 // range [0...255] are wrapped (mod 256). Do the conversion ourselves, to
854 // make sure that we only return 0 when there were no failures. 854 // make sure that we only return 0 when there were no failures.
855 return (num_failing_results > 255) ? 255 : num_failing_results; 855 return (num_failing_results > 255) ? 255 : num_failing_results;
856 } 856 }
857 857
858 #if !defined SK_BUILD_FOR_IOS 858 #if !defined SK_BUILD_FOR_IOS
859 int main(int argc, char * const argv[]) { 859 int main(int argc, char * const argv[]) {
860 return tool_main(argc, (char**) argv); 860 return tool_main(argc, (char**) argv);
861 } 861 }
862 #endif 862 #endif
OLDNEW
« include/core/SkData.h ('K') | « tools/lua/lua_pictures.cpp ('k') | tools/skdiff_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698