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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 1719293002: Make DM failures fatal (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « dm/DM.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 "DMSrcSink.h" 8 #include "DMSrcSink.h"
9 #include "SkAndroidCodec.h" 9 #include "SkAndroidCodec.h"
10 #include "SkCodec.h" 10 #include "SkCodec.h"
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 // Everything else is considered a failure. 432 // Everything else is considered a failure.
433 return SkStringPrintf("Couldn't getPixels %s.", fPath.c_str( )); 433 return SkStringPrintf("Couldn't getPixels %s.", fPath.c_str( ));
434 } 434 }
435 premultiply_if_necessary(bitmap); 435 premultiply_if_necessary(bitmap);
436 canvas->drawBitmap(bitmap, 0, 0); 436 canvas->drawBitmap(bitmap, 0, 0);
437 break; 437 break;
438 } 438 }
439 case kScanline_Mode: { 439 case kScanline_Mode: {
440 if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, NULL , colorPtr, 440 if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, NULL , colorPtr,
441 colorCountPtr)) { 441 colorCountPtr)) {
442 return Error::Nonfatal("Could not start scanline decoder"); 442 return "Could not start scanline decoder";
443 } 443 }
444 444
445 void* dst = bitmap.getAddr(0, 0); 445 void* dst = bitmap.getAddr(0, 0);
446 size_t rowBytes = bitmap.rowBytes(); 446 size_t rowBytes = bitmap.rowBytes();
447 uint32_t height = decodeInfo.height(); 447 uint32_t height = decodeInfo.height();
448 switch (codec->getScanlineOrder()) { 448 switch (codec->getScanlineOrder()) {
449 case SkCodec::kTopDown_SkScanlineOrder: 449 case SkCodec::kTopDown_SkScanlineOrder:
450 case SkCodec::kBottomUp_SkScanlineOrder: 450 case SkCodec::kBottomUp_SkScanlineOrder:
451 case SkCodec::kNone_SkScanlineOrder: 451 case SkCodec::kNone_SkScanlineOrder:
452 // We do not need to check the return value. On an incomple te 452 // We do not need to check the return value. On an incomple te
(...skipping 19 matching lines...) Expand all
472 } 472 }
473 case kStripe_Mode: { 473 case kStripe_Mode: {
474 const int height = decodeInfo.height(); 474 const int height = decodeInfo.height();
475 // This value is chosen arbitrarily. We exercise more cases by choo sing a value that 475 // This value is chosen arbitrarily. We exercise more cases by choo sing a value that
476 // does not align with image blocks. 476 // does not align with image blocks.
477 const int stripeHeight = 37; 477 const int stripeHeight = 37;
478 const int numStripes = (height + stripeHeight - 1) / stripeHeight; 478 const int numStripes = (height + stripeHeight - 1) / stripeHeight;
479 479
480 // Decode odd stripes 480 // Decode odd stripes
481 if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, NULL , colorPtr, 481 if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, NULL , colorPtr,
482 colorCountPtr) 482 colorCountPtr)) {
483 || SkCodec::kTopDown_SkScanlineOrder != codec->getScanlineOr der()) { 483 return "Could not start scanline decoder";
484 // This mode was designed to test the new skip scanlines API in libjpeg-turbo. 484 }
485 // Jpegs have kTopDown_SkScanlineOrder, and at this time, it is not interesting 485
486 // to run this test for image types that do not have this scanli ne ordering. 486 // This mode was designed to test the new skip scanlines API in libj peg-turbo.
487 return Error::Nonfatal("Could not start top-down scanline decode r"); 487 // Jpegs have kTopDown_SkScanlineOrder, and at this time, it is not interesting
488 // to run this test for image types that do not have this scanline o rdering.
489 if (SkCodec::kTopDown_SkScanlineOrder != codec->getScanlineOrder()) {
490 return Error::Nonfatal("kStripe test is only interesting for kTo pDown codecs.");
488 } 491 }
489 492
490 for (int i = 0; i < numStripes; i += 2) { 493 for (int i = 0; i < numStripes; i += 2) {
491 // Skip a stripe 494 // Skip a stripe
492 const int linesToSkip = SkTMin(stripeHeight, height - i * stripe Height); 495 const int linesToSkip = SkTMin(stripeHeight, height - i * stripe Height);
493 codec->skipScanlines(linesToSkip); 496 codec->skipScanlines(linesToSkip);
494 497
495 // Read a stripe 498 // Read a stripe
496 const int startY = (i + 1) * stripeHeight; 499 const int startY = (i + 1) * stripeHeight;
497 const int linesToRead = SkTMin(stripeHeight, height - startY); 500 const int linesToRead = SkTMin(stripeHeight, height - startY);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 if (!subsetBm.installPixels(decodeInfo, pixels, rowBytes, co lorTable.get(), 592 if (!subsetBm.installPixels(decodeInfo, pixels, rowBytes, co lorTable.get(),
590 nullptr, nullptr)) { 593 nullptr, nullptr)) {
591 return SkStringPrintf("could not install pixels for %s." , fPath.c_str()); 594 return SkStringPrintf("could not install pixels for %s." , fPath.c_str());
592 } 595 }
593 const SkCodec::Result result = codec->getPixels(decodeInfo, pixels, rowBytes, 596 const SkCodec::Result result = codec->getPixels(decodeInfo, pixels, rowBytes,
594 &opts, colorPtr, colorCountPtr); 597 &opts, colorPtr, colorCountPtr);
595 switch (result) { 598 switch (result) {
596 case SkCodec::kSuccess: 599 case SkCodec::kSuccess:
597 case SkCodec::kIncompleteInput: 600 case SkCodec::kIncompleteInput:
598 break; 601 break;
599 case SkCodec::kInvalidConversion:
600 if (0 == (x|y)) {
601 // First subset is okay to return unimplemented.
602 return Error::Nonfatal("Incompatible colortype c onversion");
603 }
604 // If the first subset succeeded, a later one should not fail.
605 // fall through to failure
606 case SkCodec::kUnimplemented:
607 if (0 == (x|y)) {
608 // First subset is okay to return unimplemented.
609 return Error::Nonfatal("subset codec not support ed");
610 }
611 // If the first subset succeeded, why would a later one fail?
612 // fall through to failure
613 default: 602 default:
614 return SkStringPrintf("subset codec failed to decode (%d, %d, %d, %d) " 603 return SkStringPrintf("subset codec failed to decode (%d, %d, %d, %d) "
615 "from %s with dimensions (%d x %d)\t error %d", 604 "from %s with dimensions (%d x %d)\t error %d",
616 x, y, decodeInfo.width(), deco deInfo.height(), 605 x, y, decodeInfo.width(), deco deInfo.height(),
617 fPath.c_str(), W, H, result); 606 fPath.c_str(), W, H, result);
618 } 607 }
619 premultiply_if_necessary(subsetBm); 608 premultiply_if_necessary(subsetBm);
620 canvas->drawBitmap(subsetBm, SkIntToScalar(left), SkIntToSca lar(top)); 609 canvas->drawBitmap(subsetBm, SkIntToScalar(left), SkIntToSca lar(top));
621 // translate by the scaled height. 610 // translate by the scaled height.
622 top += decodeInfo.height(); 611 top += decodeInfo.height();
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 if (x + 1 == divisor && y + 1 == divisor) { 758 if (x + 1 == divisor && y + 1 == divisor) {
770 finalScaledWidth = scaledWidthOffset + scaledSubsetSize. width(); 759 finalScaledWidth = scaledWidthOffset + scaledSubsetSize. width();
771 finalScaledHeight = scaledHeightOffset + scaledSubsetSiz e.height(); 760 finalScaledHeight = scaledHeightOffset + scaledSubsetSiz e.height();
772 } 761 }
773 762
774 switch (codec->getAndroidPixels(subsetDecodeInfo, pixels, bi tmap.rowBytes(), 763 switch (codec->getAndroidPixels(subsetDecodeInfo, pixels, bi tmap.rowBytes(),
775 &options)) { 764 &options)) {
776 case SkCodec::kSuccess: 765 case SkCodec::kSuccess:
777 case SkCodec::kIncompleteInput: 766 case SkCodec::kIncompleteInput:
778 break; 767 break;
779 case SkCodec::kInvalidConversion:
780 return Error::Nonfatal("Cannot convert to requested color type.");
781 default: 768 default:
782 return SkStringPrintf("Couldn't getPixels %s.", fPat h.c_str()); 769 return SkStringPrintf("Couldn't getPixels %s.", fPat h.c_str());
783 } 770 }
784 } 771 }
785 } 772 }
786 773
787 SkRect rect = SkRect::MakeXYWH(0, 0, (SkScalar) finalScaledWidth, 774 SkRect rect = SkRect::MakeXYWH(0, 0, (SkScalar) finalScaledWidth,
788 (SkScalar) finalScaledHeight); 775 (SkScalar) finalScaledHeight);
789 premultiply_if_necessary(bitmap); 776 premultiply_if_necessary(bitmap);
790 canvas->drawBitmapRect(bitmap, rect, rect, nullptr); 777 canvas->drawBitmapRect(bitmap, rect, rect, nullptr);
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 skr.visit<void>(i, drawsAsSingletonPictures); 1419 skr.visit<void>(i, drawsAsSingletonPictures);
1433 } 1420 }
1434 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); 1421 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture());
1435 1422
1436 canvas->drawPicture(macroPic); 1423 canvas->drawPicture(macroPic);
1437 return check_against_reference(bitmap, src, fSink); 1424 return check_against_reference(bitmap, src, fSink);
1438 }); 1425 });
1439 } 1426 }
1440 1427
1441 } // namespace DM 1428 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DM.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698