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/SkBmpCodec.cpp

Issue 1381483002: Call rewindIfNeeded in SkCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@codecSDmerge
Patch Set: Rebase 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 | « include/codec/SkCodec.h ('k') | src/codec/SkBmpMaskCodec.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 "SkBmpCodec.h" 8 #include "SkBmpCodec.h"
9 #include "SkBmpMaskCodec.h" 9 #include "SkBmpMaskCodec.h"
10 #include "SkBmpRLECodec.h" 10 #include "SkBmpRLECodec.h"
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 // Also set numColors to maxColors when it is too large 569 // Also set numColors to maxColors when it is too large
570 uint32_t maxColors = 1 << fBitsPerPixel; 570 uint32_t maxColors = 1 << fBitsPerPixel;
571 if (numColors == 0 || numColors >= maxColors) { 571 if (numColors == 0 || numColors >= maxColors) {
572 return maxColors; 572 return maxColors;
573 } 573 }
574 return numColors; 574 return numColors;
575 } 575 }
576 576
577 SkCodec::Result SkBmpCodec::onStartScanlineDecode(const SkImageInfo& dstInfo, 577 SkCodec::Result SkBmpCodec::onStartScanlineDecode(const SkImageInfo& dstInfo,
578 const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputCo lorCount) { 578 const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputCo lorCount) {
579 if (!this->rewindIfNeeded()) {
580 return kCouldNotRewind;
581 }
582 if (options.fSubset) { 579 if (options.fSubset) {
583 // Subsets are not supported. 580 // Subsets are not supported.
584 return kUnimplemented; 581 return kUnimplemented;
585 } 582 }
586 if (dstInfo.dimensions() != this->getInfo().dimensions()) { 583 if (dstInfo.dimensions() != this->getInfo().dimensions()) {
587 if (!SkScaledCodec::DimensionsSupportedForSampling(this->getInfo(), dstI nfo)) { 584 if (!SkScaledCodec::DimensionsSupportedForSampling(this->getInfo(), dstI nfo)) {
588 return SkCodec::kInvalidScale; 585 return SkCodec::kInvalidScale;
589 } 586 }
590 } 587 }
591 if (!conversion_possible(dstInfo, this->getInfo())) { 588 if (!conversion_possible(dstInfo, this->getInfo())) {
592 SkCodecPrintf("Error: cannot convert input type to output type.\n"); 589 SkCodecPrintf("Error: cannot convert input type to output type.\n");
593 return kInvalidConversion; 590 return kInvalidConversion;
594 } 591 }
595 592
596 return prepareToDecode(dstInfo, options, inputColorPtr, inputColorCount); 593 return prepareToDecode(dstInfo, options, inputColorPtr, inputColorCount);
597 } 594 }
598 595
599 SkCodec::Result SkBmpCodec::onGetScanlines(void* dst, int count, size_t rowBytes ) { 596 SkCodec::Result SkBmpCodec::onGetScanlines(void* dst, int count, size_t rowBytes ) {
600 // Create a new image info representing the portion of the image to decode 597 // Create a new image info representing the portion of the image to decode
601 SkImageInfo rowInfo = this->dstInfo().makeWH(this->dstInfo().width(), count) ; 598 SkImageInfo rowInfo = this->dstInfo().makeWH(this->dstInfo().width(), count) ;
602 599
603 // Decode the requested rows 600 // Decode the requested rows
604 return this->decodeRows(rowInfo, dst, rowBytes, this->options()); 601 return this->decodeRows(rowInfo, dst, rowBytes, this->options());
605 } 602 }
606 603
607 int SkBmpCodec::onNextScanline() const { 604 int SkBmpCodec::onNextScanline() const {
608 return this->getDstRow(this->INHERITED::onNextScanline(), this->dstInfo().he ight()); 605 return this->getDstRow(this->INHERITED::onNextScanline(), this->dstInfo().he ight());
609 } 606 }
OLDNEW
« no previous file with comments | « include/codec/SkCodec.h ('k') | src/codec/SkBmpMaskCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698