Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: src/core/SkBitmapProcState.cpp

Issue 796063007: separate out the scaline-choosing to simplify chooseProcs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« src/core/SkBitmapProcState.h ('K') | « src/core/SkBitmapProcState.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 if (SkPaint::kLow_FilterLevel == fFilterLevel) { 450 if (SkPaint::kLow_FilterLevel == fFilterLevel) {
451 // Only try bilerp if the matrix is "interesting" and 451 // Only try bilerp if the matrix is "interesting" and
452 // the image has a suitable size. 452 // the image has a suitable size.
453 453
454 if (fInvType <= SkMatrix::kTranslate_Mask || 454 if (fInvType <= SkMatrix::kTranslate_Mask ||
455 !valid_for_filtering(fBitmap->width() | fBitmap->height())) { 455 !valid_for_filtering(fBitmap->width() | fBitmap->height())) {
456 fFilterLevel = SkPaint::kNone_FilterLevel; 456 fFilterLevel = SkPaint::kNone_FilterLevel;
457 } 457 }
458 } 458 }
459 459
460 // At this point, we know exactly what kind of sampling the per-scanline 460 return this->chooseScanlineProcs(trivialMatrix, clampClamp, paint);
461 // shader will perform. 461 }
462 462
463 bool SkBitmapProcState::chooseScanlineProcs(bool trivialMatrix, bool clampClamp,
464 const SkPaint& paint) {
463 fMatrixProc = this->chooseMatrixProc(trivialMatrix); 465 fMatrixProc = this->chooseMatrixProc(trivialMatrix);
464 // TODO(dominikg): SkASSERT(fMatrixProc) instead? chooseMatrixProc never ret urns NULL. 466 // TODO(dominikg): SkASSERT(fMatrixProc) instead? chooseMatrixProc never ret urns NULL.
465 if (NULL == fMatrixProc) { 467 if (NULL == fMatrixProc) {
466 return false; 468 return false;
467 } 469 }
468 470
469 /////////////////////////////////////////////////////////////////////// 471 ///////////////////////////////////////////////////////////////////////
470 472
471 const SkAlphaType at = fBitmap->alphaType(); 473 const SkAlphaType at = fBitmap->alphaType();
472 474
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 break; 513 break;
512 case kAlpha_8_SkColorType: 514 case kAlpha_8_SkColorType:
513 index |= 32; 515 index |= 32;
514 fPaintPMColor = SkPreMultiplyColor(paint.getColor()); 516 fPaintPMColor = SkPreMultiplyColor(paint.getColor());
515 break; 517 break;
516 default: 518 default:
517 // TODO(dominikg): Should we ever get here? SkASSERT(false) inst ead? 519 // TODO(dominikg): Should we ever get here? SkASSERT(false) inst ead?
518 return false; 520 return false;
519 } 521 }
520 522
521 #if !SK_ARM_NEON_IS_ALWAYS 523 #if !SK_ARM_NEON_IS_ALWAYS
522 static const SampleProc32 gSkBitmapProcStateSample32[] = { 524 static const SampleProc32 gSkBitmapProcStateSample32[] = {
523 S32_opaque_D32_nofilter_DXDY, 525 S32_opaque_D32_nofilter_DXDY,
524 S32_alpha_D32_nofilter_DXDY, 526 S32_alpha_D32_nofilter_DXDY,
525 S32_opaque_D32_nofilter_DX, 527 S32_opaque_D32_nofilter_DX,
526 S32_alpha_D32_nofilter_DX, 528 S32_alpha_D32_nofilter_DX,
527 S32_opaque_D32_filter_DXDY, 529 S32_opaque_D32_filter_DXDY,
528 S32_alpha_D32_filter_DXDY, 530 S32_alpha_D32_filter_DXDY,
529 S32_opaque_D32_filter_DX, 531 S32_opaque_D32_filter_DX,
530 S32_alpha_D32_filter_DX, 532 S32_alpha_D32_filter_DX,
531 533
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 SI8_D16_nofilter_DXDY, 583 SI8_D16_nofilter_DXDY,
582 SI8_D16_nofilter_DX, 584 SI8_D16_nofilter_DX,
583 SI8_D16_filter_DXDY, 585 SI8_D16_filter_DXDY,
584 SI8_D16_filter_DX, 586 SI8_D16_filter_DX,
585 587
586 // Don't support 4444 -> 565 588 // Don't support 4444 -> 565
587 NULL, NULL, NULL, NULL, 589 NULL, NULL, NULL, NULL,
588 // Don't support A8 -> 565 590 // Don't support A8 -> 565
589 NULL, NULL, NULL, NULL 591 NULL, NULL, NULL, NULL
590 }; 592 };
591 #endif 593 #endif
592 594
593 fSampleProc32 = SK_ARM_NEON_WRAP(gSkBitmapProcStateSample32)[index]; 595 fSampleProc32 = SK_ARM_NEON_WRAP(gSkBitmapProcStateSample32)[index];
594 index >>= 1; // shift away any opaque/alpha distinction 596 index >>= 1; // shift away any opaque/alpha distinction
595 fSampleProc16 = SK_ARM_NEON_WRAP(gSkBitmapProcStateSample16)[index]; 597 fSampleProc16 = SK_ARM_NEON_WRAP(gSkBitmapProcStateSample16)[index];
596 598
597 // our special-case shaderprocs 599 // our special-case shaderprocs
598 if (SK_ARM_NEON_WRAP(S16_D16_filter_DX) == fSampleProc16) { 600 if (SK_ARM_NEON_WRAP(S16_D16_filter_DX) == fSampleProc16) {
599 if (clampClamp) { 601 if (clampClamp) {
600 fShaderProc16 = SK_ARM_NEON_WRAP(Clamp_S16_D16_filter_DX_shaderp roc); 602 fShaderProc16 = SK_ARM_NEON_WRAP(Clamp_S16_D16_filter_DX_shaderp roc);
601 } else if (SkShader::kRepeat_TileMode == fTileModeX && 603 } else if (SkShader::kRepeat_TileMode == fTileModeX &&
602 SkShader::kRepeat_TileMode == fTileModeY) { 604 SkShader::kRepeat_TileMode == fTileModeY) {
603 fShaderProc16 = SK_ARM_NEON_WRAP(Repeat_S16_D16_filter_DX_shader proc); 605 fShaderProc16 = SK_ARM_NEON_WRAP(Repeat_S16_D16_filter_DX_shader proc);
604 } 606 }
605 } else if (SK_ARM_NEON_WRAP(SI8_opaque_D32_filter_DX) == fSampleProc32 & & clampClamp) { 607 } else if (SK_ARM_NEON_WRAP(SI8_opaque_D32_filter_DX) == fSampleProc32 & & clampClamp) {
606 fShaderProc32 = SK_ARM_NEON_WRAP(Clamp_SI8_opaque_D32_filter_DX_shad erproc); 608 fShaderProc32 = SK_ARM_NEON_WRAP(Clamp_SI8_opaque_D32_filter_DX_shad erproc);
607 } else if (S32_opaque_D32_nofilter_DX == fSampleProc32 && clampClamp) { 609 } else if (S32_opaque_D32_nofilter_DX == fSampleProc32 && clampClamp) {
608 fShaderProc32 = Clamp_S32_opaque_D32_nofilter_DX_shaderproc; 610 fShaderProc32 = Clamp_S32_opaque_D32_nofilter_DX_shaderproc;
609 } 611 }
610 612
611 if (NULL == fShaderProc32) { 613 if (NULL == fShaderProc32) {
612 fShaderProc32 = this->chooseShaderProc32(); 614 fShaderProc32 = this->chooseShaderProc32();
613 } 615 }
614 } 616 }
615 617
616 // see if our platform has any accelerated overrides 618 // see if our platform has any accelerated overrides
617 this->platformProcs(); 619 this->platformProcs();
618 620
619 return true; 621 return true;
620 } 622 }
621 623
622 static void Clamp_S32_D32_nofilter_trans_shaderproc(const SkBitmapProcState& s, 624 static void Clamp_S32_D32_nofilter_trans_shaderproc(const SkBitmapProcState& s,
623 int x, int y, 625 int x, int y,
624 SkPMColor* SK_RESTRICT color s, 626 SkPMColor* SK_RESTRICT color s,
625 int count) { 627 int count) {
626 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0); 628 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0);
627 SkASSERT(s.fInvKy == 0); 629 SkASSERT(s.fInvKy == 0);
628 SkASSERT(count > 0 && colors != NULL); 630 SkASSERT(count > 0 && colors != NULL);
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 fx += dx; 1086 fx += dx;
1085 } 1087 }
1086 } else { 1088 } else {
1087 for (int i = 0; i < count; ++i) { 1089 for (int i = 0; i < count; ++i) {
1088 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; 1090 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)];
1089 fx += dx; 1091 fx += dx;
1090 } 1092 }
1091 } 1093 }
1092 } 1094 }
1093 1095
OLDNEW
« src/core/SkBitmapProcState.h ('K') | « src/core/SkBitmapProcState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698