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

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

Issue 1656833002: Sampler bias for all nofilter flavors (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « no previous file | src/core/SkBitmapProcState_matrixProcs.cpp » ('j') | 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 "SkBitmapController.h" 9 #include "SkBitmapController.h"
10 #include "SkBitmapProcState.h" 10 #include "SkBitmapProcState.h"
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 485
486 mproc(s, xy, 1, x, y); 486 mproc(s, xy, 1, x, y);
487 487
488 iY0 = xy[0] >> 18; 488 iY0 = xy[0] >> 18;
489 iY1 = xy[0] & 0x3FFF; 489 iY1 = xy[0] & 0x3FFF;
490 iSubY = (xy[0] >> 14) & 0xF; 490 iSubY = (xy[0] >> 14) & 0xF;
491 } else { 491 } else {
492 int yTemp; 492 int yTemp;
493 493
494 if (s.fInvType > SkMatrix::kTranslate_Mask) { 494 if (s.fInvType > SkMatrix::kTranslate_Mask) {
495 // TODO(fmalita): looks like another SkBitmapProcStateAutoMapper cus tomer 495 const SkBitmapProcStateAutoMapper mapper(s, x, y);
496 SkPoint pt; 496
497 s.fInvProc(s.fInvMatrix,
498 SkIntToScalar(x) + SK_ScalarHalf,
499 SkIntToScalar(y) + SK_ScalarHalf,
500 &pt);
501 // When the matrix has a scale component the setup code in 497 // When the matrix has a scale component the setup code in
502 // chooseProcs multiples the inverse matrix by the inverse of the 498 // chooseProcs multiples the inverse matrix by the inverse of the
503 // bitmap's width and height. Since this method is going to do 499 // bitmap's width and height. Since this method is going to do
504 // its own tiling and sampling we need to undo that here. 500 // its own tiling and sampling we need to undo that here.
505 if (SkShader::kClamp_TileMode != s.fTileModeX || 501 if (SkShader::kClamp_TileMode != s.fTileModeX ||
506 SkShader::kClamp_TileMode != s.fTileModeY) { 502 SkShader::kClamp_TileMode != s.fTileModeY) {
507 yTemp = SkScalarFloorToInt(pt.fY * s.fPixmap.height()); 503 yTemp = SkFractionalIntToInt(mapper.y() * s.fPixmap.height());
508 } else { 504 } else {
509 yTemp = SkScalarFloorToInt(pt.fY); 505 yTemp = SkFractionalIntToInt(mapper.y());
510 } 506 }
511 } else { 507 } else {
512 yTemp = s.fFilterOneY + y; 508 yTemp = s.fFilterOneY + y;
513 } 509 }
514 510
515 const int stopY = s.fPixmap.height(); 511 const int stopY = s.fPixmap.height();
516 switch (s.fTileModeY) { 512 switch (s.fTileModeY) {
517 case SkShader::kClamp_TileMode: 513 case SkShader::kClamp_TileMode:
518 iY0 = SkClampMax(yTemp, stopY-1); 514 iY0 = SkClampMax(yTemp, stopY-1);
519 break; 515 break;
520 case SkShader::kRepeat_TileMode: 516 case SkShader::kRepeat_TileMode:
521 iY0 = sk_int_mod(yTemp, stopY); 517 iY0 = sk_int_mod(yTemp, stopY);
522 break; 518 break;
523 case SkShader::kMirror_TileMode: 519 case SkShader::kMirror_TileMode:
524 default: 520 default:
525 iY0 = sk_int_mirror(yTemp, stopY); 521 iY0 = sk_int_mirror(yTemp, stopY);
526 break; 522 break;
527 } 523 }
528 524
529 #ifdef SK_DEBUG 525 #ifdef SK_DEBUG
530 { 526 {
527 const SkBitmapProcStateAutoMapper mapper(s, x, y);
531 int iY2; 528 int iY2;
532 if (s.fInvType > SkMatrix::kTranslate_Mask) { 529
533 SkPoint pt; 530 if (s.fInvType > SkMatrix::kTranslate_Mask &&
534 s.fInvProc(s.fInvMatrix, 531 (SkShader::kClamp_TileMode != s.fTileModeX ||
535 SkIntToScalar(x) + SK_ScalarHalf, 532 SkShader::kClamp_TileMode != s.fTileModeY)) {
536 SkIntToScalar(y) + SK_ScalarHalf, 533 iY2 = SkFractionalIntToInt(mapper.y() * s.fPixmap.height());
537 &pt);
538 if (SkShader::kClamp_TileMode != s.fTileModeX ||
539 SkShader::kClamp_TileMode != s.fTileModeY) {
540 pt.fY *= s.fPixmap.height();
541 }
542 iY2 = SkScalarFloorToInt(pt.fY);
543 } else { 534 } else {
544 const SkBitmapProcStateAutoMapper mapper(s, x, y);
545 iY2 = SkFractionalIntToInt(mapper.y()); 535 iY2 = SkFractionalIntToInt(mapper.y());
546 } 536 }
547 537
548 switch (s.fTileModeY) { 538 switch (s.fTileModeY) {
549 case SkShader::kClamp_TileMode: 539 case SkShader::kClamp_TileMode:
550 iY2 = SkClampMax(iY2, stopY-1); 540 iY2 = SkClampMax(iY2, stopY-1);
551 break; 541 break;
552 case SkShader::kRepeat_TileMode: 542 case SkShader::kRepeat_TileMode:
553 iY2 = sk_int_mod(iY2, stopY); 543 iY2 = sk_int_mod(iY2, stopY);
554 break; 544 break;
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 fx += dx; 822 fx += dx;
833 } 823 }
834 } else { 824 } else {
835 for (int i = 0; i < count; ++i) { 825 for (int i = 0; i < count; ++i) {
836 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; 826 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)];
837 fx += dx; 827 fx += dx;
838 } 828 }
839 } 829 }
840 } 830 }
841 831
OLDNEW
« no previous file with comments | « no previous file | src/core/SkBitmapProcState_matrixProcs.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698