| OLD | NEW |
| 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 "SkCodec.h" | 8 #include "SkCodec.h" |
| 9 #include "SkColorTable.h" |
| 9 #include "SkImageInfo.h" | 10 #include "SkImageInfo.h" |
| 10 #include "SkMaskSwizzler.h" | 11 #include "SkMaskSwizzler.h" |
| 11 #include "SkStream.h" | 12 #include "SkStream.h" |
| 12 #include "SkSwizzler.h" | 13 #include "SkSwizzler.h" |
| 13 #include "SkTypes.h" | 14 #include "SkTypes.h" |
| 14 | 15 |
| 15 // TODO: rename SkCodec_libbmp files to SkBmpCodec | 16 // TODO: rename SkCodec_libbmp files to SkBmpCodec |
| 16 // TODO: define a wrapper for SkDebugf that doesn't always print | 17 // TODO: define a wrapper for SkDebugf that doesn't always print |
| 17 /* | 18 /* |
| 18 * | 19 * |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 */ | 69 */ |
| 69 enum BitmapInputFormat { | 70 enum BitmapInputFormat { |
| 70 kStandard_BitmapInputFormat, | 71 kStandard_BitmapInputFormat, |
| 71 kRLE_BitmapInputFormat, | 72 kRLE_BitmapInputFormat, |
| 72 kBitMask_BitmapInputFormat, | 73 kBitMask_BitmapInputFormat, |
| 73 kUnknown_BitmapInputFormat | 74 kUnknown_BitmapInputFormat |
| 74 }; | 75 }; |
| 75 | 76 |
| 76 /* | 77 /* |
| 77 * | 78 * |
| 79 * Creates the color table |
| 80 * |
| 81 */ |
| 82 bool createColorTable(SkAlphaType alphaType); |
| 83 |
| 84 /* |
| 85 * |
| 78 * Performs the bitmap decoding for bit masks input format | 86 * Performs the bitmap decoding for bit masks input format |
| 79 * | 87 * |
| 80 */ | 88 */ |
| 81 Result decodeMask(const SkImageInfo& dstInfo, void* dst, | 89 Result decodeMask(const SkImageInfo& dstInfo, void* dst, |
| 82 size_t dstRowBytes); | 90 size_t dstRowBytes); |
| 83 | 91 |
| 84 /* | 92 /* |
| 85 * | 93 * |
| 86 * Set an RLE pixel using the color table | 94 * Set an RLE pixel using the color table |
| 87 * | 95 * |
| 88 */ | 96 */ |
| 89 void setRLEPixel(SkPMColor* dst, size_t dstRowBytes, int height, | 97 void setRLEPixel(SkPMColor* dst, size_t dstRowBytes, |
| 90 uint32_t x, uint32_t y, uint8_t index); | 98 const SkImageInfo& dstInfo, uint32_t x, uint32_t y, |
| 99 uint8_t index); |
| 100 /* |
| 101 * |
| 102 * Set an RLE24 pixel from R, G, B values |
| 103 * |
| 104 */ |
| 105 void setRLE24Pixel(SkPMColor* dst, size_t dstRowBytes, |
| 106 const SkImageInfo& dstInfo, uint32_t x, uint32_t y, |
| 107 uint8_t red, uint8_t green, uint8_t blue); |
| 91 | 108 |
| 92 /* | 109 /* |
| 93 * | 110 * |
| 94 * Performs the bitmap decoding for RLE input format | 111 * Performs the bitmap decoding for RLE input format |
| 95 * | 112 * |
| 96 */ | 113 */ |
| 97 Result decodeRLE(const SkImageInfo& dstInfo, void* dst, | 114 Result decodeRLE(const SkImageInfo& dstInfo, void* dst, |
| 98 size_t dstRowBytes); | 115 size_t dstRowBytes); |
| 99 | 116 |
| 100 /* | 117 /* |
| 101 * | 118 * |
| 102 * Performs the bitmap decoding for standard input format | 119 * Performs the bitmap decoding for standard input format |
| 103 * | 120 * |
| 104 */ | 121 */ |
| 105 Result decode(const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes); | 122 Result decode(const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes); |
| 106 | 123 |
| 107 /* | 124 /* |
| 108 * | 125 * |
| 109 * Creates an instance of the decoder | 126 * Creates an instance of the decoder |
| 110 * Called only by NewFromStream | 127 * Called only by NewFromStream |
| 111 * | 128 * |
| 112 * @param srcInfo contains the source width and height | 129 * @param srcInfo contains the source width and height |
| 113 * @param stream the stream of image data | 130 * @param stream the stream of image data |
| 114 * @param bitsPerPixel the number of bits used to store each pixel | 131 * @param bitsPerPixel the number of bits used to store each pixel |
| 115 * @param format the format of the bmp file | 132 * @param format the format of the bmp file |
| 116 * @param masks optional color masks for certain bmp formats, passes | 133 * @param masks optional color masks for certain bmp formats, passes |
| 117 ownership to SkBmpCodec | 134 ownership to SkBmpCodec |
| 118 * @param colorTable array representing the color table for index-based bmp | 135 * @param numColors the number of colors in the color table |
| 119 * formats, colors are unpremultiplied, passes ownership | 136 * @param bytesPerColor the number of bytes in the stream used to represent |
| 120 * to SkBmpCodec | 137 each color in the color table |
| 138 * @param offset the offset of the image pixel data from the end of the |
| 139 * headers |
| 121 * @param rowOrder indicates whether rows are ordered top-down or bottom-up | 140 * @param rowOrder indicates whether rows are ordered top-down or bottom-up |
| 122 * @param remainingBytes used only for RLE decodes, as we must decode all | 141 * @param RLEBytes used only for RLE decodes, as we must decode all |
| 123 * of the data at once rather than row by row | 142 * of the data at once rather than row by row |
| 124 * it indicates the amount of data left in the stream | 143 * it indicates the amount of data left in the stream |
| 125 * after decoding the headers | 144 * after decoding the headers |
| 126 * | 145 * |
| 127 */ | 146 */ |
| 128 SkBmpCodec(const SkImageInfo& srcInfo, SkStream* stream, | 147 SkBmpCodec(const SkImageInfo& srcInfo, SkStream* stream, |
| 129 uint16_t bitsPerPixel, BitmapInputFormat format, | 148 uint16_t bitsPerPixel, BitmapInputFormat format, |
| 130 SkMasks* masks, SkPMColor* colorTable, | 149 SkMasks* masks, uint32_t numColors, uint32_t bytesPerColor, |
| 131 RowOrder rowOrder, uint32_t remainingBytes); | 150 uint32_t offset, RowOrder rowOrder, size_t RLEByes); |
| 132 | 151 |
| 133 // Fields | 152 // Fields |
| 134 const uint16_t fBitsPerPixel; | 153 const uint16_t fBitsPerPixel; |
| 135 const BitmapInputFormat fInputFormat; | 154 const BitmapInputFormat fInputFormat; |
| 136 SkAutoTDelete<SkMasks> fMasks; // owned | 155 SkAutoTDelete<SkMasks> fMasks; // owned |
| 137 const SkAutoTDeleteArray<SkPMColor> fColorTable; // owned, unpremul | 156 SkAutoTDelete<SkColorTable> fColorTable; // owned |
| 157 const uint32_t fNumColors; |
| 158 const uint32_t fBytesPerColor; |
| 159 const uint32_t fOffset; |
| 138 const RowOrder fRowOrder; | 160 const RowOrder fRowOrder; |
| 139 const uint32_t fRemainingBytes; | 161 const size_t fRLEBytes; |
| 140 | 162 |
| 141 typedef SkCodec INHERITED; | 163 typedef SkCodec INHERITED; |
| 142 }; | 164 }; |
| OLD | NEW |