/* Does the given edge contain the given point. The point must already * be known to be contained within the line determined by the edge, * (most likely the point results from an intersection of this edge * with another). * * If we had exact arithmetic, then this function would simply be a * matter of examining whether the y value of the point lies within * the range of y values of the edge. But since intersection points * are not exact due to being rounded to the nearest integer within * the available precision, we must also examine the x value of the * point. * * The definition of "contains" here is that the given intersection * point will be seen by the sweep line after the start event for the * given edge and before the stop event for the edge. See the comments * in the implementation for more details. */ static cairo_bool_t _cairo_bo_edge_contains_intersect_point (cairo_bo_edge_t *edge, cairo_bo_intersect_point_t *point) { int cmp_top, cmp_bottom; /* XXX: When running the actual algorithm, we don't actually need to * compare against edge->top at all here, since any intersection above * top is eliminated early via a slope comparison. We're leaving these * here for now only for the sake of the quadratic-time intersection * finder which needs them. */ cmp_top = _cairo_bo_intersect_ordinate_32_compare (point->y, edge->edge.top); cmp_bottom = _cairo_bo_intersect_ordinate_32_compare (point->y, edge->edge.bottom); if (cmp_top < 0 || cmp_bottom > 0) { return FALSE; } if (cmp_top > 0 && cmp_bottom < 0) { return TRUE; } /* At this stage, the point lies on the same y value as either * edge->top or edge->bottom, so we have to examine the x value in * order to properly determine containment. */ /* If the y value of the point is the same as the y value of the * top of the edge, then the x value of the point must be greater * to be considered as inside the edge. Similarly, if the y value * of the point is the same as the y value of the bottom of the * edge, then the x value of the point must be less to be * considered as inside. */ if (cmp_top == 0) { cairo_fixed_t top_x; top_x = _line_compute_intersection_x_for_y (&edge->edge.line, edge->edge.top); return _cairo_bo_intersect_ordinate_32_compare (point->x, top_x) > 0; } else { /* cmp_bottom == 0 */ cairo_fixed_t bot_x; bot_x = _line_compute_intersection_x_for_y (&edge->edge.line, edge->edge.bottom); return _cairo_bo_intersect_ordinate_32_compare (point->x, bot_x) < 0; } }
/* Does the given edge contain the given point. The point must already * be known to be contained within the line determined by the edge, * (most likely the point results from an intersection of this edge * with another). * * If we had exact arithmetic, then this function would simply be a * matter of examining whether the y value of the point lies within * the range of y values of the edge. But since intersection points * are not exact due to being rounded to the nearest integer within * the available precision, we must also examine the x value of the * point. * * The definition of "contains" here is that the given intersection * point will be seen by the sweep line after the start event for the * given edge and before the stop event for the edge. See the comments * in the implementation for more details. */ static cairo_bool_t _cairo_bo_edge_contains_intersect_point (cairo_bo_edge_t *edge, cairo_bo_intersect_point_t *point) { return _cairo_bo_intersect_ordinate_32_compare (point->y, edge->edge.bottom) < 0; }