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

Side by Side Diff: src/core/SkBitmapProcState_matrix.h

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.cpp ('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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkMath.h" 9 #include "SkMath.h"
10 #include "SkMathPriv.h" 10 #include "SkMathPriv.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 const unsigned maxX = s.fPixmap.width() - 1; 58 const unsigned maxX = s.fPixmap.width() - 1;
59 const SkFixed one = s.fFilterOneX; 59 const SkFixed one = s.fFilterOneX;
60 const SkFractionalInt dx = s.fInvSxFractionalInt; 60 const SkFractionalInt dx = s.fInvSxFractionalInt;
61 SkFractionalInt fx; 61 SkFractionalInt fx;
62 62
63 { 63 {
64 SkPoint pt; 64 SkPoint pt;
65 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, 65 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
66 SkIntToScalar(y) + SK_ScalarHalf, &pt); 66 SkIntToScalar(y) + SK_ScalarHalf, &pt);
67 const SkFixed fy = SkScalarToFixed(pt.fY) - (s.fFilterOneY >> 1); 67 const SkFixed fy = SkScalarToFixed(pt.fY) - (s.fFilterOneY >> 1)
68 + bitmap_sampler_inv_bias(s.fInvMatrix.getScaleY());
68 const unsigned maxY = s.fPixmap.height() - 1; 69 const unsigned maxY = s.fPixmap.height() - 1;
69 // compute our two Y values up front 70 // compute our two Y values up front
70 *xy++ = PACK_FILTER_Y_NAME(fy, maxY, s.fFilterOneY PREAMBLE_ARG_Y); 71 *xy++ = PACK_FILTER_Y_NAME(fy, maxY, s.fFilterOneY PREAMBLE_ARG_Y);
71 // now initialize fx 72 // now initialize fx
72 fx = SkScalarToFractionalInt(pt.fX) - (SkFixedToFractionalInt(one) >> 1) ; 73 fx = SkScalarToFractionalInt(pt.fX) - (SkFixedToFractionalInt(one) >> 1)
74 + bitmap_sampler_inv_bias(s.fInvMatrix.getScaleX());
73 } 75 }
74 76
75 #ifdef CHECK_FOR_DECAL 77 #ifdef CHECK_FOR_DECAL
76 if (can_truncate_to_fixed_for_decal(fx, dx, count, maxX)) { 78 if (can_truncate_to_fixed_for_decal(fx, dx, count, maxX)) {
77 decal_filter_scale(xy, SkFractionalIntToFixed(fx), 79 decal_filter_scale(xy, SkFractionalIntToFixed(fx),
78 SkFractionalIntToFixed(dx), count); 80 SkFractionalIntToFixed(dx), count);
79 } else 81 } else
80 #endif 82 #endif
81 { 83 {
82 do { 84 do {
(...skipping 12 matching lines...) Expand all
95 SkMatrix::kAffine_Mask)) == 0); 97 SkMatrix::kAffine_Mask)) == 0);
96 98
97 PREAMBLE(s); 99 PREAMBLE(s);
98 SkPoint srcPt; 100 SkPoint srcPt;
99 s.fInvProc(s.fInvMatrix, 101 s.fInvProc(s.fInvMatrix,
100 SkIntToScalar(x) + SK_ScalarHalf, 102 SkIntToScalar(x) + SK_ScalarHalf,
101 SkIntToScalar(y) + SK_ScalarHalf, &srcPt); 103 SkIntToScalar(y) + SK_ScalarHalf, &srcPt);
102 104
103 SkFixed oneX = s.fFilterOneX; 105 SkFixed oneX = s.fFilterOneX;
104 SkFixed oneY = s.fFilterOneY; 106 SkFixed oneY = s.fFilterOneY;
105 SkFixed fx = SkScalarToFixed(srcPt.fX) - (oneX >> 1); 107 SkFixed fx = SkScalarToFixed(srcPt.fX) - (oneX >> 1)
106 SkFixed fy = SkScalarToFixed(srcPt.fY) - (oneY >> 1); 108 + bitmap_sampler_inv_bias(s.fInvMatrix.getScaleX());
109 SkFixed fy = SkScalarToFixed(srcPt.fY) - (oneY >> 1)
110 + bitmap_sampler_inv_bias(s.fInvMatrix.getScaleY());
107 SkFixed dx = s.fInvSx; 111 SkFixed dx = s.fInvSx;
108 SkFixed dy = s.fInvKy; 112 SkFixed dy = s.fInvKy;
109 unsigned maxX = s.fPixmap.width() - 1; 113 unsigned maxX = s.fPixmap.width() - 1;
110 unsigned maxY = s.fPixmap.height() - 1; 114 unsigned maxY = s.fPixmap.height() - 1;
111 115
112 do { 116 do {
113 *xy++ = PACK_FILTER_Y_NAME(fy, maxY, oneY PREAMBLE_ARG_Y); 117 *xy++ = PACK_FILTER_Y_NAME(fy, maxY, oneY PREAMBLE_ARG_Y);
114 fy += dy; 118 fy += dy;
115 *xy++ = PACK_FILTER_X_NAME(fx, maxX, oneX PREAMBLE_ARG_X); 119 *xy++ = PACK_FILTER_X_NAME(fx, maxX, oneX PREAMBLE_ARG_X);
116 fx += dx; 120 fx += dx;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 #undef PERSP_FILTER_NAME 160 #undef PERSP_FILTER_NAME
157 161
158 #undef PREAMBLE 162 #undef PREAMBLE
159 #undef PREAMBLE_PARAM_X 163 #undef PREAMBLE_PARAM_X
160 #undef PREAMBLE_PARAM_Y 164 #undef PREAMBLE_PARAM_Y
161 #undef PREAMBLE_ARG_X 165 #undef PREAMBLE_ARG_X
162 #undef PREAMBLE_ARG_Y 166 #undef PREAMBLE_ARG_Y
163 167
164 #undef TILEX_LOW_BITS 168 #undef TILEX_LOW_BITS
165 #undef TILEY_LOW_BITS 169 #undef TILEY_LOW_BITS
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcState.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698