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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkRect.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkScalar.h
diff --git a/include/core/SkScalar.h b/include/core/SkScalar.h
index 4efa8417afd4a9edc903c19412a68ac3b997d7af..26352d1194191b4c7aace5faea9ef36d6731a01d 100644
--- a/include/core/SkScalar.h
+++ b/include/core/SkScalar.h
@@ -168,6 +168,18 @@ static inline int SkDScalarRoundToInt(SkScalar x) {
return (int)floor(xx);
}
+/**
+ * Variant of SkScalarRoundToInt, identical to SkDScalarRoundToInt except when the input fraction
+ * is 0.5. In this case only, round the value down. This is used to round the top and left
+ * of a rectangle, and corresponds to the way the scan converter treats the top and left edges.
+ */
+static inline int SkDScalarRoundDownToInt(SkScalar x) {
+ double xx = x;
+ xx += 0.5;
+ double floorXX = floor(xx);
+ return (int)floorXX - (xx == floorXX);
+}
+
static inline SkScalar SkScalarClampMax(SkScalar x, SkScalar max) {
x = SkTMin(x, max);
x = SkTMax<SkScalar>(x, 0);
« 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