Index: src/codec/SkBmpRLECodec.cpp |
diff --git a/src/codec/SkBmpRLECodec.cpp b/src/codec/SkBmpRLECodec.cpp |
index 14a5b01c1f374d520856058aeef61ef9978324d3..761cd9185d9c1fa1933e941a6cb9a3f381c323f0 100644 |
--- a/src/codec/SkBmpRLECodec.cpp |
+++ b/src/codec/SkBmpRLECodec.cpp |
@@ -53,20 +53,9 @@ SkCodec::Result SkBmpRLECodec::onGetPixels(const SkImageInfo& dstInfo, |
return 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 (!this->createColorTable(inputColorCount)) { |
- SkCodecPrintf("Error: could not create color table.\n"); |
- return kInvalidInput; |
- } |
- |
- // Copy the color table to the client if necessary |
- copy_color_table(dstInfo, fColorTable, inputColorPtr, inputColorCount); |
- |
- // Initialize a swizzler if necessary |
- if (!this->initializeStreamBuffer()) { |
- SkCodecPrintf("Error: cannot initialize swizzler.\n"); |
- return kInvalidConversion; |
+ Result result = this->prepareToDecode(dstInfo, opts, inputColorPtr, inputColorCount); |
+ if (kSuccess != result) { |
+ return result; |
} |
// Perform the decode |
@@ -196,12 +185,7 @@ void SkBmpRLECodec::setPixel(void* dst, size_t dstRowBytes, |
uint8_t index) { |
// Set the row |
int height = dstInfo.height(); |
- int row; |
- if (SkBmpCodec::kBottomUp_RowOrder == this->rowOrder()) { |
- row = height - y - 1; |
- } else { |
- row = y; |
- } |
+ int row = this->getDstRow(y); |
// Set the pixel based on destination color type |
switch (dstInfo.colorType()) { |
@@ -233,12 +217,7 @@ void SkBmpRLECodec::setRGBPixel(void* dst, size_t dstRowBytes, |
uint8_t blue) { |
// Set the row |
int height = dstInfo.height(); |
- int row; |
- if (SkBmpCodec::kBottomUp_RowOrder == this->rowOrder()) { |
- row = height - y - 1; |
- } else { |
- row = y; |
- } |
+ uint32_t row = this->getDstRow(y); |
// Set the pixel based on destination color type |
switch (dstInfo.colorType()) { |
@@ -456,3 +435,24 @@ SkCodec::Result SkBmpRLECodec::decode(const SkImageInfo& dstInfo, |
} |
} |
} |
+ |
+SkCodec::Result SkBmpRLECodec::prepareToDecode(const SkImageInfo& dstInfo, |
+ const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputColorCount) { |
+ // Create the color table if necessary and prepare the stream for decode |
+ // Note that if it is non-NULL, inputColorCount will be modified |
+ if (!this->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, this->fColorTable, inputColorPtr, inputColorCount); |
+ |
+ // Initialize a buffer for encoded RLE data |
+ if (!this->initializeStreamBuffer()) { |
+ SkCodecPrintf("Error: cannot initialize swizzler.\n"); |
+ return SkCodec::kInvalidConversion; |
+ } |
+ |
+ return SkCodec::kSuccess; |
+} |