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

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: Line length and fix comment Created 4 years, 7 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 "SkAndroidCodec.h" 9 #include "SkAndroidCodec.h"
10 #include "SkCodec.h" 10 #include "SkCodec.h"
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 default: 427 default:
428 // Everything else is considered a failure. 428 // Everything else is considered a failure.
429 return SkStringPrintf("Couldn't getPixels %s.", fPath.c_str( )); 429 return SkStringPrintf("Couldn't getPixels %s.", fPath.c_str( ));
430 } 430 }
431 premultiply_if_necessary(bitmap); 431 premultiply_if_necessary(bitmap);
432 swap_rb_if_necessary(bitmap, fDstColorType); 432 swap_rb_if_necessary(bitmap, fDstColorType);
433 canvas->drawBitmap(bitmap, 0, 0); 433 canvas->drawBitmap(bitmap, 0, 0);
434 break; 434 break;
435 } 435 }
436 case kScanline_Mode: { 436 case kScanline_Mode: {
437 if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, NULL , colorPtr, 437 const bool supportsNewScanlineDecoding = fPath.endsWith("png");
438 colorCountPtr)) { 438 if (supportsNewScanlineDecoding) {
439 return "Could not start scanline decoder"; 439 if (SkCodec::kSuccess != codec->startIncrementalDecode(decodeInf o,
440 } 440 bitmap.getPixels(), bitmap.rowBytes(), nullptr, colorPtr , colorCountPtr)) {
441 return "Could not start incremental decode";
442 }
443 int rowsDecoded;
444 if (SkCodec::kIncompleteInput == codec->incrementalDecode(&rowsD ecoded)) {
445 codec->fillIncompleteImage(decodeInfo, bitmap.getPixels(), b itmap.rowBytes(),
446 SkCodec::kNo_ZeroInitialized, dec odeInfo.height(),
447 rowsDecoded);
448 }
441 449
442 void* dst = bitmap.getAddr(0, 0); 450 } else {
443 size_t rowBytes = bitmap.rowBytes(); 451 if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, NULL, colorPtr,
444 uint32_t height = decodeInfo.height(); 452 colorCountPt r)) {
445 switch (codec->getScanlineOrder()) { 453 return "Could not start scanline decoder";
446 case SkCodec::kTopDown_SkScanlineOrder: 454 }
447 case SkCodec::kBottomUp_SkScanlineOrder: 455
448 case SkCodec::kNone_SkScanlineOrder: 456 void* dst = bitmap.getAddr(0, 0);
449 // We do not need to check the return value. On an incomple te 457 size_t rowBytes = bitmap.rowBytes();
450 // image, memory will be filled with a default value. 458 uint32_t height = decodeInfo.height();
451 codec->getScanlines(dst, height, rowBytes); 459 switch (codec->getScanlineOrder()) {
452 break; 460 case SkCodec::kTopDown_SkScanlineOrder:
453 case SkCodec::kOutOfOrder_SkScanlineOrder: { 461 case SkCodec::kBottomUp_SkScanlineOrder:
454 for (int y = 0; y < decodeInfo.height(); y++) { 462 // We do not need to check the return value. On an inco mplete
455 int dstY = codec->outputScanline(y); 463 // image, memory will be filled with a default value.
456 void* dstPtr = bitmap.getAddr(0, dstY); 464 codec->getScanlines(dst, height, rowBytes);
457 // We complete the loop, even if this call begins to fai l 465 break;
458 // due to an incomplete image. This ensures any uniniti alized 466 case SkCodec::kOutOfOrder_SkScanlineOrder: {
459 // memory will be filled with the proper value. 467 for (int y = 0; y < decodeInfo.height(); y++) {
460 codec->getScanlines(dstPtr, 1, bitmap.rowBytes()); 468 int dstY = codec->outputScanline(y);
469 void* dstPtr = bitmap.getAddr(0, dstY);
470 // We complete the loop, even if this call begins to fail
471 // due to an incomplete image. This ensures any uni nitialized
472 // memory will be filled with the proper value.
473 codec->getScanlines(dstPtr, 1, bitmap.rowBytes());
474 }
475 break;
461 } 476 }
462 break;
463 } 477 }
464 } 478 }
465 479
466 premultiply_if_necessary(bitmap); 480 premultiply_if_necessary(bitmap);
467 swap_rb_if_necessary(bitmap, fDstColorType); 481 swap_rb_if_necessary(bitmap, fDstColorType);
468 canvas->drawBitmap(bitmap, 0, 0); 482 canvas->drawBitmap(bitmap, 0, 0);
469 break; 483 break;
470 } 484 }
471 case kStripe_Mode: { 485 case kStripe_Mode: {
472 const int height = decodeInfo.height(); 486 const int height = decodeInfo.height();
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 skr.visit(i, drawsAsSingletonPictures); 1513 skr.visit(i, drawsAsSingletonPictures);
1500 } 1514 }
1501 sk_sp<SkPicture> macroPic(macroRec.finishRecordingAsPicture()); 1515 sk_sp<SkPicture> macroPic(macroRec.finishRecordingAsPicture());
1502 1516
1503 canvas->drawPicture(macroPic); 1517 canvas->drawPicture(macroPic);
1504 return check_against_reference(bitmap, src, fSink); 1518 return check_against_reference(bitmap, src, fSink);
1505 }); 1519 });
1506 } 1520 }
1507 1521
1508 } // namespace DM 1522 } // 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