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

Side by Side Diff: src/core/SkCubicClipper.cpp

Issue 1517883002: fix SkPath::contains() for points on edge, conics (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add comment 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/SkCubicClipper.h ('k') | src/core/SkPath.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 /* 2 /*
3 * Copyright 2009 The Android Open Source Project 3 * Copyright 2009 The Android Open Source Project
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 9
10 #include "SkCubicClipper.h" 10 #include "SkCubicClipper.h"
11 #include "SkGeometry.h" 11 #include "SkGeometry.h"
12 12
13 SkCubicClipper::SkCubicClipper() { 13 SkCubicClipper::SkCubicClipper() {
14 fClip.setEmpty(); 14 fClip.setEmpty();
15 } 15 }
16 16
17 void SkCubicClipper::setClip(const SkIRect& clip) { 17 void SkCubicClipper::setClip(const SkIRect& clip) {
18 // conver to scalars, since that's where we'll see the points 18 // conver to scalars, since that's where we'll see the points
19 fClip.set(clip); 19 fClip.set(clip);
20 } 20 }
21 21
22 22
23 static bool chopMonoCubicAtY(SkPoint pts[4], SkScalar y, SkScalar* t) { 23 bool SkCubicClipper::ChopMonoAtY(const SkPoint pts[4], SkScalar y, SkScalar* t) {
24 SkScalar ycrv[4]; 24 SkScalar ycrv[4];
25 ycrv[0] = pts[0].fY - y; 25 ycrv[0] = pts[0].fY - y;
26 ycrv[1] = pts[1].fY - y; 26 ycrv[1] = pts[1].fY - y;
27 ycrv[2] = pts[2].fY - y; 27 ycrv[2] = pts[2].fY - y;
28 ycrv[3] = pts[3].fY - y; 28 ycrv[3] = pts[3].fY - y;
29 29
30 #ifdef NEWTON_RAPHSON // Quadratic convergence, typically <= 3 iterations. 30 #ifdef NEWTON_RAPHSON // Quadratic convergence, typically <= 3 iterations.
31 // Initial guess. 31 // Initial guess.
32 // TODO(turk): Check for zero denominator? Shouldn't happen unless the curve 32 // TODO(turk): Check for zero denominator? Shouldn't happen unless the curve
33 // is not only monotonic but degenerate. 33 // is not only monotonic but degenerate.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 const SkScalar ctop = fClip.fTop; 124 const SkScalar ctop = fClip.fTop;
125 const SkScalar cbot = fClip.fBottom; 125 const SkScalar cbot = fClip.fBottom;
126 if (dst[3].fY <= ctop || dst[0].fY >= cbot) { 126 if (dst[3].fY <= ctop || dst[0].fY >= cbot) {
127 return false; 127 return false;
128 } 128 }
129 129
130 SkScalar t; 130 SkScalar t;
131 SkPoint tmp[7]; // for SkChopCubicAt 131 SkPoint tmp[7]; // for SkChopCubicAt
132 132
133 // are we partially above 133 // are we partially above
134 if (dst[0].fY < ctop && chopMonoCubicAtY(dst, ctop, &t)) { 134 if (dst[0].fY < ctop && ChopMonoAtY(dst, ctop, &t)) {
135 SkChopCubicAt(dst, tmp, t); 135 SkChopCubicAt(dst, tmp, t);
136 dst[0] = tmp[3]; 136 dst[0] = tmp[3];
137 dst[1] = tmp[4]; 137 dst[1] = tmp[4];
138 dst[2] = tmp[5]; 138 dst[2] = tmp[5];
139 } 139 }
140 140
141 // are we partially below 141 // are we partially below
142 if (dst[3].fY > cbot && chopMonoCubicAtY(dst, cbot, &t)) { 142 if (dst[3].fY > cbot && ChopMonoAtY(dst, cbot, &t)) {
143 SkChopCubicAt(dst, tmp, t); 143 SkChopCubicAt(dst, tmp, t);
144 dst[1] = tmp[1]; 144 dst[1] = tmp[1];
145 dst[2] = tmp[2]; 145 dst[2] = tmp[2];
146 dst[3] = tmp[3]; 146 dst[3] = tmp[3];
147 } 147 }
148 148
149 if (reverse) { 149 if (reverse) {
150 SkTSwap<SkPoint>(dst[0], dst[3]); 150 SkTSwap<SkPoint>(dst[0], dst[3]);
151 SkTSwap<SkPoint>(dst[1], dst[2]); 151 SkTSwap<SkPoint>(dst[1], dst[2]);
152 } 152 }
153 return true; 153 return true;
154 } 154 }
OLDNEW
« no previous file with comments | « src/core/SkCubicClipper.h ('k') | src/core/SkPath.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698