cairo_private cairo_status_t _cairo_traps_path (const cairo_traps_t *traps, cairo_path_fixed_t *path) { int i; for (i = 0; i < traps->num_traps; i++) { cairo_status_t status; cairo_trapezoid_t trap = traps->traps[i]; if (trap.top == trap.bottom) continue; _sanitize_trap (&trap); status = _cairo_path_fixed_move_to (path, trap.left.p1.x, trap.top); if (unlikely (status)) return status; status = _cairo_path_fixed_line_to (path, trap.right.p1.x, trap.top); if (unlikely (status)) return status; status = _cairo_path_fixed_line_to (path, trap.right.p2.x, trap.bottom); if (unlikely (status)) return status; status = _cairo_path_fixed_line_to (path, trap.left.p2.x, trap.bottom); if (unlikely (status)) return status; status = _cairo_path_fixed_close_path (path); if (unlikely (status)) return status; } return CAIRO_STATUS_SUCCESS; }
static cairo_status_t _cairo_path_fixed_add_box (cairo_path_fixed_t *path, const cairo_box_t *box, cairo_fixed_t fx, cairo_fixed_t fy) { cairo_status_t status; status = _cairo_path_fixed_move_to (path, box->p1.x + fx, box->p1.y + fy); if (unlikely (status)) return status; status = _cairo_path_fixed_line_to (path, box->p2.x + fx, box->p1.y + fy); if (unlikely (status)) return status; status = _cairo_path_fixed_line_to (path, box->p2.x + fx, box->p2.y + fy); if (unlikely (status)) return status; status = _cairo_path_fixed_line_to (path, box->p1.x + fx, box->p2.y + fy); if (unlikely (status)) return status; return _cairo_path_fixed_close_path (path); }
static cairo_status_t _append_line_to (void *closure, cairo_point_t *point) { cairo_path_fixed_t *path = (cairo_path_fixed_t *) closure; return _cairo_path_fixed_line_to (path, point->x, point->y); }
IFACEMETHODIMP_(void) EndFigure( D2D1_FIGURE_END figureEnd) { if (figureEnd == D2D1_FIGURE_END_CLOSED) { cairo_status_t status = _cairo_path_fixed_line_to(mCairoPath, GetFixedX(mStartPoint), GetFixedY(mStartPoint)); } }
static cairo_status_t _scaled_glyph_path_line_to (void *abstract_closure, cairo_point_t *point) { cairo_scaled_glyph_path_closure_t *closure = abstract_closure; return _cairo_path_fixed_line_to (closure->path, point->x + closure->offset.x, point->y + closure->offset.y); }
IFACEMETHODIMP_(void) AddLines( const D2D1_POINT_2F *points, UINT pointsCount) { for (unsigned int i = 0; i < pointsCount; i++) { cairo_status_t status = _cairo_path_fixed_line_to(mCairoPath, GetFixedX(points[i]), GetFixedY(points[i])); } }
static cairo_status_t _cairo_default_context_arc (void *abstract_cr, double xc, double yc, double radius, double angle1, double angle2, cairo_bool_t forward) { cairo_default_context_t *cr = abstract_cr; cairo_status_t status; /* Do nothing, successfully, if radius is <= 0 */ if (radius <= 0.0) { cairo_fixed_t x_fixed, y_fixed; _cairo_gstate_user_to_backend (cr->gstate, &xc, &yc); x_fixed = _cairo_fixed_from_double (xc); y_fixed = _cairo_fixed_from_double (yc); status = _cairo_path_fixed_line_to (cr->path, x_fixed, y_fixed); if (unlikely (status)) return status; status = _cairo_path_fixed_line_to (cr->path, x_fixed, y_fixed); if (unlikely (status)) return status; return CAIRO_STATUS_SUCCESS; } status = _cairo_default_context_line_to (cr, xc + radius * cos (angle1), yc + radius * sin (angle1)); if (unlikely (status)) return status; if (forward) _cairo_arc_path (&cr->base, xc, yc, radius, angle1, angle2); else _cairo_arc_path_negative (&cr->base, xc, yc, radius, angle1, angle2); return CAIRO_STATUS_SUCCESS; /* any error will have already been set on cr */ }
static cairo_status_t _cairo_default_context_line_to (void *abstract_cr, double x, double y) { cairo_default_context_t *cr = abstract_cr; cairo_fixed_t x_fixed, y_fixed; _cairo_gstate_user_to_backend (cr->gstate, &x, &y); x_fixed = _cairo_fixed_from_double (x); y_fixed = _cairo_fixed_from_double (y); return _cairo_path_fixed_line_to (cr->path, x_fixed, y_fixed); }
static void _cairo_quartz_path_apply_func (void *info, const CGPathElement *el) { cairo_path_fixed_t *path = (cairo_path_fixed_t *) info; cairo_status_t status; switch (el->type) { case kCGPathElementMoveToPoint: status = _cairo_path_fixed_move_to (path, _cairo_fixed_from_double(el->points[0].x), _cairo_fixed_from_double(el->points[0].y)); assert(!status); break; case kCGPathElementAddLineToPoint: status = _cairo_path_fixed_line_to (path, _cairo_fixed_from_double(el->points[0].x), _cairo_fixed_from_double(el->points[0].y)); assert(!status); break; case kCGPathElementAddQuadCurveToPoint: { cairo_fixed_t fx, fy; double x, y; if (!_cairo_path_fixed_get_current_point (path, &fx, &fy)) fx = fy = 0; x = _cairo_fixed_to_double (fx); y = _cairo_fixed_to_double (fy); status = _cairo_path_fixed_curve_to (path, _cairo_fixed_from_double((x + el->points[0].x * 2.0) / 3.0), _cairo_fixed_from_double((y + el->points[0].y * 2.0) / 3.0), _cairo_fixed_from_double((el->points[0].x * 2.0 + el->points[1].x) / 3.0), _cairo_fixed_from_double((el->points[0].y * 2.0 + el->points[1].y) / 3.0), _cairo_fixed_from_double(el->points[1].x), _cairo_fixed_from_double(el->points[1].y)); } assert(!status); break; case kCGPathElementAddCurveToPoint: status = _cairo_path_fixed_curve_to (path, _cairo_fixed_from_double(el->points[0].x), _cairo_fixed_from_double(el->points[0].y), _cairo_fixed_from_double(el->points[1].x), _cairo_fixed_from_double(el->points[1].y), _cairo_fixed_from_double(el->points[2].x), _cairo_fixed_from_double(el->points[2].y)); assert(!status); break; case kCGPathElementCloseSubpath: status = _cairo_path_fixed_close_path (path); assert(!status); break; } }
cairo_status_t _cairo_path_fixed_rel_line_to (cairo_path_fixed_t *path, cairo_fixed_t dx, cairo_fixed_t dy) { cairo_fixed_t x, y; if (! path->has_current_point) return _cairo_error (CAIRO_STATUS_NO_CURRENT_POINT); x = path->current_point.x + dx; y = path->current_point.y + dy; return _cairo_path_fixed_line_to (path, x, y); }
static OSStatus MyATSCubicLineToCallback(const Float32Point * pt, void *callBackDataPtr) { cairo_ATSUI_glyph_path_callback_info_t *info = callBackDataPtr; double scaledPt[2]; cairo_fixed_t x, y; scaledPt[0] = pt->x; scaledPt[1] = pt->y; cairo_matrix_transform_point(&info->scale, &scaledPt[0], &scaledPt[1]); x = _cairo_fixed_from_double(scaledPt[0]); y = _cairo_fixed_from_double(scaledPt[1]); _cairo_path_fixed_line_to(info->path, x, y); return noErr; }
/** * _cairo_path_append_to_context: * @path: the path data to be appended * @cr: a cairo context * * Append @path to the current path within @cr. * * Return value: %CAIRO_STATUS_INVALID_PATH_DATA if the data in @path * is invalid, and %CAIRO_STATUS_SUCCESS otherwise. **/ cairo_status_t _cairo_path_append_to_context (const cairo_path_t *path, cairo_t *cr) { const cairo_path_data_t *p, *end; cairo_fixed_t x1_fixed, y1_fixed; cairo_fixed_t x2_fixed, y2_fixed; cairo_fixed_t x3_fixed, y3_fixed; cairo_matrix_t user_to_backend; cairo_status_t status; double x, y; user_to_backend = cr->gstate->ctm; cairo_matrix_multiply (&user_to_backend, &user_to_backend, &cr->gstate->target->device_transform); end = &path->data[path->num_data]; for (p = &path->data[0]; p < end; p += p->header.length) { switch (p->header.type) { case CAIRO_PATH_MOVE_TO: if (unlikely (p->header.length < 2)) return _cairo_error (CAIRO_STATUS_INVALID_PATH_DATA); x = p[1].point.x, y = p[1].point.y; cairo_matrix_transform_point (&user_to_backend, &x, &y); x1_fixed = _cairo_fixed_from_double (x); y1_fixed = _cairo_fixed_from_double (y); status = _cairo_path_fixed_move_to (cr->path, x1_fixed, y1_fixed); break; case CAIRO_PATH_LINE_TO: if (unlikely (p->header.length < 2)) return _cairo_error (CAIRO_STATUS_INVALID_PATH_DATA); x = p[1].point.x, y = p[1].point.y; cairo_matrix_transform_point (&user_to_backend, &x, &y); x1_fixed = _cairo_fixed_from_double (x); y1_fixed = _cairo_fixed_from_double (y); status = _cairo_path_fixed_line_to (cr->path, x1_fixed, y1_fixed); break; case CAIRO_PATH_CURVE_TO: if (unlikely (p->header.length < 4)) return _cairo_error (CAIRO_STATUS_INVALID_PATH_DATA); x = p[1].point.x, y = p[1].point.y; cairo_matrix_transform_point (&user_to_backend, &x, &y); x1_fixed = _cairo_fixed_from_double (x); y1_fixed = _cairo_fixed_from_double (y); x = p[2].point.x, y = p[2].point.y; cairo_matrix_transform_point (&user_to_backend, &x, &y); x2_fixed = _cairo_fixed_from_double (x); y2_fixed = _cairo_fixed_from_double (y); x = p[3].point.x, y = p[3].point.y; cairo_matrix_transform_point (&user_to_backend, &x, &y); x3_fixed = _cairo_fixed_from_double (x); y3_fixed = _cairo_fixed_from_double (y); status = _cairo_path_fixed_curve_to (cr->path, x1_fixed, y1_fixed, x2_fixed, y2_fixed, x3_fixed, y3_fixed); break; case CAIRO_PATH_CLOSE_PATH: if (unlikely (p->header.length < 1)) return _cairo_error (CAIRO_STATUS_INVALID_PATH_DATA); status = _cairo_path_fixed_close_path (cr->path); break; default: return _cairo_error (CAIRO_STATUS_INVALID_PATH_DATA); } if (unlikely (status)) return status; } return CAIRO_STATUS_SUCCESS; }