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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 srcPtr += sampleX; | 243 srcPtr += sampleX; |
244 } | 244 } |
245 return SkSwizzler::kOpaque_ResultAlpha; | 245 return SkSwizzler::kOpaque_ResultAlpha; |
246 } | 246 } |
247 | 247 |
248 /* | 248 /* |
249 * | 249 * |
250 * Create a new mask swizzler | 250 * Create a new mask swizzler |
251 * | 251 * |
252 */ | 252 */ |
253 SkMaskSwizzler* SkMaskSwizzler::CreateMaskSwizzler( | 253 SkMaskSwizzler* SkMaskSwizzler::CreateMaskSwizzler(const SkImageInfo& dstInfo, |
254 const SkImageInfo& dstInfo, const SkImageInfo& srcInfo, SkMasks* masks, | 254 const SkImageInfo& srcInfo, SkMasks* masks, uint32_t bitsPerPixel, int s
ubsetLeft, |
255 uint32_t bitsPerPixel) { | 255 int subsetWidth) { |
256 | 256 |
257 // Choose the appropriate row procedure | 257 // Choose the appropriate row procedure |
258 RowProc proc = nullptr; | 258 RowProc proc = nullptr; |
259 switch (bitsPerPixel) { | 259 switch (bitsPerPixel) { |
260 case 16: | 260 case 16: |
261 switch (dstInfo.colorType()) { | 261 switch (dstInfo.colorType()) { |
262 case kN32_SkColorType: | 262 case kN32_SkColorType: |
263 switch (dstInfo.alphaType()) { | 263 switch (dstInfo.alphaType()) { |
264 case kUnpremul_SkAlphaType: | 264 case kUnpremul_SkAlphaType: |
265 proc = &swizzle_mask16_to_n32_unpremul; | 265 proc = &swizzle_mask16_to_n32_unpremul; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 break; | 347 break; |
348 } | 348 } |
349 break; | 349 break; |
350 default: | 350 default: |
351 SkASSERT(false); | 351 SkASSERT(false); |
352 return nullptr; | 352 return nullptr; |
353 } | 353 } |
354 | 354 |
355 // Get the sample size | 355 // Get the sample size |
356 int sampleX; | 356 int sampleX; |
357 SkScaledCodec::ComputeSampleSize(dstInfo, srcInfo, &sampleX, NULL); | 357 SkScaledCodec::ComputeSampleSize(dstInfo.dimensions(), srcInfo.dimensions(),
&sampleX, nullptr); |
| 358 int startX = get_start_coord(sampleX) + subsetLeft; |
358 | 359 |
359 return new SkMaskSwizzler(dstInfo, masks, proc, sampleX); | 360 return new SkMaskSwizzler(masks, proc, subsetWidth, sampleX, startX); |
360 } | 361 } |
361 | 362 |
362 /* | 363 /* |
363 * | 364 * |
364 * Constructor for mask swizzler | 365 * Constructor for mask swizzler |
365 * | 366 * |
366 */ | 367 */ |
367 SkMaskSwizzler::SkMaskSwizzler(const SkImageInfo& dstInfo, SkMasks* masks, | 368 SkMaskSwizzler::SkMaskSwizzler(SkMasks* masks, RowProc proc, uint32_t width, uin
t32_t sampleX, |
368 RowProc proc, uint32_t sampleX) | 369 uint32_t startX) |
369 : fDstInfo(dstInfo) | 370 : fMasks(masks) |
370 , fMasks(masks) | |
371 , fRowProc(proc) | 371 , fRowProc(proc) |
| 372 , fWidth(width) |
372 , fSampleX(sampleX) | 373 , fSampleX(sampleX) |
373 , fStartX(get_start_coord(sampleX)) | 374 , fStartX(startX) |
374 {} | 375 {} |
375 | 376 |
376 /* | 377 /* |
377 * | 378 * |
378 * Swizzle the specified row | 379 * Swizzle the specified row |
379 * | 380 * |
380 */ | 381 */ |
381 SkSwizzler::ResultAlpha SkMaskSwizzler::swizzle(void* dst, const uint8_t* SK_RES
TRICT src) { | 382 SkSwizzler::ResultAlpha SkMaskSwizzler::swizzle(void* dst, const uint8_t* SK_RES
TRICT src) { |
382 SkASSERT(nullptr != dst && nullptr != src); | 383 SkASSERT(nullptr != dst && nullptr != src); |
383 return fRowProc(dst, src, fDstInfo.width(), fMasks, fStartX, fSampleX); | 384 return fRowProc(dst, src, fWidth, fMasks, fStartX, fSampleX); |
384 } | 385 } |
OLD | NEW |