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

Side by Side Diff: src/codec/SkCodec_libpng.cpp

Issue 1390213002: Add subsetting to SkScanlineDecoder (Closed) Base URL: https://skia.googlesource.com/skia.git@fill-refactor
Patch Set: Response to comments Created 5 years, 2 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 | « src/codec/SkCodec_libpng.h ('k') | src/codec/SkCodec_wbmp.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 "SkCodec_libpng.h" 8 #include "SkCodec_libpng.h"
9 #include "SkCodecPriv.h" 9 #include "SkCodecPriv.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 default: 428 default:
429 //would have exited before now if the colorType was supported by png 429 //would have exited before now if the colorType was supported by png
430 SkASSERT(false); 430 SkASSERT(false);
431 } 431 }
432 432
433 // Copy the color table to the client if they request kIndex8 mode 433 // Copy the color table to the client if they request kIndex8 mode
434 copy_color_table(requestedInfo, fColorTable, ctable, ctableCount); 434 copy_color_table(requestedInfo, fColorTable, ctable, ctableCount);
435 435
436 // Create the swizzler. SkPngCodec retains ownership of the color table. 436 // Create the swizzler. SkPngCodec retains ownership of the color table.
437 const SkPMColor* colors = get_color_ptr(fColorTable.get()); 437 const SkPMColor* colors = get_color_ptr(fColorTable.get());
438 fSwizzler.reset(SkSwizzler::CreateSwizzler(fSrcConfig, colors, requestedInfo , 438 fSwizzler.reset(SkSwizzler::CreateSwizzler(fSrcConfig, colors, requestedInfo , options));
439 options.fZeroInitialized));
440 if (!fSwizzler) { 439 if (!fSwizzler) {
441 // FIXME: CreateSwizzler could fail for another reason. 440 // FIXME: CreateSwizzler could fail for another reason.
442 return kUnimplemented; 441 return kUnimplemented;
443 } 442 }
444 return kSuccess; 443 return kSuccess;
445 } 444 }
446 445
447 446
448 bool SkPngCodec::onRewind() { 447 bool SkPngCodec::onRewind() {
449 // This sets fPng_ptr and fInfo_ptr to nullptr. If read_header 448 // This sets fPng_ptr and fInfo_ptr to nullptr. If read_header
(...skipping 20 matching lines...) Expand all
470 int* rowsDecoded) { 469 int* rowsDecoded) {
471 if (!conversion_possible(requestedInfo, this->getInfo())) { 470 if (!conversion_possible(requestedInfo, this->getInfo())) {
472 return kInvalidConversion; 471 return kInvalidConversion;
473 } 472 }
474 if (options.fSubset) { 473 if (options.fSubset) {
475 // Subsets are not supported. 474 // Subsets are not supported.
476 return kUnimplemented; 475 return kUnimplemented;
477 } 476 }
478 477
479 // Note that ctable and ctableCount may be modified if there is a color tabl e 478 // Note that ctable and ctableCount may be modified if there is a color tabl e
480 const Result result = this->initializeSwizzler(requestedInfo, options, 479 const Result result = this->initializeSwizzler(requestedInfo, options, ctabl e, ctableCount);
481 ctable, ctableCount);
482 if (result != kSuccess) { 480 if (result != kSuccess) {
483 return result; 481 return result;
484 } 482 }
485 // FIXME: Could we use the return value of setjmp to specify the type of 483 // FIXME: Could we use the return value of setjmp to specify the type of
486 // error? 484 // error?
487 int row = 0; 485 int row = 0;
488 // This must be declared above the call to setjmp to avoid memory leaks on i ncomplete images. 486 // This must be declared above the call to setjmp to avoid memory leaks on i ncomplete images.
489 SkAutoMalloc storage; 487 SkAutoMalloc storage;
490 if (setjmp(png_jmpbuf(fPng_ptr))) { 488 if (setjmp(png_jmpbuf(fPng_ptr))) {
491 // Assume that any error that occurs while reading rows is caused by an incomplete input. 489 // Assume that any error that occurs while reading rows is caused by an incomplete input.
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 png_structp png_ptr, png_infop info_ptr, int bitDepth, int numberPas ses) 690 png_structp png_ptr, png_infop info_ptr, int bitDepth, int numberPas ses)
693 : INHERITED(srcInfo, stream, png_ptr, info_ptr, bitDepth, numberPasses) 691 : INHERITED(srcInfo, stream, png_ptr, info_ptr, bitDepth, numberPasses)
694 , fAlphaState(kUnknown_AlphaState) 692 , fAlphaState(kUnknown_AlphaState)
695 , fHeight(-1) 693 , fHeight(-1)
696 , fCanSkipRewind(false) 694 , fCanSkipRewind(false)
697 { 695 {
698 SkASSERT(numberPasses != 1); 696 SkASSERT(numberPasses != 1);
699 } 697 }
700 698
701 Result onStartScanlineDecode(const SkImageInfo& dstInfo, const Options& opti ons, 699 Result onStartScanlineDecode(const SkImageInfo& dstInfo, const Options& opti ons,
702 SkPMColor ctable[], int* ctableCount) override 700 SkPMColor ctable[], int* ctableCount) override {
703 {
704 if (!conversion_possible(dstInfo, this->getInfo())) { 701 if (!conversion_possible(dstInfo, this->getInfo())) {
705 return kInvalidConversion; 702 return kInvalidConversion;
706 } 703 }
707 704
708 const SkCodec::Result result = this->initializeSwizzler(dstInfo, options , ctable, 705 const Result result = this->initializeSwizzler(dstInfo, options, ctable,
709 ctableCount); 706 ctableCount);
710 if (result != SkCodec::kSuccess) { 707 if (result != kSuccess) {
711 return result; 708 return result;
712 } 709 }
713 710
714 fAlphaState = kUnknown_AlphaState; 711 fAlphaState = kUnknown_AlphaState;
715 fHeight = dstInfo.height(); 712 fHeight = dstInfo.height();
716 // FIXME: This need not be called on a second call to onStartScanlineDec ode. 713 // FIXME: This need not be called on a second call to onStartScanlineDec ode.
717 fSrcRowBytes = this->getInfo().width() * SkSwizzler::BytesPerPixel(this- >srcConfig()); 714 fSrcRowBytes = this->getInfo().width() * SkSwizzler::BytesPerPixel(this- >srcConfig());
718 fGarbageRow.reset(fSrcRowBytes); 715 fGarbageRow.reset(fSrcRowBytes);
719 fGarbageRowPtr = static_cast<uint8_t*>(fGarbageRow.get()); 716 fGarbageRowPtr = static_cast<uint8_t*>(fGarbageRow.get());
720 fCanSkipRewind = true; 717 fCanSkipRewind = true;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 837
841 if (1 == numberPasses) { 838 if (1 == numberPasses) {
842 return new SkPngScanlineDecoder(imageInfo, streamDeleter.detach(), png_p tr, info_ptr, 839 return new SkPngScanlineDecoder(imageInfo, streamDeleter.detach(), png_p tr, info_ptr,
843 bitDepth); 840 bitDepth);
844 } 841 }
845 842
846 return new SkPngInterlacedScanlineDecoder(imageInfo, streamDeleter.detach(), png_ptr, 843 return new SkPngInterlacedScanlineDecoder(imageInfo, streamDeleter.detach(), png_ptr,
847 info_ptr, bitDepth, numberPasses); 844 info_ptr, bitDepth, numberPasses);
848 } 845 }
849 846
OLDNEW
« no previous file with comments | « src/codec/SkCodec_libpng.h ('k') | src/codec/SkCodec_wbmp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698