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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 2023103002: Revert of Make SkPngCodec decode progressively. (Closed) Base URL: https://skia.googlesource.com/skia.git@foil
Patch Set: Created 4 years, 6 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') | 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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 default: 425 default:
426 // Everything else is considered a failure. 426 // Everything else is considered a failure.
427 return SkStringPrintf("Couldn't getPixels %s.", fPath.c_str( )); 427 return SkStringPrintf("Couldn't getPixels %s.", fPath.c_str( ));
428 } 428 }
429 429
430 draw_to_canvas(canvas, bitmapInfo, pixels.get(), rowBytes, colorPtr, colorCount, 430 draw_to_canvas(canvas, bitmapInfo, pixels.get(), rowBytes, colorPtr, colorCount,
431 fDstColorType); 431 fDstColorType);
432 break; 432 break;
433 } 433 }
434 case kScanline_Mode: { 434 case kScanline_Mode: {
435 if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, NULL , colorPtr,
436 &colorCount)) {
437 return "Could not start scanline decoder";
438 }
439
435 void* dst = pixels.get(); 440 void* dst = pixels.get();
436 uint32_t height = decodeInfo.height(); 441 uint32_t height = decodeInfo.height();
437 const bool png = fPath.endsWith("png"); 442 switch (codec->getScanlineOrder()) {
438 const bool ico = fPath.endsWith("ico"); 443 case SkCodec::kTopDown_SkScanlineOrder:
439 bool useOldScanlineMethod = !png && !ico; 444 case SkCodec::kBottomUp_SkScanlineOrder:
440 if (png || ico) { 445 case SkCodec::kNone_SkScanlineOrder:
441 if (SkCodec::kSuccess == codec->startIncrementalDecode(decodeInf o, dst, 446 // We do not need to check the return value. On an incomple te
442 rowBytes, nullptr, colorPtr, &colorCount)) { 447 // image, memory will be filled with a default value.
443 int rowsDecoded; 448 codec->getScanlines(dst, height, rowBytes);
444 if (SkCodec::kIncompleteInput == codec->incrementalDecode(&r owsDecoded)) { 449 break;
445 codec->fillIncompleteImage(decodeInfo, dst, rowBytes, 450 case SkCodec::kOutOfOrder_SkScanlineOrder: {
446 SkCodec::kNo_ZeroInitialized, height, 451 for (int y = 0; y < decodeInfo.height(); y++) {
447 rowsDecoded); 452 int dstY = codec->outputScanline(y);
453 void* dstPtr = SkTAddOffset<void>(dst, rowBytes * dstY);
454 // We complete the loop, even if this call begins to fai l
455 // due to an incomplete image. This ensures any uniniti alized
456 // memory will be filled with the proper value.
457 codec->getScanlines(dstPtr, 1, rowBytes);
448 } 458 }
449 } else { 459 break;
450 if (png) {
451 // Error: PNG should support incremental decode.
452 return "Could not start incremental decode";
453 }
454 // Otherwise, this is an ICO. Since incremental failed, it m ust contain a BMP,
455 // which should work via startScanlineDecode
456 useOldScanlineMethod = true;
457 } 460 }
458 } 461 }
459 462
460 if (useOldScanlineMethod) {
461 if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, NULL, colorPtr,
462 &colorCount) ) {
463 return "Could not start scanline decoder";
464 }
465
466 switch (codec->getScanlineOrder()) {
467 case SkCodec::kTopDown_SkScanlineOrder:
468 case SkCodec::kBottomUp_SkScanlineOrder:
469 // We do not need to check the return value. On an inco mplete
470 // image, memory will be filled with a default value.
471 codec->getScanlines(dst, height, rowBytes);
472 break;
473 case SkCodec::kOutOfOrder_SkScanlineOrder: {
474 for (int y = 0; y < decodeInfo.height(); y++) {
475 int dstY = codec->outputScanline(y);
476 void* dstPtr = SkTAddOffset<void>(dst, rowBytes * ds tY);
477 // We complete the loop, even if this call begins to fail
478 // due to an incomplete image. This ensures any uni nitialized
479 // memory will be filled with the proper value.
480 codec->getScanlines(dstPtr, 1, rowBytes);
481 }
482 break;
483 }
484 }
485 }
486
487 draw_to_canvas(canvas, bitmapInfo, dst, rowBytes, colorPtr, colorCou nt, fDstColorType); 463 draw_to_canvas(canvas, bitmapInfo, dst, rowBytes, colorPtr, colorCou nt, fDstColorType);
488 break; 464 break;
489 } 465 }
490 case kStripe_Mode: { 466 case kStripe_Mode: {
491 const int height = decodeInfo.height(); 467 const int height = decodeInfo.height();
492 // This value is chosen arbitrarily. We exercise more cases by choo sing a value that 468 // This value is chosen arbitrarily. We exercise more cases by choo sing a value that
493 // does not align with image blocks. 469 // does not align with image blocks.
494 const int stripeHeight = 37; 470 const int stripeHeight = 37;
495 const int numStripes = (height + stripeHeight - 1) / stripeHeight; 471 const int numStripes = (height + stripeHeight - 1) / stripeHeight;
496 void* dst = pixels.get(); 472 void* dst = pixels.get();
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 skr.visit(i, drawsAsSingletonPictures); 1530 skr.visit(i, drawsAsSingletonPictures);
1555 } 1531 }
1556 sk_sp<SkPicture> macroPic(macroRec.finishRecordingAsPicture()); 1532 sk_sp<SkPicture> macroPic(macroRec.finishRecordingAsPicture());
1557 1533
1558 canvas->drawPicture(macroPic); 1534 canvas->drawPicture(macroPic);
1559 return check_against_reference(bitmap, src, fSink); 1535 return check_against_reference(bitmap, src, fSink);
1560 }); 1536 });
1561 } 1537 }
1562 1538
1563 } // namespace DM 1539 } // namespace DM
OLDNEW
« no previous file with comments | « no previous file | fuzz/fuzz.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698