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 #ifndef SkSwizzler_DEFINED | 8 #ifndef SkSwizzler_DEFINED |
9 #define SkSwizzler_DEFINED | 9 #define SkSwizzler_DEFINED |
10 | 10 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 /** | 120 /** |
121 * Create a new SkSwizzler. | 121 * Create a new SkSwizzler. |
122 * @param SrcConfig Description of the format of the source. | 122 * @param SrcConfig Description of the format of the source. |
123 * @param ctable Unowned pointer to an array of up to 256 colors for an | 123 * @param ctable Unowned pointer to an array of up to 256 colors for an |
124 * index source. | 124 * index source. |
125 * @param dstInfo Describes the destination. | 125 * @param dstInfo Describes the destination. |
126 * @param options Indicates if dst is zero-initialized. The | 126 * @param options Indicates if dst is zero-initialized. The |
127 * implementation may choose to skip writing zeroes | 127 * implementation may choose to skip writing zeroes |
128 * if set to kYes_ZeroInitialized. | 128 * if set to kYes_ZeroInitialized. |
129 * Contains subset information. | 129 * Contains subset information. |
130 * @param frame Indicates if the source pixels represent an image frame | |
131 * that is a subset of the full image. This is subtlely | |
132 * different than if the client requests a subset decode, | |
scroggo
2015/11/17 14:56:26
Maybe explain how it's different? Or where an expl
msarett
2015/11/17 18:00:50
Done.
| |
133 * and must be handled differently. | |
130 * @return A new SkSwizzler or nullptr on failure. | 134 * @return A new SkSwizzler or nullptr on failure. |
131 */ | 135 */ |
132 static SkSwizzler* CreateSwizzler(SrcConfig, const SkPMColor* ctable, | 136 static SkSwizzler* CreateSwizzler(SrcConfig, const SkPMColor* ctable, |
133 const SkImageInfo& dstInfo, const SkCodec: :Options&); | 137 const SkImageInfo& dstInfo, const SkCodec: :Options&, |
138 const SkIRect* frame = nullptr); | |
134 | 139 |
135 /** | 140 /** |
136 * Swizzle a line. Generally this will be called height times, once | 141 * Swizzle a line. Generally this will be called height times, once |
137 * for each row of source. | 142 * for each row of source. |
138 * By allowing the caller to pass in the dst pointer, we give the caller | 143 * By allowing the caller to pass in the dst pointer, we give the caller |
139 * flexibility to use the swizzler even when the encoded data does not | 144 * flexibility to use the swizzler even when the encoded data does not |
140 * store the rows in order. This also improves usability for scaled and | 145 * store the rows in order. This also improves usability for scaled and |
141 * subset decodes. | 146 * subset decodes. |
142 * @param dst Where we write the output. | 147 * @param dst Where we write the output. |
143 * @param src The next row of the source data. | 148 * @param src The next row of the source data. |
144 * @return A result code describing if the row was fully opaque, fully | 149 * @return A result code describing if the row was fully opaque, fully |
145 * transparent, or neither | 150 * transparent, or neither |
146 */ | 151 */ |
147 ResultAlpha swizzle(void* dst, const uint8_t* SK_RESTRICT src); | 152 ResultAlpha swizzle(void* dst, const uint8_t* SK_RESTRICT src); |
148 | 153 |
149 /** | 154 /** |
150 * Implement fill using a custom width. | 155 * Implement fill using a custom width. |
151 */ | 156 */ |
152 void fill(const SkImageInfo& info, void* dst, size_t rowBytes, uint32_t colo rOrIndex, | 157 void fill(const SkImageInfo& info, void* dst, size_t rowBytes, uint32_t colo rOrIndex, |
153 SkCodec::ZeroInitialized zeroInit) override { | 158 SkCodec::ZeroInitialized zeroInit) override { |
154 const SkImageInfo fillInfo = info.makeWH(fDstWidth, info.height()); | 159 const SkImageInfo fillInfo = info.makeWH(fAllocatedWidth, info.height()) ; |
155 SkSampler::Fill(fillInfo, dst, rowBytes, colorOrIndex, zeroInit); | 160 SkSampler::Fill(fillInfo, dst, rowBytes, colorOrIndex, zeroInit); |
156 } | 161 } |
157 | 162 |
158 private: | 163 private: |
159 | 164 |
160 /** | 165 /** |
161 * Method for converting raw data to Skia pixels. | 166 * Method for converting raw data to Skia pixels. |
162 * @param dstRow Row in which to write the resulting pixels. | 167 * @param dstRow Row in which to write the resulting pixels. |
163 * @param src Row of src data, in format specified by SrcConfig | 168 * @param src Row of src data, in format specified by SrcConfig |
164 * @param dstWidth Width in pixels of the destination | 169 * @param dstWidth Width in pixels of the destination |
165 * @param bpp if bitsPerPixel % 8 == 0, deltaSrc is bytesPerPixel | 170 * @param bpp if bitsPerPixel % 8 == 0, deltaSrc is bytesPerPixel |
166 * else, deltaSrc is bitsPerPixel | 171 * else, deltaSrc is bitsPerPixel |
167 * @param deltaSrc bpp * sampleX | 172 * @param deltaSrc bpp * sampleX |
168 * @param ctable Colors (used for kIndex source). | 173 * @param ctable Colors (used for kIndex source). |
169 * @param offset The offset before the first pixel to sample. | 174 * @param offset The offset before the first pixel to sample. |
170 Is in bytes or bits based on what deltaSrc is in. | 175 Is in bytes or bits based on what deltaSrc is in. |
171 */ | 176 */ |
172 typedef ResultAlpha (*RowProc)(void* SK_RESTRICT dstRow, | 177 typedef ResultAlpha (*RowProc)(void* SK_RESTRICT dstRow, |
173 const uint8_t* SK_RESTRICT src, | 178 const uint8_t* SK_RESTRICT src, |
174 int dstWidth, int bpp, int deltaSrc, int offs et, | 179 int dstWidth, int bpp, int deltaSrc, int offs et, |
175 const SkPMColor ctable[]); | 180 const SkPMColor ctable[]); |
176 | 181 |
177 const RowProc fRowProc; | 182 const RowProc fRowProc; |
178 const SkPMColor* fColorTable; // Unowned pointer | 183 const SkPMColor* fColorTable; // Unowned pointer |
179 const int fSrcOffset; // Offset of the src in pixels, allows for partial | 184 const int fSrcOffset; // Offset of the src in pixels, allows for partial |
180 // scanline decodes. | 185 // scanline decodes. |
181 int fX0; // Start coordinate for the src, may b e different than | 186 const int fDstOffset; // Offset of the dst in pixels, allows the src to be |
scroggo
2015/11/17 14:56:26
a* partial frame... ?
msarett
2015/11/17 18:00:50
Acknowledged.
| |
182 // fSrcOffset if we are sampling. | 187 // partial frame of the dst. |
183 const int fSubsetWidth; // Width of the subset of the source b efore any sampling. | 188 int fSrcOffsetBytes; // Byte offset of the src, takes sampl ing into account. |
184 int fDstWidth; // Width of dst, which may differ with sampling. | 189 int fDstOffsetBytes; // Byte offset of the dst, takes sampl ing into account. |
190 const int fSrcWidth; // Pixel width of src before any sampl ing, accounting | |
191 // for subset decodes. | |
scroggo
2015/11/17 14:56:26
When you say "accounting for subset decodes", what
msarett
2015/11/17 18:00:50
Acknowledged.
| |
192 const int fDstWidth; // Pixel width of dst before any sampl ing, accounting | |
193 // subset decodes or image frame subse ts. | |
194 int fSwizzleWidth; // The number of pixels that will be w ritten by the | |
195 // RowProc. Scaled version of fSrcWid th. | |
196 int fAllocatedWidth; // The pixel width of destination memo ry. Scaled version | |
197 // of fDstWidth. | |
185 int fSampleX; // step between X samples | 198 int fSampleX; // step between X samples |
186 const int fBPP; // if bitsPerPixel % 8 == 0 | 199 const int fSrcBPP; // Bits/bytes per pixel for the SrcCon fig |
200 // if bitsPerPixel % 8 == 0 | |
187 // fBPP is bytesPerPixel | 201 // fBPP is bytesPerPixel |
188 // else | 202 // else |
189 // fBPP is bitsPerPixel | 203 // fBPP is bitsPerPixel |
204 const int fDstBPP; // Bytes per pixel for the destination color type | |
190 | 205 |
191 SkSwizzler(RowProc proc, const SkPMColor* ctable, int srcOffset, int subsetW idth, int bpp); | 206 SkSwizzler(RowProc proc, const SkPMColor* ctable, int srcOffset, int srcWidt h, int dstOffset, |
207 int dstWidth, int srcBPP, int dstBPP); | |
192 | 208 |
193 int onSetSampleX(int) override; | 209 int onSetSampleX(int) override; |
194 | 210 |
195 }; | 211 }; |
196 #endif // SkSwizzler_DEFINED | 212 #endif // SkSwizzler_DEFINED |
OLD | NEW |