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 "SkColorTable.h" |
10 #include "SkImageInfo.h" | 10 #include "SkImageInfo.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 * Describes if rows of the input start at the top or bottom of the image | 28 * Describes if rows of the input start at the top or bottom of the image |
29 * | 29 * |
30 */ | 30 */ |
31 enum RowOrder { | 31 enum RowOrder { |
32 kTopDown_RowOrder, | 32 kTopDown_RowOrder, |
33 kBottomUp_RowOrder | 33 kBottomUp_RowOrder |
34 }; | 34 }; |
35 | 35 |
36 /* | 36 /* |
37 * | 37 * |
38 * Checks the start of the stream to see if the image is a bitmap | 38 * Checks the start of the stream to see if the image is a bmp |
39 * | 39 * |
40 */ | 40 */ |
41 static bool IsBmp(SkStream*); | 41 static bool IsBmp(SkStream*); |
42 | 42 |
43 /* | 43 /* |
44 * | 44 * |
45 * Assumes IsBmp was called and returned true | 45 * Assumes IsBmp was called and returned true |
46 * Creates a bitmap decoder | 46 * Creates a bmp decoder |
47 * Reads enough of the stream to determine the image format | 47 * Reads enough of the stream to determine the image format |
48 * | 48 * |
49 */ | 49 */ |
50 static SkCodec* NewFromStream(SkStream*); | 50 static SkCodec* NewFromStream(SkStream*); |
51 | 51 |
| 52 /* |
| 53 * |
| 54 * Creates a bmp decoder for a bmp embedded in ico |
| 55 * Reads enough of the stream to determine the image format |
| 56 * |
| 57 */ |
| 58 static SkCodec* NewFromIco(SkStream*); |
| 59 |
52 protected: | 60 protected: |
53 | 61 |
54 /* | 62 /* |
55 * | 63 * |
56 * Initiates the bitmap decode | 64 * Initiates the bmp decode |
57 * | 65 * |
58 */ | 66 */ |
59 virtual Result onGetPixels(const SkImageInfo& dstInfo, void* dst, | 67 virtual Result onGetPixels(const SkImageInfo& dstInfo, void* dst, |
60 size_t dstRowBytes, const Options&, SkPMColor*, | 68 size_t dstRowBytes, const Options&, SkPMColor*, |
61 int*) SK_OVERRIDE; | 69 int*) SK_OVERRIDE; |
62 | 70 |
63 private: | 71 private: |
64 | 72 |
65 /* | 73 /* |
66 * | 74 * |
67 * Used to define the input format of the bitmap | 75 * Used to define the input format of the bmp |
68 * | 76 * |
69 */ | 77 */ |
70 enum BitmapInputFormat { | 78 enum BitmapInputFormat { |
71 kStandard_BitmapInputFormat, | 79 kStandard_BitmapInputFormat, |
72 kRLE_BitmapInputFormat, | 80 kRLE_BitmapInputFormat, |
73 kBitMask_BitmapInputFormat, | 81 kBitMask_BitmapInputFormat, |
74 kUnknown_BitmapInputFormat | 82 kUnknown_BitmapInputFormat |
75 }; | 83 }; |
76 | 84 |
77 /* | 85 /* |
78 * | 86 * |
79 * Creates the color table | 87 * Creates the color table |
80 * | 88 * |
81 */ | 89 */ |
82 bool createColorTable(SkAlphaType alphaType); | 90 bool createColorTable(SkAlphaType alphaType); |
83 | 91 |
84 /* | 92 /* |
85 * | 93 * |
| 94 * Creates a bmp decoder |
| 95 * Reads enough of the stream to determine the image format |
| 96 * |
| 97 */ |
| 98 static SkCodec* NewFromStream(SkStream*, const bool isIco); |
| 99 |
| 100 /* |
| 101 * |
86 * Performs the bitmap decoding for bit masks input format | 102 * Performs the bitmap decoding for bit masks input format |
87 * | 103 * |
88 */ | 104 */ |
89 Result decodeMask(const SkImageInfo& dstInfo, void* dst, | 105 Result decodeMask(const SkImageInfo& dstInfo, void* dst, |
90 size_t dstRowBytes); | 106 size_t dstRowBytes); |
91 | 107 |
92 /* | 108 /* |
93 * | 109 * |
94 * Set an RLE pixel using the color table | 110 * Set an RLE pixel using the color table |
95 * | 111 * |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 * @param rowOrder indicates whether rows are ordered top-down or bottom-up | 156 * @param rowOrder indicates whether rows are ordered top-down or bottom-up |
141 * @param RLEBytes used only for RLE decodes, as we must decode all | 157 * @param RLEBytes used only for RLE decodes, as we must decode all |
142 * of the data at once rather than row by row | 158 * of the data at once rather than row by row |
143 * it indicates the amount of data left in the stream | 159 * it indicates the amount of data left in the stream |
144 * after decoding the headers | 160 * after decoding the headers |
145 * | 161 * |
146 */ | 162 */ |
147 SkBmpCodec(const SkImageInfo& srcInfo, SkStream* stream, | 163 SkBmpCodec(const SkImageInfo& srcInfo, SkStream* stream, |
148 uint16_t bitsPerPixel, BitmapInputFormat format, | 164 uint16_t bitsPerPixel, BitmapInputFormat format, |
149 SkMasks* masks, uint32_t numColors, uint32_t bytesPerColor, | 165 SkMasks* masks, uint32_t numColors, uint32_t bytesPerColor, |
150 uint32_t offset, RowOrder rowOrder, size_t RLEByes); | 166 uint32_t offset, RowOrder rowOrder, size_t RLEBytes, |
| 167 bool isIco); |
151 | 168 |
152 // Fields | 169 // Fields |
153 const uint16_t fBitsPerPixel; | 170 const uint16_t fBitsPerPixel; |
154 const BitmapInputFormat fInputFormat; | 171 const BitmapInputFormat fInputFormat; |
155 SkAutoTDelete<SkMasks> fMasks; // owned | 172 SkAutoTDelete<SkMasks> fMasks; // owned |
156 SkAutoTDelete<SkColorTable> fColorTable; // owned | 173 SkAutoTDelete<SkColorTable> fColorTable; // owned |
157 uint32_t fNumColors; | 174 uint32_t fNumColors; |
158 const uint32_t fBytesPerColor; | 175 const uint32_t fBytesPerColor; |
159 const uint32_t fOffset; | 176 const uint32_t fOffset; |
160 const RowOrder fRowOrder; | 177 const RowOrder fRowOrder; |
161 const size_t fRLEBytes; | 178 const uint32_t fRLEBytes; |
| 179 const bool fIsIco; |
162 | 180 |
163 typedef SkCodec INHERITED; | 181 typedef SkCodec INHERITED; |
164 }; | 182 }; |
OLD | NEW |