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

Side by Side Diff: include/core/SkScalar.h

Issue 1548643002: revised strokerect gm (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: handle halfway case in scan converter 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 | « include/core/SkRect.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 2006 The Android Open Source Project 2 * Copyright 2006 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 SkScalar_DEFINED 8 #ifndef SkScalar_DEFINED
9 #define SkScalar_DEFINED 9 #define SkScalar_DEFINED
10 10
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 * SkASSERT(0 == ix); // <--- fails 161 * SkASSERT(0 == ix); // <--- fails
162 * ix = SkDScalarRoundToInt(x); 162 * ix = SkDScalarRoundToInt(x);
163 * SkASSERT(0 == ix); // <--- succeeds 163 * SkASSERT(0 == ix); // <--- succeeds
164 */ 164 */
165 static inline int SkDScalarRoundToInt(SkScalar x) { 165 static inline int SkDScalarRoundToInt(SkScalar x) {
166 double xx = x; 166 double xx = x;
167 xx += 0.5; 167 xx += 0.5;
168 return (int)floor(xx); 168 return (int)floor(xx);
169 } 169 }
170 170
171 /**
172 * Variant of SkScalarRoundToInt, identical to SkDScalarRoundToInt except when the input fraction
173 * is 0.5. In this case only, round the value down. This is used to round the t op and left
174 * of a rectangle, and corresponds to the way the scan converter treats the top and left edges.
175 */
176 static inline int SkDScalarRoundDownToInt(SkScalar x) {
177 double xx = x;
178 xx += 0.5;
179 double floorXX = floor(xx);
180 return (int)floorXX - (xx == floorXX);
181 }
182
171 static inline SkScalar SkScalarClampMax(SkScalar x, SkScalar max) { 183 static inline SkScalar SkScalarClampMax(SkScalar x, SkScalar max) {
172 x = SkTMin(x, max); 184 x = SkTMin(x, max);
173 x = SkTMax<SkScalar>(x, 0); 185 x = SkTMax<SkScalar>(x, 0);
174 return x; 186 return x;
175 } 187 }
176 188
177 static inline SkScalar SkScalarPin(SkScalar x, SkScalar min, SkScalar max) { 189 static inline SkScalar SkScalarPin(SkScalar x, SkScalar min, SkScalar max) {
178 return SkTPin(x, min, max); 190 return SkTPin(x, min, max);
179 } 191 }
180 192
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 SkASSERT(n >= 0); 272 SkASSERT(n >= 0);
261 for (int i = 0; i < n; ++i) { 273 for (int i = 0; i < n; ++i) {
262 if (a[i] != b[i]) { 274 if (a[i] != b[i]) {
263 return false; 275 return false;
264 } 276 }
265 } 277 }
266 return true; 278 return true;
267 } 279 }
268 280
269 #endif 281 #endif
OLDNEW
« no previous file with comments | « include/core/SkRect.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698