| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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&, void* dst, |
| 129 size_t dstRowBytes, | 129 size_t dstRowBytes, |
| 130 SkImageGenerator::ZeroInitialized); | 130 SkImageGenerator::ZeroInitialized); |
| 131 | 131 |
| 132 /** | 132 /** |
| 133 * Fill the remainder of the destination with a single color | 133 * Fill the remainder of the destination with a single color |
| 134 * | 134 * |
| 135 * @param y | 135 * @param dstStartRow |
| 136 * The starting row for the fill. | 136 * The destination row to fill from. |
| 137 * |
| 138 * @param numRows |
| 139 * The number of rows to fill. |
| 137 * | 140 * |
| 138 * @param colorOrIndex | 141 * @param colorOrIndex |
| 139 * @param colorTable | 142 * @param colorTable |
| 140 * If dstInfo.colorType() is kIndex8, colorOrIndex is assumed to be a uint8_
t | 143 * If dstInfo.colorType() is kIndex8, colorOrIndex is assumed to be a uint8_
t |
| 141 * index, and colorTable is ignored. Each 8-bit pixel will be set to (uint8_
t) | 144 * index, and colorTable is ignored. Each 8-bit pixel will be set to (uint8_
t) |
| 142 * index. | 145 * index. |
| 143 * | 146 * |
| 144 * If dstInfo.colorType() is kN32, colorOrIndex is treated differently depen
ding on | 147 * If dstInfo.colorType() is kN32, colorOrIndex is treated differently depen
ding on |
| 145 * whether colorTable is NULL: | 148 * whether colorTable is NULL: |
| 146 * | 149 * |
| 147 * A NULL colorTable means colorOrIndex is treated as an SkPMColor (premul o
r | 150 * A NULL colorTable means colorOrIndex is treated as an SkPMColor (premul o
r |
| 148 * unpremul, depending on dstInfo.alphaType()). Each 4-byte pixel will be se
t to | 151 * unpremul, depending on dstInfo.alphaType()). Each 4-byte pixel will be se
t to |
| 149 * colorOrIndex. | 152 * colorOrIndex. |
| 150 | 153 |
| 151 * A non-NULL colorTable means colorOrIndex is treated as a uint8_t index in
to | 154 * A non-NULL colorTable means colorOrIndex is treated as a uint8_t index in
to |
| 152 * the colorTable. i.e. each 4-byte pixel will be set to | 155 * the colorTable. i.e. each 4-byte pixel will be set to |
| 153 * colorTable[(uint8_t) colorOrIndex]. | 156 * colorTable[(uint8_t) colorOrIndex]. |
| 154 * | 157 * |
| 155 * Other SkColorTypes are not supported. | 158 * Other SkColorTypes are not supported. |
| 156 * | 159 * |
| 157 */ | 160 */ |
| 158 static void Fill(void* dst, const SkImageInfo& dstInfo, size_t dstRowBytes,
uint32_t y, | 161 static void Fill(void* dstStartRow, const SkImageInfo& dstInfo, size_t dstRo
wBytes, |
| 159 uint32_t colorOrIndex, SkPMColor* colorTable); | 162 uint32_t numRows, uint32_t colorOrIndex, const SkPMColor* colorTable
); |
| 160 | 163 |
| 161 /** | 164 /** |
| 162 * Swizzle the next line. Call height times, once for each row of source. | 165 * Swizzle the next line. Call height times, once for each row of source. |
| 163 * @param src The next row of the source data. | 166 * @param src The next row of the source data. |
| 164 * @return A result code describing if the row was fully opaque, fully | 167 * @return A result code describing if the row was fully opaque, fully |
| 165 * transparent, or neither | 168 * transparent, or neither |
| 166 */ | 169 */ |
| 167 ResultAlpha next(const uint8_t* SK_RESTRICT src); | 170 ResultAlpha next(const uint8_t* SK_RESTRICT src); |
| 168 | 171 |
| 169 /** | 172 /** |
| (...skipping 10 matching lines...) Expand all Loading... |
| 180 * Update the destination row. | 183 * Update the destination row. |
| 181 * | 184 * |
| 182 * Typically this is done by next, but for a client that wants to manually | 185 * Typically this is done by next, but for a client that wants to manually |
| 183 * modify the destination row (for example, for decoding scanline one at a | 186 * modify the destination row (for example, for decoding scanline one at a |
| 184 * time) they can call this before each call to next. | 187 * time) they can call this before each call to next. |
| 185 * TODO: Maybe replace this with a version of next which allows supplying t
he | 188 * TODO: Maybe replace this with a version of next which allows supplying t
he |
| 186 * destination? | 189 * destination? |
| 187 */ | 190 */ |
| 188 void setDstRow(void* dst) { fDstRow = dst; } | 191 void setDstRow(void* dst) { fDstRow = dst; } |
| 189 | 192 |
| 193 /** |
| 194 * Get the next destination row to decode to |
| 195 */ |
| 196 void* getDstRow() { |
| 197 // kDesignateRow_NextMode does not update the fDstRow ptr. This functio
n is |
| 198 // unnecessary in that case since fDstRow will always be equal to the po
inter |
| 199 // passed to CreateSwizzler(). |
| 200 SkASSERT(kDesignateRow_NextMode != fNextMode); |
| 201 return fDstRow; |
| 202 } |
| 203 |
| 190 private: | 204 private: |
| 191 | 205 |
| 192 #ifdef SK_DEBUG | 206 #ifdef SK_DEBUG |
| 193 /* | 207 /* |
| 194 * | 208 * |
| 195 * Keep track of which version of next the caller is using | 209 * Keep track of which version of next the caller is using |
| 196 * | 210 * |
| 197 */ | 211 */ |
| 198 enum NextMode { | 212 enum NextMode { |
| 199 kUninitialized_NextMode, | 213 kUninitialized_NextMode, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 228 const SkImageInfo fDstInfo; | 242 const SkImageInfo fDstInfo; |
| 229 void* fDstRow; | 243 void* fDstRow; |
| 230 const size_t fDstRowBytes; | 244 const size_t fDstRowBytes; |
| 231 int fCurrY; | 245 int fCurrY; |
| 232 | 246 |
| 233 SkSwizzler(RowProc proc, const SkPMColor* ctable, int deltaSrc, | 247 SkSwizzler(RowProc proc, const SkPMColor* ctable, int deltaSrc, |
| 234 const SkImageInfo& info, void* dst, size_t rowBytes); | 248 const SkImageInfo& info, void* dst, size_t rowBytes); |
| 235 | 249 |
| 236 }; | 250 }; |
| 237 #endif // SkSwizzler_DEFINED | 251 #endif // SkSwizzler_DEFINED |
| OLD | NEW |