Index: src/codec/SkBmpCodec.cpp |
diff --git a/src/codec/SkBmpCodec.cpp b/src/codec/SkBmpCodec.cpp |
index fa4608ffeec513cacd753fc3efc721497d1eff3c..2b70cb415891d95cf5b2a8f81258e65e5b36b635 100644 |
--- a/src/codec/SkBmpCodec.cpp |
+++ b/src/codec/SkBmpCodec.cpp |
@@ -44,16 +44,6 @@ enum BmpCompressionMethod { |
}; |
/* |
- * Used to define the input format of the bmp |
- */ |
-enum BmpInputFormat { |
- kStandard_BmpInputFormat, |
- kRLE_BmpInputFormat, |
- kBitMask_BmpInputFormat, |
- kUnknown_BmpInputFormat |
-}; |
- |
-/* |
* Checks the start of the stream to see if the image is a bitmap |
*/ |
bool SkBmpCodec::IsBmp(SkStream* stream) { |
@@ -472,7 +462,7 @@ bool SkBmpCodec::ReadHeader(SkStream* stream, bool inIco, SkCodec** codecOut) { |
switch (inputFormat) { |
case kStandard_BmpInputFormat: |
*codecOut = SkNEW_ARGS(SkBmpStandardCodec, (imageInfo, stream, |
- bitsPerPixel, numColors, bytesPerColor, |
+ inputFormat, bitsPerPixel, numColors, bytesPerColor, |
offset - bytesRead, rowOrder, inIco)); |
return true; |
case kBitMask_BmpInputFormat: |
@@ -490,7 +480,7 @@ bool SkBmpCodec::ReadHeader(SkStream* stream, bool inIco, SkCodec** codecOut) { |
} |
*codecOut = SkNEW_ARGS(SkBmpMaskCodec, (imageInfo, stream, |
- bitsPerPixel, masks.detach(), rowOrder)); |
+ inputFormat, bitsPerPixel, masks.detach(), rowOrder)); |
return true; |
case kRLE_BmpInputFormat: |
// Bmp-in-Ico must be standard mode |
@@ -499,7 +489,7 @@ bool SkBmpCodec::ReadHeader(SkStream* stream, bool inIco, SkCodec** codecOut) { |
// Icos skip the header that contains totalBytes. |
SkASSERT(!inIco); |
*codecOut = SkNEW_ARGS(SkBmpRLECodec, ( |
- imageInfo, stream, bitsPerPixel, numColors, |
+ imageInfo, stream, inputFormat, bitsPerPixel, numColors, |
bytesPerColor, offset - bytesRead, rowOrder, RLEBytes)); |
return true; |
default: |
@@ -529,8 +519,9 @@ SkCodec* SkBmpCodec::NewFromStream(SkStream* stream, bool inIco) { |
} |
SkBmpCodec::SkBmpCodec(const SkImageInfo& info, SkStream* stream, |
- uint16_t bitsPerPixel, RowOrder rowOrder) |
+ BmpInputFormat inputFormat, uint16_t bitsPerPixel, RowOrder rowOrder) |
: INHERITED(info, stream) |
+ , fInputFormat(inputFormat) |
, fBitsPerPixel(bitsPerPixel) |
, fRowOrder(rowOrder) |
{} |
@@ -562,3 +553,21 @@ uint32_t SkBmpCodec::computeNumColors(uint32_t numColors) { |
} |
return numColors; |
} |
+ |
+SkScanlineDecoder* SkBmpCodec::NewSDFromStream(SkStream* stream) { |
+ SkAutoTDelete<SkBmpCodec> codec(static_cast<SkBmpCodec*>(SkBmpCodec::NewFromStream(stream))); |
+ if (!codec) { |
+ return NULL; |
+ } |
+ |
+ switch(codec->fInputFormat) { |
+ case kStandard_BmpInputFormat: |
+ return SkNEW_ARGS(SkBmpStandardScanlineDecoder, ((SkBmpStandardCodec*) codec.detach())); |
+ case kBitMask_BmpInputFormat: |
+ return SkNEW_ARGS(SkBmpMaskScanlineDecoder, ((SkBmpMaskCodec*) codec.detach())); |
+ case kRLE_BmpInputFormat: |
+ return SkNEW_ARGS(SkBmpRLEScanlineDecoder, ((SkBmpRLECodec*) codec.detach())); |
+ default: |
+ return NULL; |
scroggo
2015/08/13 21:25:35
Can this case be reached?
msarett
2015/08/14 15:44:48
No. Adding an SkASSERT(false).
|
+ } |
+} |