Chromium Code Reviews| Index: src/codec/SkBmpCodec.h |
| diff --git a/src/codec/SkBmpCodec.h b/src/codec/SkBmpCodec.h |
| index 9909945c51047865cdb72c45a77cfea9125bc395..c211ca5300f9e8c10b129d9eb0b3d40dbb6467d1 100644 |
| --- a/src/codec/SkBmpCodec.h |
| +++ b/src/codec/SkBmpCodec.h |
| @@ -4,6 +4,8 @@ |
| * Use of this source code is governed by a BSD-style license that can be |
| * found in the LICENSE file. |
| */ |
| +#ifndef SkBmpCodec_DEFINED |
| +#define SkBmpCodec_DEFINED |
| #include "SkCodec.h" |
| #include "SkColorTable.h" |
| @@ -13,19 +15,15 @@ |
| #include "SkSwizzler.h" |
| #include "SkTypes.h" |
|
msarett
2015/08/03 22:52:36
Changes:
Deleted functions that relate to specifi
|
| -// TODO: rename SkCodec_libbmp files to SkBmpCodec |
| /* |
| - * |
| - * This class implements the decoding for bmp images |
| - * |
| + * This class enables code sharing between its bmp codec subclasses. It is the |
|
scroggo
2015/08/04 16:16:46
nit: This second sentence seems unnecessarily word
msarett
2015/08/04 23:14:44
Yep agreed
msarett
2015/08/04 23:14:44
Done.
|
| + * subclasses which perform the actual decoding. |
| */ |
| class SkBmpCodec : public SkCodec { |
| public: |
| /* |
| - * |
| * Describes if rows of the input start at the top or bottom of the image |
| - * |
| */ |
| enum RowOrder { |
| kTopDown_RowOrder, |
| @@ -33,161 +31,84 @@ public: |
| }; |
| /* |
| - * |
| * Checks the start of the stream to see if the image is a bmp |
| - * |
| */ |
| static bool IsBmp(SkStream*); |
| /* |
| - * |
| * Assumes IsBmp was called and returned true |
| * Creates a bmp decoder |
| * Reads enough of the stream to determine the image format |
| - * |
| */ |
| static SkCodec* NewFromStream(SkStream*); |
| /* |
| - * |
| * Creates a bmp decoder for a bmp embedded in ico |
| * Reads enough of the stream to determine the image format |
| - * |
| */ |
| static SkCodec* NewFromIco(SkStream*); |
| protected: |
| - /* |
| - * |
| - * Initiates the bmp decode |
| - * |
| - */ |
| - Result onGetPixels(const SkImageInfo& dstInfo, void* dst, |
| - size_t dstRowBytes, const Options&, SkPMColor*, |
| - int*) override; |
| + SkBmpCodec(const SkImageInfo& info, SkStream* stream, uint16_t bitsPerPixel, |
| + RowOrder rowOrder); |
| SkEncodedFormat onGetEncodedFormat() const override { return kBMP_SkEncodedFormat; } |
| -private: |
| - |
| - /* |
| - * |
| - * Used to define the input format of the bmp |
| - * |
| - */ |
| - enum BitmapInputFormat { |
| - kStandard_BitmapInputFormat, |
| - kRLE_BitmapInputFormat, |
| - kBitMask_BitmapInputFormat, |
| - kUnknown_BitmapInputFormat |
| - }; |
| - |
| - /* |
| - * |
| - * Creates the color table |
| - * Sets colorCount to the new color count if it is non-NULL |
| - */ |
| - bool createColorTable(SkAlphaType alphaType, int* colorCount); |
| - |
| - /* |
| - * |
| - * Creates a bmp decoder |
| - * Reads enough of the stream to determine the image format |
| - * |
| - */ |
| - static SkCodec* NewFromStream(SkStream*, bool isIco); |
| - |
| /* |
| - * |
| * Read enough of the stream to initialize the SkBmpCodec. Returns a bool |
| * representing success or failure. If it returned true, and codecOut was |
| * not NULL, it will be set to a new SkBmpCodec. |
| * Does *not* take ownership of the passed in SkStream. |
| - * |
| */ |
| static bool ReadHeader(SkStream*, bool isIco, SkCodec** codecOut); |
| /* |
| - * |
| - * Performs the bitmap decoding for bit masks input format |
| - * |
| + * Fix the decoded output when a bmp is encoded as fully transparent. |
| + * It was most likely not intended to be opaque. |
| */ |
| - Result decodeMask(const SkImageInfo& dstInfo, void* dst, |
| - size_t dstRowBytes, const Options& opts); |
| + static SkCodec::Result FixTransparentDecode(void* dst, size_t dstRowBytes, |
|
msarett
2015/08/03 22:52:36
FixTransparentDecode() is new. It is an improveme
scroggo
2015/08/04 16:16:46
We should find those images. Have you checked out
msarett
2015/08/04 23:14:44
I'll chat with you tomorrow, but I checked out src
|
| + SkPMColor* colorPtr, int* colorCountPtr, SkStream* stream); |
|
scroggo
2015/08/04 16:16:46
Can you update the comment that this requires a ca
msarett
2015/08/04 23:14:44
Yeah it's unfortunate. I see the trade off as:
Ra
|
| /* |
| - * |
| - * Set an RLE pixel using the color table |
| - * |
| + * Rewinds the image stream if necessary |
| */ |
| - void setRLEPixel(void* dst, size_t dstRowBytes, |
| - const SkImageInfo& dstInfo, uint32_t x, uint32_t y, |
| - uint8_t index); |
| + bool handleRewind(bool isIco); |
| + |
| /* |
| - * |
| - * Set an RLE24 pixel from R, G, B values |
| - * |
| + * Get the destination row to start filling from |
| + * Used to fill the remainder of the image on incomplete input for bmps |
| */ |
| - void setRLE24Pixel(void* dst, size_t dstRowBytes, |
| - const SkImageInfo& dstInfo, uint32_t x, uint32_t y, |
| - uint8_t red, uint8_t green, uint8_t blue); |
| + void* getDstStartRow(void* dst, size_t dstRowBytes, int32_t y) const; |
| /* |
| - * |
| - * Performs the bitmap decoding for RLE input format |
| - * |
| + * Accessors used by subclasses |
| */ |
| - Result decodeRLE(const SkImageInfo& dstInfo, void* dst, |
| - size_t dstRowBytes, const Options& opts); |
| + const uint16_t bitsPerPixel() const { return fBitsPerPixel; } |
|
scroggo
2015/08/04 16:16:46
It seems a little weird to return a const basic da
msarett
2015/08/04 23:14:44
Nope let's just make it a basic data type.
|
| + const RowOrder rowOrder() const {return fRowOrder; } |
|
scroggo
2015/08/04 16:16:46
nit: space between "{" and "return"
msarett
2015/08/04 23:14:45
Done.
|
| + |
| +private: |
| /* |
| - * |
| - * Performs the bitmap decoding for standard input format |
| - * |
| + * Used to define the input format of the bmp |
| */ |
| - Result decode(const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes, const Options& opts); |
| + enum BmpInputFormat { |
|
scroggo
2015/08/04 16:16:46
It looks like this is no longer used by the header
msarett
2015/08/04 23:14:44
Done.
|
| + kStandard_BmpInputFormat, |
| + kRLE_BmpInputFormat, |
| + kBitMask_BmpInputFormat, |
| + kUnknown_BmpInputFormat |
| + }; |
| /* |
| - * |
| - * Creates an instance of the decoder |
| - * Called only by NewFromStream |
| - * |
| - * @param srcInfo contains the source width and height |
| - * @param stream the stream of image data |
| - * @param bitsPerPixel the number of bits used to store each pixel |
| - * @param format the format of the bmp file |
| - * @param masks optional color masks for certain bmp formats, passes |
| - ownership to SkBmpCodec |
| - * @param numColors the number of colors in the color table |
| - * @param bytesPerColor the number of bytes in the stream used to represent |
| - each color in the color table |
| - * @param offset the offset of the image pixel data from the end of the |
| - * headers |
| - * @param rowOrder indicates whether rows are ordered top-down or bottom-up |
| - * @param RLEBytes used only for RLE decodes, as we must decode all |
| - * of the data at once rather than row by row |
| - * it indicates the amount of data left in the stream |
| - * after decoding the headers |
| - * |
| + * Creates a bmp decoder |
| + * Reads enough of the stream to determine the image format |
| */ |
| - SkBmpCodec(const SkImageInfo& srcInfo, SkStream* stream, |
| - uint16_t bitsPerPixel, BitmapInputFormat format, |
| - SkMasks* masks, uint32_t numColors, uint32_t bytesPerColor, |
| - uint32_t offset, RowOrder rowOrder, size_t RLEBytes, |
| - bool isIco); |
| - |
| - // Fields |
| - const uint16_t fBitsPerPixel; |
| - const BitmapInputFormat fInputFormat; |
| - SkAutoTDelete<SkMasks> fMasks; // owned |
| - SkAutoTUnref<SkColorTable> fColorTable; // owned |
| - uint32_t fNumColors; |
| - const uint32_t fBytesPerColor; |
| - const uint32_t fOffset; |
| - const RowOrder fRowOrder; |
| - const size_t fRLEBytes; |
| - const bool fIsIco; |
| + static SkCodec* NewFromStream(SkStream*, bool isIco); |
| + |
| + const uint16_t fBitsPerPixel; |
| + const RowOrder fRowOrder; |
| typedef SkCodec INHERITED; |
| }; |
| + |
| +#endif |