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

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

Issue 1527633002: SkBitmapProcState rounding bias (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: simplified expr Created 5 years 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 | « src/core/SkBitmapProcState.h ('k') | src/core/SkBitmapProcState_matrix.h » ('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 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | 816 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask |
817 SkMatrix::kScale_Mask)) == 0); 817 SkMatrix::kScale_Mask)) == 0);
818 818
819 const unsigned maxX = s.fPixmap.width() - 1; 819 const unsigned maxX = s.fPixmap.width() - 1;
820 SkFractionalInt fx; 820 SkFractionalInt fx;
821 int dstY; 821 int dstY;
822 { 822 {
823 SkPoint pt; 823 SkPoint pt;
824 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, SkIntToScalar (y) + SK_ScalarHalf, 824 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, SkIntToScalar (y) + SK_ScalarHalf,
825 &pt); 825 &pt);
826 fx = SkScalarToFractionalInt(pt.fY); 826 fx = SkScalarToFractionalInt(pt.fY)
827 + bitmap_sampler_inv_bias(s.fInvMatrix.getScaleY());
827 const unsigned maxY = s.fPixmap.height() - 1; 828 const unsigned maxY = s.fPixmap.height() - 1;
828 dstY = SkClampMax(SkFractionalIntToInt(fx), maxY); 829 dstY = SkClampMax(SkFractionalIntToInt(fx), maxY);
829 fx = SkScalarToFractionalInt(pt.fX); 830 fx = SkScalarToFractionalInt(pt.fX)
831 + bitmap_sampler_inv_bias(s.fInvMatrix.getScaleX());
830 } 832 }
831 833
832 const SkPMColor* SK_RESTRICT src = s.fPixmap.addr32(0, dstY); 834 const SkPMColor* SK_RESTRICT src = s.fPixmap.addr32(0, dstY);
833 const SkFractionalInt dx = s.fInvSxFractionalInt; 835 const SkFractionalInt dx = s.fInvSxFractionalInt;
834 836
835 // Check if we're safely inside [0...maxX] so no need to clamp each computed index. 837 // Check if we're safely inside [0...maxX] so no need to clamp each computed index.
836 // 838 //
837 if ((uint64_t)SkFractionalIntToInt(fx) <= maxX && 839 if ((uint64_t)SkFractionalIntToInt(fx) <= maxX &&
838 (uint64_t)SkFractionalIntToInt(fx + dx * (count - 1)) <= maxX) 840 (uint64_t)SkFractionalIntToInt(fx + dx * (count - 1)) <= maxX)
839 { 841 {
(...skipping 16 matching lines...) Expand all
856 fx += dx; 858 fx += dx;
857 } 859 }
858 } else { 860 } else {
859 for (int i = 0; i < count; ++i) { 861 for (int i = 0; i < count; ++i) {
860 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; 862 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)];
861 fx += dx; 863 fx += dx;
862 } 864 }
863 } 865 }
864 } 866 }
865 867
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcState.h ('k') | src/core/SkBitmapProcState_matrix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698