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 #include "SkCodecPriv.h" | 8 #include "SkCodecPriv.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkMaskSwizzler.h" | 10 #include "SkMaskSwizzler.h" |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 SkMaskSwizzler* SkMaskSwizzler::CreateMaskSwizzler(const SkImageInfo& dstInfo, | 228 SkMaskSwizzler* SkMaskSwizzler::CreateMaskSwizzler(const SkImageInfo& dstInfo, |
229 const SkImageInfo& srcInfo, SkMasks* masks, uint32_t bitsPerPixel, | 229 const SkImageInfo& srcInfo, SkMasks* masks, uint32_t bitsPerPixel, |
230 const SkCodec::Options& options) { | 230 const SkCodec::Options& options) { |
231 | 231 |
232 // Choose the appropriate row procedure | 232 // Choose the appropriate row procedure |
233 RowProc proc = nullptr; | 233 RowProc proc = nullptr; |
234 switch (bitsPerPixel) { | 234 switch (bitsPerPixel) { |
235 case 16: | 235 case 16: |
236 switch (dstInfo.colorType()) { | 236 switch (dstInfo.colorType()) { |
237 case kN32_SkColorType: | 237 case kN32_SkColorType: |
238 switch (dstInfo.alphaType()) { | 238 if (kOpaque_SkAlphaType == srcInfo.alphaType()) { |
239 case kUnpremul_SkAlphaType: | 239 proc = &swizzle_mask16_to_n32_opaque; |
240 proc = &swizzle_mask16_to_n32_unpremul; | 240 } else { |
241 break; | 241 switch (dstInfo.alphaType()) { |
242 case kPremul_SkAlphaType: | 242 case kUnpremul_SkAlphaType: |
243 proc = &swizzle_mask16_to_n32_premul; | 243 proc = &swizzle_mask16_to_n32_unpremul; |
244 break; | 244 break; |
245 case kOpaque_SkAlphaType: | 245 case kPremul_SkAlphaType: |
246 proc = &swizzle_mask16_to_n32_opaque; | 246 proc = &swizzle_mask16_to_n32_premul; |
247 break; | 247 break; |
248 default: | 248 default: |
249 break; | 249 break; |
| 250 } |
250 } | 251 } |
251 break; | 252 break; |
252 case kRGB_565_SkColorType: | 253 case kRGB_565_SkColorType: |
253 proc = &swizzle_mask16_to_565; | 254 proc = &swizzle_mask16_to_565; |
254 break; | 255 break; |
255 default: | 256 default: |
256 break; | 257 break; |
257 } | 258 } |
258 break; | 259 break; |
259 case 24: | 260 case 24: |
260 switch (dstInfo.colorType()) { | 261 switch (dstInfo.colorType()) { |
261 case kN32_SkColorType: | 262 case kN32_SkColorType: |
262 switch (dstInfo.alphaType()) { | 263 if (kOpaque_SkAlphaType == srcInfo.alphaType()) { |
263 case kUnpremul_SkAlphaType: | 264 proc = &swizzle_mask24_to_n32_opaque; |
264 proc = &swizzle_mask24_to_n32_unpremul; | 265 } else { |
265 break; | 266 switch (dstInfo.alphaType()) { |
266 case kPremul_SkAlphaType: | 267 case kUnpremul_SkAlphaType: |
267 proc = &swizzle_mask24_to_n32_premul; | 268 proc = &swizzle_mask24_to_n32_unpremul; |
268 break; | 269 break; |
269 case kOpaque_SkAlphaType: | 270 case kPremul_SkAlphaType: |
270 proc = &swizzle_mask24_to_n32_opaque; | 271 proc = &swizzle_mask24_to_n32_premul; |
271 break; | 272 break; |
272 default: | 273 default: |
273 break; | 274 break; |
| 275 } |
274 } | 276 } |
275 break; | 277 break; |
276 case kRGB_565_SkColorType: | 278 case kRGB_565_SkColorType: |
277 proc = &swizzle_mask24_to_565; | 279 proc = &swizzle_mask24_to_565; |
278 break; | 280 break; |
279 default: | 281 default: |
280 break; | 282 break; |
281 } | 283 } |
282 break; | 284 break; |
283 case 32: | 285 case 32: |
284 switch (dstInfo.colorType()) { | 286 switch (dstInfo.colorType()) { |
285 case kN32_SkColorType: | 287 case kN32_SkColorType: |
286 switch (dstInfo.alphaType()) { | 288 if (kOpaque_SkAlphaType == srcInfo.alphaType()) { |
287 case kUnpremul_SkAlphaType: | 289 proc = &swizzle_mask32_to_n32_opaque; |
288 proc = &swizzle_mask32_to_n32_unpremul; | 290 } else { |
289 break; | 291 switch (dstInfo.alphaType()) { |
290 case kPremul_SkAlphaType: | 292 case kUnpremul_SkAlphaType: |
291 proc = &swizzle_mask32_to_n32_premul; | 293 proc = &swizzle_mask32_to_n32_unpremul; |
292 break; | 294 break; |
293 case kOpaque_SkAlphaType: | 295 case kPremul_SkAlphaType: |
294 proc = &swizzle_mask32_to_n32_opaque; | 296 proc = &swizzle_mask32_to_n32_premul; |
295 break; | 297 break; |
296 default: | 298 default: |
297 break; | 299 break; |
| 300 } |
298 } | 301 } |
299 break; | 302 break; |
300 case kRGB_565_SkColorType: | 303 case kRGB_565_SkColorType: |
301 proc = &swizzle_mask32_to_565; | 304 proc = &swizzle_mask32_to_565; |
302 break; | 305 break; |
303 default: | 306 default: |
304 break; | 307 break; |
305 } | 308 } |
306 break; | 309 break; |
307 default: | 310 default: |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 | 352 |
350 /* | 353 /* |
351 * | 354 * |
352 * Swizzle the specified row | 355 * Swizzle the specified row |
353 * | 356 * |
354 */ | 357 */ |
355 void SkMaskSwizzler::swizzle(void* dst, const uint8_t* SK_RESTRICT src) { | 358 void SkMaskSwizzler::swizzle(void* dst, const uint8_t* SK_RESTRICT src) { |
356 SkASSERT(nullptr != dst && nullptr != src); | 359 SkASSERT(nullptr != dst && nullptr != src); |
357 fRowProc(dst, src, fDstWidth, fMasks, fX0, fSampleX); | 360 fRowProc(dst, src, fDstWidth, fMasks, fX0, fSampleX); |
358 } | 361 } |
OLD | NEW |