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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 1997703003: Make SkPngCodec decode progressively. (Closed) Base URL: https://skia.googlesource.com/skia.git@foil
Patch Set: Simplify applyXformRow Created 4 years, 3 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 | « no previous file | fuzz/fuzz.cpp » ('j') | include/codec/SkCodec.h » ('J')
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 "Resources.h" 9 #include "Resources.h"
10 #include "SkAndroidCodec.h" 10 #include "SkAndroidCodec.h"
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 default: 438 default:
439 // Everything else is considered a failure. 439 // Everything else is considered a failure.
440 return SkStringPrintf("Couldn't getPixels %s.", fPath.c_str( )); 440 return SkStringPrintf("Couldn't getPixels %s.", fPath.c_str( ));
441 } 441 }
442 442
443 draw_to_canvas(canvas, bitmapInfo, pixels.get(), rowBytes, colorPtr, colorCount, 443 draw_to_canvas(canvas, bitmapInfo, pixels.get(), rowBytes, colorPtr, colorCount,
444 fDstColorType); 444 fDstColorType);
445 break; 445 break;
446 } 446 }
447 case kScanline_Mode: { 447 case kScanline_Mode: {
448 if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, NULL , colorPtr,
449 &colorCount)) {
450 return "Could not start scanline decoder";
451 }
452
453 void* dst = pixels.get(); 448 void* dst = pixels.get();
454 uint32_t height = decodeInfo.height(); 449 uint32_t height = decodeInfo.height();
455 switch (codec->getScanlineOrder()) { 450 const bool png = fPath.endsWith("png");
456 case SkCodec::kTopDown_SkScanlineOrder: 451 const bool ico = fPath.endsWith("ico");
457 case SkCodec::kBottomUp_SkScanlineOrder: 452 bool useOldScanlineMethod = !png && !ico;
458 case SkCodec::kNone_SkScanlineOrder: 453 if (png || ico) {
459 // We do not need to check the return value. On an incomple te 454 if (SkCodec::kSuccess == codec->startIncrementalDecode(decodeInf o, dst,
460 // image, memory will be filled with a default value. 455 rowBytes, nullptr, colorPtr, &colorCount)) {
461 codec->getScanlines(dst, height, rowBytes); 456 int rowsDecoded;
462 break; 457 if (SkCodec::kIncompleteInput == codec->incrementalDecode(&r owsDecoded)) {
463 case SkCodec::kOutOfOrder_SkScanlineOrder: { 458 codec->fillIncompleteImage(decodeInfo, dst, rowBytes,
464 for (int y = 0; y < decodeInfo.height(); y++) { 459 SkCodec::kNo_ZeroInitialized, height,
465 int dstY = codec->outputScanline(y); 460 rowsDecoded);
466 void* dstPtr = SkTAddOffset<void>(dst, rowBytes * dstY);
467 // We complete the loop, even if this call begins to fai l
468 // due to an incomplete image. This ensures any uniniti alized
469 // memory will be filled with the proper value.
470 codec->getScanlines(dstPtr, 1, rowBytes);
471 } 461 }
472 break; 462 } else {
463 if (png) {
464 // Error: PNG should support incremental decode.
465 return "Could not start incremental decode";
466 }
467 // Otherwise, this is an ICO. Since incremental failed, it m ust contain a BMP,
468 // which should work via startScanlineDecode
469 useOldScanlineMethod = true;
473 } 470 }
474 } 471 }
475 472
473 if (useOldScanlineMethod) {
474 if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, NULL, colorPtr,
475 &colorCount) ) {
476 return "Could not start scanline decoder";
477 }
478
479 switch (codec->getScanlineOrder()) {
480 case SkCodec::kTopDown_SkScanlineOrder:
481 case SkCodec::kBottomUp_SkScanlineOrder:
482 // We do not need to check the return value. On an inco mplete
483 // image, memory will be filled with a default value.
484 codec->getScanlines(dst, height, rowBytes);
485 break;
486 case SkCodec::kOutOfOrder_SkScanlineOrder: {
487 for (int y = 0; y < decodeInfo.height(); y++) {
488 int dstY = codec->outputScanline(y);
489 void* dstPtr = SkTAddOffset<void>(dst, rowBytes * ds tY);
490 // We complete the loop, even if this call begins to fail
491 // due to an incomplete image. This ensures any uni nitialized
492 // memory will be filled with the proper value.
493 codec->getScanlines(dstPtr, 1, rowBytes);
494 }
495 break;
496 }
497 }
498 }
499
476 draw_to_canvas(canvas, bitmapInfo, dst, rowBytes, colorPtr, colorCou nt, fDstColorType); 500 draw_to_canvas(canvas, bitmapInfo, dst, rowBytes, colorPtr, colorCou nt, fDstColorType);
477 break; 501 break;
478 } 502 }
479 case kStripe_Mode: { 503 case kStripe_Mode: {
480 const int height = decodeInfo.height(); 504 const int height = decodeInfo.height();
481 // This value is chosen arbitrarily. We exercise more cases by choo sing a value that 505 // This value is chosen arbitrarily. We exercise more cases by choo sing a value that
482 // does not align with image blocks. 506 // does not align with image blocks.
483 const int stripeHeight = 37; 507 const int stripeHeight = 37;
484 const int numStripes = (height + stripeHeight - 1) / stripeHeight; 508 const int numStripes = (height + stripeHeight - 1) / stripeHeight;
485 void* dst = pixels.get(); 509 void* dst = pixels.get();
(...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 Error err = src.draw(&rec); 1659 Error err = src.draw(&rec);
1636 if (!err.isEmpty()) { 1660 if (!err.isEmpty()) {
1637 return err; 1661 return err;
1638 } 1662 }
1639 dl->draw(canvas); 1663 dl->draw(canvas);
1640 return check_against_reference(bitmap, src, fSink); 1664 return check_against_reference(bitmap, src, fSink);
1641 }); 1665 });
1642 } 1666 }
1643 1667
1644 } // namespace DM 1668 } // namespace DM
OLDNEW
« no previous file with comments | « no previous file | fuzz/fuzz.cpp » ('j') | include/codec/SkCodec.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698