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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 * | 110 * |
111 */ | 111 */ |
112 static int BytesPerPixel(SrcConfig sc) { | 112 static int BytesPerPixel(SrcConfig sc) { |
113 SkASSERT(SkIsAlign8(BitsPerPixel(sc))); | 113 SkASSERT(SkIsAlign8(BitsPerPixel(sc))); |
114 return BitsPerPixel(sc) >> 3; | 114 return BitsPerPixel(sc) >> 3; |
115 } | 115 } |
116 | 116 |
117 /** | 117 /** |
118 * Create a new SkSwizzler. | 118 * Create a new SkSwizzler. |
119 * @param SrcConfig Description of the format of the source. | 119 * @param SrcConfig Description of the format of the source. |
120 * @param dstInfo describes the destination. | 120 * @param SkImageInfo dimensions() describe both the src and the dst. |
| 121 * Other fields describe the dst. |
121 * @param ZeroInitialized Whether dst is zero-initialized. The | 122 * @param ZeroInitialized Whether dst is zero-initialized. The |
122 implementation may choose to skip writing zeroes | 123 implementation may choose to skip writing zeroes |
123 * if set to kYes_ZeroInitialized. | 124 * if set to kYes_ZeroInitialized. |
124 * @param srcInfo is the info of the source. Used to calculate the width sa
mplesize. | |
125 * Width sampling is supported by the swizzler, by skipping
pixels when | |
126 swizzling the row. Height sampling is not supported by t
he swizzler, | |
127 but is implemented in SkScaledCodec. | |
128 Sampling in Y can be done by a client with a scanline de
coder, | |
129 but sampling in X allows the swizzler to skip swizzling
pixels and | |
130 reading from and writing to memory. | |
131 * @return A new SkSwizzler or NULL on failure. | 125 * @return A new SkSwizzler or NULL on failure. |
132 */ | 126 */ |
133 static SkSwizzler* CreateSwizzler(SrcConfig, const SkPMColor* ctable, | 127 static SkSwizzler* CreateSwizzler(SrcConfig, const SkPMColor* ctable, |
134 const SkImageInfo& dstInfo, SkCodec::ZeroI
nitialized, | 128 const SkImageInfo&, SkCodec::ZeroInitializ
ed); |
135 const SkImageInfo& srcInfo); | 129 |
136 /** | 130 /** |
137 * Fill the remainder of the destination with a single color | 131 * Fill the remainder of the destination with a single color |
138 * | 132 * |
139 * @param dstStartRow | 133 * @param dstStartRow |
140 * The destination row to fill from. | 134 * The destination row to fill from. |
141 * | 135 * |
142 * @param numRows | 136 * @param numRows |
143 * The number of rows to fill. | 137 * The number of rows to fill. |
144 * | 138 * |
145 * @param colorOrIndex | 139 * @param colorOrIndex |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 * transparent, or neither | 174 * transparent, or neither |
181 */ | 175 */ |
182 ResultAlpha swizzle(void* dst, const uint8_t* SK_RESTRICT src); | 176 ResultAlpha swizzle(void* dst, const uint8_t* SK_RESTRICT src); |
183 | 177 |
184 private: | 178 private: |
185 | 179 |
186 /** | 180 /** |
187 * Method for converting raw data to Skia pixels. | 181 * Method for converting raw data to Skia pixels. |
188 * @param dstRow Row in which to write the resulting pixels. | 182 * @param dstRow Row in which to write the resulting pixels. |
189 * @param src Row of src data, in format specified by SrcConfig | 183 * @param src Row of src data, in format specified by SrcConfig |
190 * @param dstWidth Width in pixels of the destination | 184 * @param width Width in pixels |
191 * @param deltaSrc if bitsPerPixel % 8 == 0, deltaSrc is bytesPerPixel | 185 * @param deltaSrc if bitsPerPixel % 8 == 0, deltaSrc is bytesPerPixel |
192 * else, deltaSrc is bitsPerPixel | 186 * else, deltaSrc is bitsPerPixel |
193 * @param ctable Colors (used for kIndex source). | 187 * @param ctable Colors (used for kIndex source). |
194 * @param offset The offset before the first pixel to sample. | |
195 Is in bytes or bits based on what deltaSrc is in. | |
196 */ | 188 */ |
197 typedef ResultAlpha (*RowProc)(void* SK_RESTRICT dstRow, | 189 typedef ResultAlpha (*RowProc)(void* SK_RESTRICT dstRow, |
198 const uint8_t* SK_RESTRICT src, | 190 const uint8_t* SK_RESTRICT src, |
199 int dstWidth, int deltaSrc, int offset, | 191 int width, int deltaSrc, |
200 const SkPMColor ctable[]); | 192 const SkPMColor ctable[]); |
201 | 193 |
202 const RowProc fRowProc; | 194 const RowProc fRowProc; |
203 const SkPMColor* fColorTable; // Unowned pointer | 195 const SkPMColor* fColorTable; // Unowned pointer |
204 const int fDeltaSrc; // if bitsPerPixel % 8 == 0 | 196 const int fDeltaSrc; // if bitsPerPixel % 8 == 0 |
205 // deltaSrc is bytesPerPixel | 197 // deltaSrc is bytesPerPixel |
206 // else | 198 // else |
207 // deltaSrc is bitsPerPixel | 199 // deltaSrc is bitsPerPixel |
208 const SkImageInfo fDstInfo; | 200 const SkImageInfo fDstInfo; |
209 int fCurrY; | 201 int fCurrY; |
210 const int fX0; // first X coord to sample | |
211 const int fSampleX; // step between X samples | |
212 | 202 |
213 SkSwizzler(RowProc proc, const SkPMColor* ctable, int deltaSrc, const SkImag
eInfo& info, | 203 SkSwizzler(RowProc proc, const SkPMColor* ctable, int deltaSrc, |
214 int sampleX); | 204 const SkImageInfo& info); |
| 205 |
215 }; | 206 }; |
216 #endif // SkSwizzler_DEFINED | 207 #endif // SkSwizzler_DEFINED |
OLD | NEW |