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