static cairo_status_t _cairo_clip_intersect_rectangle (cairo_clip_t *clip, const cairo_rectangle_int_t *rect) { cairo_clip_path_t *clip_path; cairo_status_t status; if (clip->path != NULL) { if (rect->x <= clip->path->extents.x && rect->y <= clip->path->extents.y && rect->x + rect->width >= clip->path->extents.x + clip->path->extents.width && rect->y + rect->height >= clip->path->extents.y + clip->path->extents.height) { return CAIRO_STATUS_SUCCESS; } } clip_path = _cairo_clip_path_create (clip); if (unlikely (clip_path == NULL)) return _cairo_error (CAIRO_STATUS_NO_MEMORY); _cairo_path_fixed_init (&clip_path->path); status = _cairo_path_fixed_move_to (&clip_path->path, _cairo_fixed_from_int (rect->x), _cairo_fixed_from_int (rect->y)); assert (status == CAIRO_STATUS_SUCCESS); status = _cairo_path_fixed_rel_line_to (&clip_path->path, _cairo_fixed_from_int (rect->width), _cairo_fixed_from_int (0)); assert (status == CAIRO_STATUS_SUCCESS); status = _cairo_path_fixed_rel_line_to (&clip_path->path, _cairo_fixed_from_int (0), _cairo_fixed_from_int (rect->height)); assert (status == CAIRO_STATUS_SUCCESS); status = _cairo_path_fixed_rel_line_to (&clip_path->path, _cairo_fixed_from_int (-rect->width), _cairo_fixed_from_int (0)); assert (status == CAIRO_STATUS_SUCCESS); status = _cairo_path_fixed_close_path (&clip_path->path); assert (status == CAIRO_STATUS_SUCCESS); clip_path->extents = *rect; clip_path->fill_rule = CAIRO_FILL_RULE_WINDING; clip_path->tolerance = 1; clip_path->antialias = CAIRO_ANTIALIAS_NONE; clip_path->flags |= CAIRO_CLIP_PATH_IS_BOX; /* could preallocate the region if it proves worthwhile */ return CAIRO_STATUS_SUCCESS; }
static cairo_status_t _cairo_default_context_rel_line_to (void *abstract_cr, double dx, double dy) { cairo_default_context_t *cr = abstract_cr; cairo_fixed_t dx_fixed, dy_fixed; _cairo_gstate_user_to_backend_distance (cr->gstate, &dx, &dy); dx_fixed = _cairo_fixed_from_double (dx); dy_fixed = _cairo_fixed_from_double (dy); return _cairo_path_fixed_rel_line_to (cr->path, dx_fixed, dy_fixed); }