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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 dstInfo describes the destination. |
121 * @param ZeroInitialized Whether dst is zero-initialized. The | 121 * @param ZeroInitialized Whether dst is zero-initialized. The |
122 implementation may choose to skip writing zeroes | 122 * implementation may choose to skip writing zeroes |
123 * if set to kYes_ZeroInitialized. | 123 * if set to kYes_ZeroInitialized. |
124 * @param srcInfo is the info of the source. Used to calculate the width sa
mplesize. | 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 | 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, | 126 * swizzling the row. Height sampling is not supported by t
he swizzler, |
127 but is implemented in SkScaledCodec. | 127 * but is implemented in SkScaledCodec. |
128 Sampling in Y can be done by a client with a scanline de
coder, | 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 | 129 * but sampling in X allows the swizzler to skip swizzling
pixels and |
130 reading from and writing to memory. | 130 * reading from and writing to memory. |
| 131 * @param subsetLeft the left offset on the src for each row swizzle. |
| 132 * @param subsetWidth the width of each swizzle in destination pixels. |
131 * @return A new SkSwizzler or nullptr on failure. | 133 * @return A new SkSwizzler or nullptr on failure. |
132 */ | 134 */ |
133 static SkSwizzler* CreateSwizzler(SrcConfig, const SkPMColor* ctable, | 135 static SkSwizzler* CreateSwizzler(SrcConfig, const SkPMColor* ctable, |
134 const SkImageInfo& dstInfo, SkCodec::ZeroI
nitialized, | 136 const SkImageInfo& dstInfo, SkCodec::ZeroI
nitialized, |
135 const SkImageInfo& srcInfo); | 137 const SkImageInfo& srcInfo, int subsetLeft
, int subsetWidth); |
136 /** | 138 /** |
137 * Fill the remainder of the destination with a single color | 139 * Fill the remainder of the destination with a single color |
138 * | 140 * |
139 * @param fillDst | 141 * @param fillDst |
140 * The destination row to fill from. | 142 * The destination row to fill from. |
141 * | 143 * |
142 * @param fillInfo | 144 * @param fillInfo |
143 * Contains the width of the rows to fill. | 145 * Contains the width of the rows to fill. |
144 * Contains the number of rows to fill. | 146 * Contains the number of rows to fill. |
145 * Contains the color type of the rows to fill. | 147 * Contains the color type of the rows to fill. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 * @param offset The offset before the first pixel to sample. | 192 * @param offset The offset before the first pixel to sample. |
191 Is in bytes or bits based on what deltaSrc is in. | 193 Is in bytes or bits based on what deltaSrc is in. |
192 */ | 194 */ |
193 typedef ResultAlpha (*RowProc)(void* SK_RESTRICT dstRow, | 195 typedef ResultAlpha (*RowProc)(void* SK_RESTRICT dstRow, |
194 const uint8_t* SK_RESTRICT src, | 196 const uint8_t* SK_RESTRICT src, |
195 int dstWidth, int bpp, int deltaSrc, int offs
et, | 197 int dstWidth, int bpp, int deltaSrc, int offs
et, |
196 const SkPMColor ctable[]); | 198 const SkPMColor ctable[]); |
197 | 199 |
198 const RowProc fRowProc; | 200 const RowProc fRowProc; |
199 const SkPMColor* fColorTable; // Unowned pointer | 201 const SkPMColor* fColorTable; // Unowned pointer |
200 const int fDeltaSrc; // if bitsPerPixel % 8 == 0 | 202 const int fLeft; |
201 // deltaSrc is bytesPerPixel | 203 const int fWidth; |
| 204 const int fBPP; // if bitsPerPixel % 8 == 0 |
| 205 // fBPP is bytesPerPixel |
202 // else | 206 // else |
203 // deltaSrc is bitsPerPixel | 207 // fBPP is bitsPerPixel |
204 const SkImageInfo fDstInfo; | 208 const int fDeltaSrc; // fBPP * sampleX |
205 int fCurrY; | |
206 const int fX0; // first X coord to sample | |
207 const int fSampleX; // step between X samples | |
208 | 209 |
209 SkSwizzler(RowProc proc, const SkPMColor* ctable, int deltaSrc, const SkImag
eInfo& info, | 210 SkSwizzler(RowProc proc, const SkPMColor* ctable, int left, int width, int b
pp, int deltaSrc); |
210 int sampleX); | |
211 }; | 211 }; |
212 #endif // SkSwizzler_DEFINED | 212 #endif // SkSwizzler_DEFINED |
OLD | NEW |