From 2e086190e55a01dc2f7b74df6f2828e8cac2b9ab Mon Sep 17 00:00:00 2001 From: "kbr@chromium.org" Date: Wed, 7 Jul 2010 22:20:35 +0000 Subject: Added optional "ambiguous" outgoing argument to XRay queries so that calling code may choose different y-coordinates for better robustness. Tested and verified manually inside O3D. BUG=none TEST=none Review URL: http://codereview.appspot.com/1695051 git-svn-id: http://skia.googlecode.com/svn/trunk@586 2bbb7eff-a529-9590-31e7-b0007b416f81 --- include/core/SkGeometry.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/core/SkGeometry.h b/include/core/SkGeometry.h index b8ab74caef..a20978326d 100644 --- a/include/core/SkGeometry.h +++ b/include/core/SkGeometry.h @@ -26,10 +26,13 @@ */ typedef SkPoint SkXRay; -/** Given a line segment from pts[0] to pts[1], and ax xray, return true if - they intersect. +/** Given a line segment from pts[0] to pts[1], and an xray, return true if + they intersect. Optional outgoing "ambiguous" argument indicates + whether the answer is ambiguous because the query occurred exactly at + one of the endpoints' y coordinates, indicating that another query y + coordinate is preferred for robustness. */ -bool SkXRayCrossesLine(const SkXRay& pt, const SkPoint pts[2]); +bool SkXRayCrossesLine(const SkXRay& pt, const SkPoint pts[2], bool* ambiguous = NULL); /** Given a quadratic equation Ax^2 + Bx + C = 0, return 0, 1, 2 roots for the equation. @@ -155,8 +158,12 @@ int SkChopCubicAtMaxCurvature(const SkPoint src[4], SkPoint dst[13], SkScalar tV left of the curve, the line is not considered to cross the curve, but if it is equal to cubic[3].fY then it is considered to cross. + Optional outgoing "ambiguous" argument indicates whether the answer is + ambiguous because the query occurred exactly at one of the endpoints' y + coordinates, indicating that another query y coordinate is preferred + for robustness. */ -bool SkXRayCrossesMonotonicCubic(const SkXRay& pt, const SkPoint cubic[4]); +bool SkXRayCrossesMonotonicCubic(const SkXRay& pt, const SkPoint cubic[4], bool* ambiguous = NULL); /** Given an arbitrary cubic bezier, return the number of times an xray crosses the cubic. Valid return values are [0..3] @@ -165,8 +172,12 @@ bool SkXRayCrossesMonotonicCubic(const SkXRay& pt, const SkPoint cubic[4]); left of the curve, the line is not considered to cross the curve, but if it is equal to cubic[3].fY then it is considered to cross. + Optional outgoing "ambiguous" argument indicates whether the answer is + ambiguous because the query occurred exactly at one of the endpoints' y + coordinates or at a tangent point, indicating that another query y + coordinate is preferred for robustness. */ -int SkNumXRayCrossingsForCubic(const SkXRay& pt, const SkPoint cubic[4]); +int SkNumXRayCrossingsForCubic(const SkXRay& pt, const SkPoint cubic[4], bool* ambiguous = NULL); /////////////////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3