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

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

Issue 1642273002: Add sampler bias for the nofilter/translate specializations (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: comment 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.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 2007 The Android Open Source Project 2 * Copyright 2007 The Android Open Source Project
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 #ifndef SkBitmapProcState_DEFINED 8 #ifndef SkBitmapProcState_DEFINED
9 #define SkBitmapProcState_DEFINED 9 #define SkBitmapProcState_DEFINED
10 10
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 SkIntToScalar(y) + SK_ScalarHalf, &pt); 199 SkIntToScalar(y) + SK_ScalarHalf, &pt);
200 200
201 // SkFixed epsilon bias to ensure inverse-mapped bitmap coordinates are rounded 201 // SkFixed epsilon bias to ensure inverse-mapped bitmap coordinates are rounded
202 // consistently WRT geometry. Note that we only need the bias for posit ive scales: 202 // consistently WRT geometry. Note that we only need the bias for posit ive scales:
203 // for negative scales, the rounding is intrinsically correct. 203 // for negative scales, the rounding is intrinsically correct.
204 // We scale it to persist SkFractionalInt -> SkFixed conversions. 204 // We scale it to persist SkFractionalInt -> SkFixed conversions.
205 const SkFixed biasX = (s.fInvMatrix.getScaleX() > 0); 205 const SkFixed biasX = (s.fInvMatrix.getScaleX() > 0);
206 const SkFixed biasY = (s.fInvMatrix.getScaleY() > 0); 206 const SkFixed biasY = (s.fInvMatrix.getScaleY() > 0);
207 fX = SkScalarToFractionalInt(pt.x()) - SkFixedToFractionalInt(biasX); 207 fX = SkScalarToFractionalInt(pt.x()) - SkFixedToFractionalInt(biasX);
208 fY = SkScalarToFractionalInt(pt.y()) - SkFixedToFractionalInt(biasY); 208 fY = SkScalarToFractionalInt(pt.y()) - SkFixedToFractionalInt(biasY);
209
210 /*
211 * (see SkBitmapProcState::setupForTranslate, which is the only user of this flag)
212 *
213 * if the translate is larger than our ints, we can get random results, or
214 * worse, we might get 0x80000000, which wreaks havoc on us, since we c an't
215 * negate it.
216 */
217 const SkScalar too_big = SkIntToScalar(1 << 30);
218 fOverflow = SkScalarAbs(pt.x() - SkFixedToScalar(biasX)) > too_big
219 || SkScalarAbs(pt.y() - SkFixedToScalar(biasY)) > too_big;
209 } 220 }
210 221
211 SkFractionalInt x() const { return fX; } 222 SkFractionalInt x() const { return fX; }
212 SkFractionalInt y() const { return fY; } 223 SkFractionalInt y() const { return fY; }
213 224
225 bool isOverflow() const { return fOverflow; }
226
214 private: 227 private:
215 SkFractionalInt fX, fY; 228 SkFractionalInt fX, fY;
229 bool fOverflow;
216 }; 230 };
217 231
218 #endif 232 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkBitmapProcState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698