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

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

Issue 1372973002: Move all knowledge of X sampling into SkScaledCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@codecSDmerge
Patch Set: Attempt to fix RLE overflow 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.h » ('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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 ,
439 options.fZeroInitialized, this->getInfo())); 439 options.fZeroInitialized));
440 if (!fSwizzler) { 440 if (!fSwizzler) {
441 // FIXME: CreateSwizzler could fail for another reason. 441 // FIXME: CreateSwizzler could fail for another reason.
442 return kUnimplemented; 442 return kUnimplemented;
443 } 443 }
444 return kSuccess; 444 return kSuccess;
445 } 445 }
446 446
447 447
448 bool SkPngCodec::onRewind() { 448 bool SkPngCodec::onRewind() {
449 // This sets fPng_ptr and fInfo_ptr to nullptr. If read_header 449 // This sets fPng_ptr and fInfo_ptr to nullptr. If read_header
(...skipping 17 matching lines...) Expand all
467 SkCodec::Result SkPngCodec::onGetPixels(const SkImageInfo& requestedInfo, void* dst, 467 SkCodec::Result SkPngCodec::onGetPixels(const SkImageInfo& requestedInfo, void* dst,
468 size_t dstRowBytes, const Options& optio ns, 468 size_t dstRowBytes, const Options& optio ns,
469 SkPMColor ctable[], int* ctableCount) { 469 SkPMColor ctable[], int* ctableCount) {
470 if (!conversion_possible(requestedInfo, this->getInfo())) { 470 if (!conversion_possible(requestedInfo, this->getInfo())) {
471 return kInvalidConversion; 471 return kInvalidConversion;
472 } 472 }
473 if (options.fSubset) { 473 if (options.fSubset) {
474 // Subsets are not supported. 474 // Subsets are not supported.
475 return kUnimplemented; 475 return kUnimplemented;
476 } 476 }
477 if (requestedInfo.dimensions() != this->getInfo().dimensions()) {
478 return kInvalidScale;
479 }
480 477
481 // 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
482 const Result result = this->initializeSwizzler(requestedInfo, options, 479 const Result result = this->initializeSwizzler(requestedInfo, options,
483 ctable, ctableCount); 480 ctable, ctableCount);
484 if (result != kSuccess) { 481 if (result != kSuccess) {
485 return result; 482 return result;
486 } 483 }
487 // FIXME: Could we use the return value of setjmp to specify the type of 484 // FIXME: Could we use the return value of setjmp to specify the type of
488 // error? 485 // error?
489 if (setjmp(png_jmpbuf(fPng_ptr))) { 486 if (setjmp(png_jmpbuf(fPng_ptr))) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 , fSrcRow(nullptr) 583 , fSrcRow(nullptr)
587 , fAlphaState(kUnknown_AlphaState) 584 , fAlphaState(kUnknown_AlphaState)
588 {} 585 {}
589 586
590 Result onStartScanlineDecode(const SkImageInfo& dstInfo, const Options& opti ons, 587 Result onStartScanlineDecode(const SkImageInfo& dstInfo, const Options& opti ons,
591 SkPMColor ctable[], int* ctableCount) override { 588 SkPMColor ctable[], int* ctableCount) override {
592 if (!conversion_possible(dstInfo, this->getInfo())) { 589 if (!conversion_possible(dstInfo, this->getInfo())) {
593 return kInvalidConversion; 590 return kInvalidConversion;
594 } 591 }
595 592
596 // Check to see if scaling was requested.
597 if (dstInfo.dimensions() != this->getInfo().dimensions()) {
598 if (!SkScaledCodec::DimensionsSupportedForSampling(this->getInfo(), dstInfo)) {
599 return kInvalidScale;
600 }
601 }
602
603 const Result result = this->initializeSwizzler(dstInfo, options, ctable, 593 const Result result = this->initializeSwizzler(dstInfo, options, ctable,
604 ctableCount); 594 ctableCount);
605 if (result != kSuccess) { 595 if (result != kSuccess) {
606 return result; 596 return result;
607 } 597 }
608 598
609 fAlphaState = kUnknown_AlphaState; 599 fAlphaState = kUnknown_AlphaState;
610 fStorage.reset(this->getInfo().width() * SkSwizzler::BytesPerPixel(this- >srcConfig())); 600 fStorage.reset(this->getInfo().width() * SkSwizzler::BytesPerPixel(this- >srcConfig()));
611 fSrcRow = static_cast<uint8_t*>(fStorage.get()); 601 fSrcRow = static_cast<uint8_t*>(fStorage.get());
612 602
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 SkASSERT(numberPasses != 1); 670 SkASSERT(numberPasses != 1);
681 } 671 }
682 672
683 Result onStartScanlineDecode(const SkImageInfo& dstInfo, const Options& opti ons, 673 Result onStartScanlineDecode(const SkImageInfo& dstInfo, const Options& opti ons,
684 SkPMColor ctable[], int* ctableCount) override 674 SkPMColor ctable[], int* ctableCount) override
685 { 675 {
686 if (!conversion_possible(dstInfo, this->getInfo())) { 676 if (!conversion_possible(dstInfo, this->getInfo())) {
687 return kInvalidConversion; 677 return kInvalidConversion;
688 } 678 }
689 679
690 // Check to see if scaling was requested. 680 const SkCodec::Result result = this->initializeSwizzler(dstInfo, options , ctable,
691 if (dstInfo.dimensions() != this->getInfo().dimensions()) { 681 ctableCount);
692 if (!SkScaledCodec::DimensionsSupportedForSampling(this->getInfo(), dstInfo)) { 682 if (result != SkCodec::kSuccess) {
693 return kInvalidScale;
694 }
695 }
696
697 const Result result = this->initializeSwizzler(dstInfo, options, ctable,
698 ctableCount);
699 if (result != kSuccess) {
700 return result; 683 return result;
701 } 684 }
702 685
703 fAlphaState = kUnknown_AlphaState; 686 fAlphaState = kUnknown_AlphaState;
704 fHeight = dstInfo.height(); 687 fHeight = dstInfo.height();
705 // FIXME: This need not be called on a second call to onStartScanlineDec ode. 688 // FIXME: This need not be called on a second call to onStartScanlineDec ode.
706 fSrcRowBytes = this->getInfo().width() * SkSwizzler::BytesPerPixel(this- >srcConfig()); 689 fSrcRowBytes = this->getInfo().width() * SkSwizzler::BytesPerPixel(this- >srcConfig());
707 fGarbageRow.reset(fSrcRowBytes); 690 fGarbageRow.reset(fSrcRowBytes);
708 fGarbageRowPtr = static_cast<uint8_t*>(fGarbageRow.get()); 691 fGarbageRowPtr = static_cast<uint8_t*>(fGarbageRow.get());
709 fCanSkipRewind = true; 692 fCanSkipRewind = true;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 809
827 if (1 == numberPasses) { 810 if (1 == numberPasses) {
828 return new SkPngScanlineDecoder(imageInfo, streamDeleter.detach(), png_p tr, info_ptr, 811 return new SkPngScanlineDecoder(imageInfo, streamDeleter.detach(), png_p tr, info_ptr,
829 bitDepth); 812 bitDepth);
830 } 813 }
831 814
832 return new SkPngInterlacedScanlineDecoder(imageInfo, streamDeleter.detach(), png_ptr, 815 return new SkPngInterlacedScanlineDecoder(imageInfo, streamDeleter.detach(), png_ptr,
833 info_ptr, bitDepth, numberPasses); 816 info_ptr, bitDepth, numberPasses);
834 } 817 }
835 818
OLDNEW
« no previous file with comments | « src/codec/SkCodec_libpng.h ('k') | src/codec/SkCodec_wbmp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698