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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 117 |
118 /** | 118 /** |
119 * Create a new SkSwizzler. | 119 * Create a new SkSwizzler. |
120 * @param SrcConfig Description of the format of the source. | 120 * @param SrcConfig Description of the format of the source. |
121 * @param ctable Unowned pointer to an array of up to 256 colors for an | 121 * @param ctable Unowned pointer to an array of up to 256 colors for an |
122 * index source. | 122 * index source. |
123 * @param dstInfo Describes the destination. | 123 * @param dstInfo Describes the destination. |
124 * @param ZeroInitialized Whether dst is zero-initialized. The | 124 * @param ZeroInitialized Whether dst is zero-initialized. The |
125 * implementation may choose to skip writing zeroes | 125 * implementation may choose to skip writing zeroes |
126 * if set to kYes_ZeroInitialized. | 126 * if set to kYes_ZeroInitialized. |
| 127 * @param srcInfo is the info of the source. Used to calculate the width sa
mplesize. |
| 128 * Width sampling is supported by the swizzler, by skipping
pixels when |
| 129 * swizzling the row. Height sampling is not supported by t
he swizzler, |
| 130 * but is implemented in SkScaledCodec. |
| 131 * Sampling in Y can be done by a client with a scanline de
coder, |
| 132 * but sampling in X allows the swizzler to skip swizzling
pixels and |
| 133 * reading from and writing to memory. |
| 134 * @param subsetLeft the left offset on the src for each row swizzle. |
| 135 * @param subsetWidth the width of each swizzle in destination pixels. |
127 * @return A new SkSwizzler or nullptr on failure. | 136 * @return A new SkSwizzler or nullptr on failure. |
128 */ | 137 */ |
129 static SkSwizzler* CreateSwizzler(SrcConfig, const SkPMColor* ctable, | 138 static SkSwizzler* CreateSwizzler(SrcConfig, const SkPMColor* ctable, |
130 const SkImageInfo& dstInfo, SkCodec::ZeroI
nitialized); | 139 const SkImageInfo& dstInfo, SkCodec::ZeroI
nitialized, |
| 140 int subsetLeft, int subsetWidth); |
131 | 141 |
132 /** | 142 /** |
133 * Swizzle a line. Generally this will be called height times, once | 143 * Swizzle a line. Generally this will be called height times, once |
134 * for each row of source. | 144 * for each row of source. |
135 * By allowing the caller to pass in the dst pointer, we give the caller | 145 * By allowing the caller to pass in the dst pointer, we give the caller |
136 * flexibility to use the swizzler even when the encoded data does not | 146 * flexibility to use the swizzler even when the encoded data does not |
137 * store the rows in order. This also improves usability for scaled and | 147 * store the rows in order. This also improves usability for scaled and |
138 * subset decodes. | 148 * subset decodes. |
139 * @param dst Where we write the output. | 149 * @param dst Where we write the output. |
140 * @param src The next row of the source data. | 150 * @param src The next row of the source data. |
(...skipping 16 matching lines...) Expand all Loading... |
157 * @param offset The offset before the first pixel to sample. | 167 * @param offset The offset before the first pixel to sample. |
158 Is in bytes or bits based on what deltaSrc is in. | 168 Is in bytes or bits based on what deltaSrc is in. |
159 */ | 169 */ |
160 typedef ResultAlpha (*RowProc)(void* SK_RESTRICT dstRow, | 170 typedef ResultAlpha (*RowProc)(void* SK_RESTRICT dstRow, |
161 const uint8_t* SK_RESTRICT src, | 171 const uint8_t* SK_RESTRICT src, |
162 int dstWidth, int bpp, int deltaSrc, int offs
et, | 172 int dstWidth, int bpp, int deltaSrc, int offs
et, |
163 const SkPMColor ctable[]); | 173 const SkPMColor ctable[]); |
164 | 174 |
165 const RowProc fRowProc; | 175 const RowProc fRowProc; |
166 const SkPMColor* fColorTable; // Unowned pointer | 176 const SkPMColor* fColorTable; // Unowned pointer |
167 const int fDeltaSrc; // if bitsPerPixel % 8 == 0 | 177 const int fSrcOffset; // Offset of the src in pixels, allows
for partial |
168 // deltaSrc is bytesPerPixel | 178 // scanline decodes. |
169 // else | 179 int fX0; // Start coordinate for the src, may b
e different than |
170 // deltaSrc is bitsPerPixel | 180 // fSrcOffset if we are sampling. |
171 const int fSrcWidth; // Width of the source - i.e. before a
ny sampling. | 181 const int fSrcWidth; // Width of the source - i.e. before a
ny sampling. |
172 int fDstWidth; // Width of dst, which may differ with
sampling. | 182 int fDstWidth; // Width of dst, which may differ with
sampling. |
173 int fX0; // first X coord to sample | |
174 int fSampleX; // step between X samples | 183 int fSampleX; // step between X samples |
| 184 const int fBPP; // if bitsPerPixel % 8 == 0 |
| 185 // fBPP is bytesPerPixel |
| 186 // else |
| 187 // fBPP is bitsPerPixel |
175 | 188 |
176 SkSwizzler(RowProc proc, const SkPMColor* ctable, int deltaSrc, int srcWidth
); | 189 SkSwizzler(RowProc proc, const SkPMColor* ctable, int srcOffset, int srcWidt
h, int bpp); |
177 | 190 |
178 int onSetSampleX(int) override; | 191 int onSetSampleX(int) override; |
179 | 192 |
180 int onGetScaledWidth() override { | 193 int onGetScaledWidth() override { |
181 return fDstWidth; | 194 return fDstWidth; |
182 } | 195 } |
183 }; | 196 }; |
184 #endif // SkSwizzler_DEFINED | 197 #endif // SkSwizzler_DEFINED |
OLD | NEW |