| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 break; | 345 break; |
| 346 default: | 346 default: |
| 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 return new SkMaskSwizzler(dstInfo.width(), masks, proc); | 355 return new SkMaskSwizzler(masks, proc, subsetLeft, subsetWidth); |
| 356 } | 356 } |
| 357 | 357 |
| 358 /* | 358 /* |
| 359 * | 359 * |
| 360 * Constructor for mask swizzler | 360 * Constructor for mask swizzler |
| 361 * | 361 * |
| 362 */ | 362 */ |
| 363 SkMaskSwizzler::SkMaskSwizzler(int width, SkMasks* masks, RowProc proc) | 363 SkMaskSwizzler::SkMaskSwizzler(SkMasks* masks, RowProc proc, int srcOffset, int
srcWidth) |
| 364 : fMasks(masks) | 364 : fMasks(masks) |
| 365 , fRowProc(proc) | 365 , fRowProc(proc) |
| 366 , fSrcWidth(width) | 366 , fSrcWidth(srcWidth) |
| 367 , fDstWidth(width) | 367 , fDstWidth(srcWidth) |
| 368 , fSampleX(1) | 368 , fSampleX(1) |
| 369 , fX0(0) | 369 , fSrcOffset(srcOffset) |
| 370 , fX0(srcOffset) |
| 370 {} | 371 {} |
| 371 | 372 |
| 372 int SkMaskSwizzler::onSetSampleX(int sampleX) { | 373 int SkMaskSwizzler::onSetSampleX(int sampleX) { |
| 373 // FIXME: Share this function with SkSwizzler? | 374 // FIXME: Share this function with SkSwizzler? |
| 374 SkASSERT(sampleX > 0); // Surely there is an upper limit? Should there be | 375 SkASSERT(sampleX > 0); // Surely there is an upper limit? Should there be |
| 375 // way to report failure? | 376 // way to report failure? |
| 376 fSampleX = sampleX; | 377 fSampleX = sampleX; |
| 377 fX0 = get_start_coord(sampleX); | 378 fX0 = get_start_coord(sampleX) + fSrcOffset; |
| 378 fDstWidth = get_scaled_dimension(fSrcWidth, sampleX); | 379 fDstWidth = get_scaled_dimension(fSrcWidth, sampleX); |
| 379 | 380 |
| 380 // check that fX0 is less than original width | 381 // check that fX0 is less than original width |
| 381 SkASSERT(fX0 >= 0 && fX0 < fSrcWidth); | 382 SkASSERT(fX0 >= 0 && fX0 < fSrcWidth); |
| 382 return fDstWidth; | 383 return fDstWidth; |
| 383 } | 384 } |
| 384 | 385 |
| 385 /* | 386 /* |
| 386 * | 387 * |
| 387 * Swizzle the specified row | 388 * Swizzle the specified row |
| 388 * | 389 * |
| 389 */ | 390 */ |
| 390 SkSwizzler::ResultAlpha SkMaskSwizzler::swizzle(void* dst, const uint8_t* SK_RES
TRICT src) { | 391 SkSwizzler::ResultAlpha SkMaskSwizzler::swizzle(void* dst, const uint8_t* SK_RES
TRICT src) { |
| 391 SkASSERT(nullptr != dst && nullptr != src); | 392 SkASSERT(nullptr != dst && nullptr != src); |
| 392 return fRowProc(dst, src, fDstWidth, fMasks, fX0, fSampleX); | 393 return fRowProc(dst, src, fDstWidth, fMasks, fX0, fSampleX); |
| 393 } | 394 } |
| OLD | NEW |