Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: src/codec/SkSwizzler.h

Issue 1256373002: Pass the destination pointer to next (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 SkASSERT(SkIsAlign8(BitsPerPixel(sc))); 111 SkASSERT(SkIsAlign8(BitsPerPixel(sc)));
112 return BitsPerPixel(sc) >> 3; 112 return BitsPerPixel(sc) >> 3;
113 } 113 }
114 114
115 /** 115 /**
116 * Create a new SkSwizzler. 116 * Create a new SkSwizzler.
117 * @param SrcConfig Description of the format of the source. 117 * @param SrcConfig Description of the format of the source.
118 * @param SkImageInfo dimensions() describe both the src and the dst. 118 * @param SkImageInfo dimensions() describe both the src and the dst.
119 * Other fields describe the dst. 119 * Other fields describe the dst.
120 * @param dst Destination to write pixels. Must match info and dstRowBytes 120 * @param dst Destination to write pixels. Must match info and dstRowBytes
121 * @param dstRowBytes rowBytes for dst. 121 * @param dstRowBytes rowBytes for dst.
scroggo 2015/07/27 20:42:06 Please remove the parameter descriptions for param
msarett 2015/07/27 21:11:34 Done.
122 * @param ZeroInitialized Whether dst is zero-initialized. The 122 * @param ZeroInitialized Whether dst is zero-initialized. The
123 implementation may choose to skip writing zeroes 123 implementation may choose to skip writing zeroes
124 * if set to kYes_ZeroInitialized. 124 * if set to kYes_ZeroInitialized.
125 * @return A new SkSwizzler or NULL on failure. 125 * @return A new SkSwizzler or NULL on failure.
126 */ 126 */
127 static SkSwizzler* CreateSwizzler(SrcConfig, const SkPMColor* ctable, 127 static SkSwizzler* CreateSwizzler(SrcConfig, const SkPMColor* ctable,
128 const SkImageInfo&, void* dst, 128 const SkImageInfo&,
129 size_t dstRowBytes,
130 SkCodec::ZeroInitialized); 129 SkCodec::ZeroInitialized);
131 130
132 /** 131 /**
133 * Fill the remainder of the destination with a single color 132 * Fill the remainder of the destination with a single color
134 * 133 *
135 * @param dstStartRow 134 * @param dstStartRow
136 * The destination row to fill from. 135 * The destination row to fill from.
137 * 136 *
138 * @param numRows 137 * @param numRows
139 * The number of rows to fill. 138 * The number of rows to fill.
(...skipping 17 matching lines...) Expand all
157 * 156 *
158 * If dstInfo.colorType() is kGray, colorOrIndex is always treated as an 8-b it color. 157 * If dstInfo.colorType() is kGray, colorOrIndex is always treated as an 8-b it color.
159 * 158 *
160 * Other SkColorTypes are not supported. 159 * Other SkColorTypes are not supported.
161 * 160 *
162 */ 161 */
163 static void Fill(void* dstStartRow, const SkImageInfo& dstInfo, size_t dstRo wBytes, 162 static void Fill(void* dstStartRow, const SkImageInfo& dstInfo, size_t dstRo wBytes,
164 uint32_t numRows, uint32_t colorOrIndex, const SkPMColor* colorTable ); 163 uint32_t numRows, uint32_t colorOrIndex, const SkPMColor* colorTable );
165 164
166 /** 165 /**
167 * Swizzle the next line. Call height times, once for each row of source. 166 * Swizzle the next line. Generally this will be called height times, once
167 * for each row of source.
168 * By allowing the caller to pass in the dst pointer, we give the caller
169 * flexibility to use the swizzler even when the encoded data does not
170 * store the rows in order. This also improves usability for scaled and
171 * subset decodes.
168 * @param src The next row of the source data. 172 * @param src The next row of the source data.
173 * @param dst The intended destination row for the output.
scroggo 2015/07/27 20:42:06 Maybe this should be "where to write the output",
msarett 2015/07/27 21:11:34 Yeah that is clearer.
169 * @return A result code describing if the row was fully opaque, fully 174 * @return A result code describing if the row was fully opaque, fully
170 * transparent, or neither 175 * transparent, or neither
171 */ 176 */
172 ResultAlpha next(const uint8_t* SK_RESTRICT src); 177 ResultAlpha next(const uint8_t* SK_RESTRICT src, void* dst);
scroggo 2015/07/27 20:42:06 I believe this function was named "next" because i
msarett 2015/07/27 21:11:34 Agreed!
173
174 /**
175 *
176 * Alternate version of next that allows the caller to specify the row.
177 * It is very important to only use one version of next. Since the other
178 * version modifies the dst pointer, it will change the behavior of this
179 * function. We will check this in Debug mode.
180 *
181 */
182 ResultAlpha next(const uint8_t* SK_RESTRICT src, int y);
183
184 /**
185 * Update the destination row.
186 *
187 * Typically this is done by next, but for a client that wants to manually
188 * modify the destination row (for example, for decoding scanline one at a
189 * time) they can call this before each call to next.
190 * TODO: Maybe replace this with a version of next which allows supplying t he
191 * destination?
192 */
193 void setDstRow(void* dst) { fDstRow = dst; }
194
195 /**
196 * Get the next destination row to decode to
197 */
198 void* getDstRow() {
199 // kDesignateRow_NextMode does not update the fDstRow ptr. This functio n is
200 // unnecessary in that case since fDstRow will always be equal to the po inter
201 // passed to CreateSwizzler().
202 SkASSERT(kDesignateRow_NextMode != fNextMode);
203 return fDstRow;
204 }
205 178
206 private: 179 private:
207 180
208 #ifdef SK_DEBUG
209 /*
210 *
211 * Keep track of which version of next the caller is using
212 *
213 */
214 enum NextMode {
215 kUninitialized_NextMode,
216 kConsecutive_NextMode,
217 kDesignateRow_NextMode,
218 };
219
220 NextMode fNextMode;
221 #endif
222
223 /** 181 /**
224 * Method for converting raw data to Skia pixels. 182 * Method for converting raw data to Skia pixels.
225 * @param dstRow Row in which to write the resulting pixels. 183 * @param dstRow Row in which to write the resulting pixels.
226 * @param src Row of src data, in format specified by SrcConfig 184 * @param src Row of src data, in format specified by SrcConfig
227 * @param width Width in pixels 185 * @param width Width in pixels
228 * @param deltaSrc if bitsPerPixel % 8 == 0, deltaSrc is bytesPerPixel 186 * @param deltaSrc if bitsPerPixel % 8 == 0, deltaSrc is bytesPerPixel
229 * else, deltaSrc is bitsPerPixel 187 * else, deltaSrc is bitsPerPixel
230 * @param y Line of source. 188 * @param y Line of source.
scroggo 2015/07/27 20:42:06 Please remove this line. (y was never actually us
msarett 2015/07/27 21:11:34 Done.
231 * @param ctable Colors (used for kIndex source). 189 * @param ctable Colors (used for kIndex source).
232 */ 190 */
233 typedef ResultAlpha (*RowProc)(void* SK_RESTRICT dstRow, 191 typedef ResultAlpha (*RowProc)(void* SK_RESTRICT dstRow,
234 const uint8_t* SK_RESTRICT src, 192 const uint8_t* SK_RESTRICT src,
235 int width, int deltaSrc, int y, 193 int width, int deltaSrc,
236 const SkPMColor ctable[]); 194 const SkPMColor ctable[]);
237 195
238 const RowProc fRowProc; 196 const RowProc fRowProc;
239 const SkPMColor* fColorTable; // Unowned pointer 197 const SkPMColor* fColorTable; // Unowned pointer
240 const int fDeltaSrc; // if bitsPerPixel % 8 == 0 198 const int fDeltaSrc; // if bitsPerPixel % 8 == 0
241 // deltaSrc is bytesPerPixel 199 // deltaSrc is bytesPerPixel
242 // else 200 // else
243 // deltaSrc is bitsPerPixel 201 // deltaSrc is bitsPerPixel
244 const SkImageInfo fDstInfo; 202 const SkImageInfo fDstInfo;
245 void* fDstRow;
246 const size_t fDstRowBytes;
247 int fCurrY; 203 int fCurrY;
248 204
249 SkSwizzler(RowProc proc, const SkPMColor* ctable, int deltaSrc, 205 SkSwizzler(RowProc proc, const SkPMColor* ctable, int deltaSrc,
250 const SkImageInfo& info, void* dst, size_t rowBytes); 206 const SkImageInfo& info);
251 207
252 }; 208 };
253 #endif // SkSwizzler_DEFINED 209 #endif // SkSwizzler_DEFINED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698