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

Side by Side Diff: experimental/Intersection/IntersectionUtilities.h

Issue 867213004: remove prototype pathops code (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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
OLDNEW
(Empty)
1 /*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 // inline utilities
9 /* Returns 0 if negative, 1 if zero, 2 if positive
10 */
11 inline int side(double x) {
12 return (x > 0) + (x >= 0);
13 }
14
15 /* Returns 1 if negative, 2 if zero, 4 if positive
16 */
17 inline int sideBit(double x) {
18 return 1 << side(x);
19 }
20
21 /* Given the set [0, 1, 2, 3], and two of the four members, compute an XOR mask
22 that computes the other two. Note that:
23
24 one ^ two == 3 for (0, 3), (1, 2)
25 one ^ two < 3 for (0, 1), (0, 2), (1, 3), (2, 3)
26 3 - (one ^ two) is either 0, 1, or 2
27 1 >> 3 - (one ^ two) is either 0 or 1
28 thus:
29 returned == 2 for (0, 3), (1, 2)
30 returned == 3 for (0, 1), (0, 2), (1, 3), (2, 3)
31 given that:
32 (0, 3) ^ 2 -> (2, 1) (1, 2) ^ 2 -> (3, 0)
33 (0, 1) ^ 3 -> (3, 2) (0, 2) ^ 3 -> (3, 1) (1, 3) ^ 3 -> (2, 0) (2, 3) ^ 3 -> (1, 0)
34 */
35 inline int other_two(int one, int two) {
36 return 1 >> 3 - (one ^ two) ^ 3;
37 }
38
39 /* Returns -1 if negative, 0 if zero, 1 if positive
40 */
41 inline int sign(double x) {
42 return (x > 0) - (x < 0);
43 }
44
45 inline double interp(double A, double B, double t) {
46 return A + (B - A) * t;
47 }
OLDNEW
« no previous file with comments | « experimental/Intersection/Inline_Tests.cpp ('k') | experimental/Intersection/IntersectionUtilities.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698