OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkBitmapCache.h" | 8 #include "SkBitmapCache.h" |
9 #include "SkBitmapProcState.h" | 9 #include "SkBitmapProcState.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 case kARGB_4444_SkColorType: | 424 case kARGB_4444_SkColorType: |
425 if (kPremul_SkAlphaType != at && kOpaque_SkAlphaType != at) { | 425 if (kPremul_SkAlphaType != at && kOpaque_SkAlphaType != at) { |
426 return false; | 426 return false; |
427 } | 427 } |
428 index |= 24; | 428 index |= 24; |
429 break; | 429 break; |
430 case kAlpha_8_SkColorType: | 430 case kAlpha_8_SkColorType: |
431 index |= 32; | 431 index |= 32; |
432 fPaintPMColor = SkPreMultiplyColor(paint.getColor()); | 432 fPaintPMColor = SkPreMultiplyColor(paint.getColor()); |
433 break; | 433 break; |
| 434 case kGray_8_SkColorType: |
| 435 index |= 40; |
| 436 fPaintPMColor = SkPreMultiplyColor(paint.getColor()); |
| 437 break; |
434 default: | 438 default: |
435 // TODO(dominikg): Should we ever get here? SkASSERT(false) inst
ead? | 439 // TODO(dominikg): Should we ever get here? SkASSERT(false) inst
ead? |
436 return false; | 440 return false; |
437 } | 441 } |
438 | 442 |
439 #if !SK_ARM_NEON_IS_ALWAYS | 443 #if !SK_ARM_NEON_IS_ALWAYS |
440 static const SampleProc32 gSkBitmapProcStateSample32[] = { | 444 static const SampleProc32 gSkBitmapProcStateSample32[] = { |
441 S32_opaque_D32_nofilter_DXDY, | 445 S32_opaque_D32_nofilter_DXDY, |
442 S32_alpha_D32_nofilter_DXDY, | 446 S32_alpha_D32_nofilter_DXDY, |
443 S32_opaque_D32_nofilter_DX, | 447 S32_opaque_D32_nofilter_DX, |
(...skipping 22 matching lines...) Expand all Loading... |
466 SI8_alpha_D32_filter_DX, | 470 SI8_alpha_D32_filter_DX, |
467 | 471 |
468 S4444_opaque_D32_nofilter_DXDY, | 472 S4444_opaque_D32_nofilter_DXDY, |
469 S4444_alpha_D32_nofilter_DXDY, | 473 S4444_alpha_D32_nofilter_DXDY, |
470 S4444_opaque_D32_nofilter_DX, | 474 S4444_opaque_D32_nofilter_DX, |
471 S4444_alpha_D32_nofilter_DX, | 475 S4444_alpha_D32_nofilter_DX, |
472 S4444_opaque_D32_filter_DXDY, | 476 S4444_opaque_D32_filter_DXDY, |
473 S4444_alpha_D32_filter_DXDY, | 477 S4444_alpha_D32_filter_DXDY, |
474 S4444_opaque_D32_filter_DX, | 478 S4444_opaque_D32_filter_DX, |
475 S4444_alpha_D32_filter_DX, | 479 S4444_alpha_D32_filter_DX, |
476 | 480 |
477 // A8 treats alpha/opaque the same (equally efficient) | 481 // A8 treats alpha/opaque the same (equally efficient) |
478 SA8_alpha_D32_nofilter_DXDY, | 482 SA8_alpha_D32_nofilter_DXDY, |
479 SA8_alpha_D32_nofilter_DXDY, | 483 SA8_alpha_D32_nofilter_DXDY, |
480 SA8_alpha_D32_nofilter_DX, | 484 SA8_alpha_D32_nofilter_DX, |
481 SA8_alpha_D32_nofilter_DX, | 485 SA8_alpha_D32_nofilter_DX, |
482 SA8_alpha_D32_filter_DXDY, | 486 SA8_alpha_D32_filter_DXDY, |
483 SA8_alpha_D32_filter_DXDY, | 487 SA8_alpha_D32_filter_DXDY, |
484 SA8_alpha_D32_filter_DX, | 488 SA8_alpha_D32_filter_DX, |
485 SA8_alpha_D32_filter_DX | 489 SA8_alpha_D32_filter_DX, |
| 490 |
| 491 // todo: possibly specialize on opaqueness |
| 492 SG8_alpha_D32_nofilter_DXDY, |
| 493 SG8_alpha_D32_nofilter_DXDY, |
| 494 SG8_alpha_D32_nofilter_DX, |
| 495 SG8_alpha_D32_nofilter_DX, |
| 496 SG8_alpha_D32_filter_DXDY, |
| 497 SG8_alpha_D32_filter_DXDY, |
| 498 SG8_alpha_D32_filter_DX, |
| 499 SG8_alpha_D32_filter_DX |
486 }; | 500 }; |
487 | 501 |
488 static const SampleProc16 gSkBitmapProcStateSample16[] = { | 502 static const SampleProc16 gSkBitmapProcStateSample16[] = { |
489 S32_D16_nofilter_DXDY, | 503 S32_D16_nofilter_DXDY, |
490 S32_D16_nofilter_DX, | 504 S32_D16_nofilter_DX, |
491 S32_D16_filter_DXDY, | 505 S32_D16_filter_DXDY, |
492 S32_D16_filter_DX, | 506 S32_D16_filter_DX, |
493 | 507 |
494 S16_D16_nofilter_DXDY, | 508 S16_D16_nofilter_DXDY, |
495 S16_D16_nofilter_DX, | 509 S16_D16_nofilter_DX, |
496 S16_D16_filter_DXDY, | 510 S16_D16_filter_DXDY, |
497 S16_D16_filter_DX, | 511 S16_D16_filter_DX, |
498 | 512 |
499 SI8_D16_nofilter_DXDY, | 513 SI8_D16_nofilter_DXDY, |
500 SI8_D16_nofilter_DX, | 514 SI8_D16_nofilter_DX, |
501 SI8_D16_filter_DXDY, | 515 SI8_D16_filter_DXDY, |
502 SI8_D16_filter_DX, | 516 SI8_D16_filter_DX, |
503 | 517 |
504 // Don't support 4444 -> 565 | 518 // Don't support 4444 -> 565 |
505 NULL, NULL, NULL, NULL, | 519 NULL, NULL, NULL, NULL, |
506 // Don't support A8 -> 565 | 520 // Don't support A8 -> 565 |
| 521 NULL, NULL, NULL, NULL, |
| 522 // Don't support G8 -> 565 (but we could) |
507 NULL, NULL, NULL, NULL | 523 NULL, NULL, NULL, NULL |
508 }; | 524 }; |
509 #endif | 525 #endif |
510 | 526 |
511 fSampleProc32 = SK_ARM_NEON_WRAP(gSkBitmapProcStateSample32)[index]; | 527 fSampleProc32 = SK_ARM_NEON_WRAP(gSkBitmapProcStateSample32)[index]; |
512 index >>= 1; // shift away any opaque/alpha distinction | 528 index >>= 1; // shift away any opaque/alpha distinction |
513 fSampleProc16 = SK_ARM_NEON_WRAP(gSkBitmapProcStateSample16)[index]; | 529 fSampleProc16 = SK_ARM_NEON_WRAP(gSkBitmapProcStateSample16)[index]; |
514 | 530 |
515 // our special-case shaderprocs | 531 // our special-case shaderprocs |
516 if (SK_ARM_NEON_WRAP(S16_D16_filter_DX) == fSampleProc16) { | 532 if (SK_ARM_NEON_WRAP(S16_D16_filter_DX) == fSampleProc16) { |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1002 fx += dx; | 1018 fx += dx; |
1003 } | 1019 } |
1004 } else { | 1020 } else { |
1005 for (int i = 0; i < count; ++i) { | 1021 for (int i = 0; i < count; ++i) { |
1006 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; | 1022 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; |
1007 fx += dx; | 1023 fx += dx; |
1008 } | 1024 } |
1009 } | 1025 } |
1010 } | 1026 } |
1011 | 1027 |
OLD | NEW |