Index: src/codec/SkBmpRLECodec.cpp |
diff --git a/src/codec/SkBmpRLECodec.cpp b/src/codec/SkBmpRLECodec.cpp |
index c71a5409d2c2c2ee5d2fa11261594c809f4c66d1..3ccecd243188b55f93ef78c579783db4e06e7504 100644 |
--- a/src/codec/SkBmpRLECodec.cpp |
+++ b/src/codec/SkBmpRLECodec.cpp |
@@ -45,10 +45,11 @@ static bool conversion_possible(const SkImageInfo& dst, |
* Called only by NewFromStream |
*/ |
SkBmpRLECodec::SkBmpRLECodec(const SkImageInfo& info, SkStream* stream, |
+ SkBmpCodec::BmpInputFormat inputFormat, |
uint16_t bitsPerPixel, uint32_t numColors, |
uint32_t bytesPerColor, uint32_t offset, |
SkBmpCodec::RowOrder rowOrder, size_t RLEBytes) |
- : INHERITED(info, stream, bitsPerPixel, rowOrder) |
+ : INHERITED(info, stream, inputFormat, bitsPerPixel, rowOrder) |
, fColorTable(NULL) |
, fNumColors(this->computeNumColors(numColors)) |
, fBytesPerColor(bytesPerColor) |
@@ -475,3 +476,57 @@ SkCodec::Result SkBmpRLECodec::decode(const SkImageInfo& dstInfo, |
} |
} |
} |
+ |
+SkBmpRLEScanlineDecoder::SkBmpRLEScanlineDecoder(SkBmpRLECodec* codec) |
+ : INHERITED(codec->getInfo()) |
+ , fCodec(codec) |
+{} |
+ |
+SkCodec::Result SkBmpRLEScanlineDecoder::onStart(const SkImageInfo& dstInfo, |
+ const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputColorCount) { |
+ if (!fCodec->rewindIfNeeded()) { |
+ return SkCodec::kCouldNotRewind; |
+ } |
+ if (options.fSubset) { |
+ // Subsets are not supported. |
+ return SkCodec::kUnimplemented; |
+ } |
+ if (dstInfo.dimensions() != fCodec->getInfo().dimensions()) { |
+ SkCodecPrintf("Error: scaling not supported.\n"); |
+ return SkCodec::kInvalidScale; |
+ } |
+ if (!conversion_possible(dstInfo, fCodec->getInfo())) { |
+ SkCodecPrintf("Error: cannot convert input type to output type.\n"); |
+ return SkCodec::kInvalidConversion; |
+ } |
+ |
+ // Create the color table if necessary and prepare the stream for decode |
+ // Note that if it is non-NULL, inputColorCount will be modified |
+ if (!fCodec->createColorTable(inputColorCount)) { |
+ SkCodecPrintf("Error: could not create color table.\n"); |
+ return SkCodec::kInvalidInput; |
+ } |
+ |
+ // Copy the color table to the client if necessary |
+ copy_color_table(dstInfo, fCodec->fColorTable, inputColorPtr, inputColorCount); |
+ |
+ // Initialize a swizzler if necessary |
+ if (!fCodec->initializeStreamBuffer()) { |
+ SkCodecPrintf("Error: cannot initialize swizzler.\n"); |
+ return SkCodec::kInvalidConversion; |
+ } |
+ |
+ fDstInfo = dstInfo; |
+ fOpts = options; |
+ |
+ return SkCodec::kSuccess; |
+} |
+ |
+SkCodec::Result SkBmpRLEScanlineDecoder::onGetScanlines(void* dst, |
+ int count, size_t rowBytes) { |
+ // Create a new image info representing the portion of the image to decode |
+ SkImageInfo rowInfo = fDstInfo.makeWH(dstInfo().width(), count); |
+ |
+ // Decode the requested rows |
+ SkCodec::Result r = fCodec->decode(rowInfo, dst, rowBytes, fOpts); |
+} |