[cairo-commit] cairo/src cairo.c,1.32,1.33 cairo.h,1.44,1.45 cairo_gstate.c,1.41,1.42 cairoint.h,1.51,1.52
Carl Worth
commit at pdx.freedesktop.org
Mon Aug 15 11:12:59 PDT 2005
Committed by: cworth
Update of /cvs/cairo/cairo/src
In directory pdx:/tmp/cvs-serv7295/src
Modified Files:
cairo.c cairo.h cairo_gstate.c cairoint.h
Log Message:
* configure.in: Bump version to 0.1.18. Includes new functions
cairo_current_path, cairo_current_path_flat,
cairo_surface_get_filter. Support for XCB backend. Fixes for
building in cygwin. Adds cairo_surface_get_filter.
* src/cairo.h:
* src/cairo.c (cairo_current_path):
(cairo_current_path_flat): Add new path query functions.
* src/cairo_gstate.c (_gpi_move_to):
(_gpi_line_to):
(_gpi_curve_to):
(_gpi_close_path):
(_cairo_gstate_interpret_path): Implement support for
cairo_current_path and cairo_current_path_flat. These functions
just provide an interface to _cairo_path_interpret and take care
of mapping from device space back to user space.
Index: cairo.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** a/cairo.c 16 Dec 2003 15:20:20 -0000 1.32
--- b/cairo.c 18 Feb 2004 02:38:23 -0000 1.33
***************
*** 864,867 ****
--- 864,904 ----
DEPRECATE (cairo_get_target_surface, cairo_current_target_surface);
+ void
+ cairo_current_path (cairo_t *cr,
+ cairo_move_to_func_t *move_to,
+ cairo_line_to_func_t *line_to,
+ cairo_curve_to_func_t *curve_to,
+ cairo_close_path_func_t *close_path,
+ void *closure)
+ {
+ if (cr->status)
+ return;
+
+ cr->status = _cairo_gstate_interpret_path (cr->gstate,
+ move_to,
+ line_to,
+ curve_to,
+ close_path,
+ closure);
+ }
+
+ void
+ cairo_current_path_flat (cairo_t *cr,
+ cairo_move_to_func_t *move_to,
+ cairo_line_to_func_t *line_to,
+ cairo_close_path_func_t *close_path,
+ void *closure)
+ {
+ if (cr->status)
+ return;
+
+ cr->status = _cairo_gstate_interpret_path (cr->gstate,
+ move_to,
+ line_to,
+ NULL,
+ close_path,
+ closure);
+ }
+
cairo_status_t
cairo_status (cairo_t *cr)
Index: cairo.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo.h,v
retrieving revision 1.44
retrieving revision 1.45
diff -C2 -d -r1.44 -r1.45
*** a/cairo.h 13 Feb 2004 03:02:33 -0000 1.44
--- b/cairo.h 18 Feb 2004 02:38:23 -0000 1.45
***************
*** 173,176 ****
--- 173,180 ----
cairo_set_pattern (cairo_t *cr, cairo_surface_t *pattern);
+ /* XXX: Currently, the tolerance value is specified by the user in
+ terms of device-space units. If I'm not mistaken, this is the only
+ value in this API that is not expressed in user-space units. I
+ should think whether this value should be user-space instead. */
void
cairo_set_tolerance (cairo_t *cr, double tolerance);
***************
*** 260,266 ****
void
cairo_curve_to (cairo_t *cr,
! double x1, double y1,
! double x2, double y2,
! double x3, double y3);
void
--- 264,270 ----
void
cairo_curve_to (cairo_t *cr,
! double x1, double y1,
! double x2, double y2,
! double x3, double y3);
void
***************
*** 537,540 ****
--- 541,559 ----
typedef void (cairo_close_path_func_t) (void *closure);
+ extern void
+ cairo_current_path (cairo_t *cr,
+ cairo_move_to_func_t *move_to,
+ cairo_line_to_func_t *line_to,
+ cairo_curve_to_func_t *curve_to,
+ cairo_close_path_func_t *close_path,
+ void *closure);
+
+ extern void
+ cairo_current_path_flat (cairo_t *cr,
+ cairo_move_to_func_t *move_to,
+ cairo_line_to_func_t *line_to,
+ cairo_close_path_func_t *close_path,
+ void *closure);
+
/* Error status queries */
Index: cairo_gstate.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_gstate.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -C2 -d -r1.41 -r1.42
*** a/cairo_gstate.c 13 Feb 2004 03:02:33 -0000 1.41
--- b/cairo_gstate.c 18 Feb 2004 02:38:23 -0000 1.42
***************
*** 1097,1100 ****
--- 1097,1252 ----
}
+ typedef struct gstate_path_interpreter {
+ cairo_matrix_t ctm_inverse;
+ double tolerance;
+ cairo_point_t current_point;
+
+ cairo_move_to_func_t *move_to;
+ cairo_line_to_func_t *line_to;
+ cairo_curve_to_func_t *curve_to;
+ cairo_close_path_func_t *close_path;
+
+ void *closure;
+ } gpi_t;
+
+ static cairo_status_t
+ _gpi_move_to (void *closure, cairo_point_t *point)
+ {
+ gpi_t *gpi = closure;
+ double x, y;
+
+ x = _cairo_fixed_to_double (point->x);
+ y = _cairo_fixed_to_double (point->y);
+
+ cairo_matrix_transform_point (&gpi->ctm_inverse, &x, &y);
+
+ gpi->move_to (gpi->closure, x, y);
+ gpi->current_point = *point;
+
+ return CAIRO_STATUS_SUCCESS;
+ }
+
+ static cairo_status_t
+ _gpi_line_to (void *closure, cairo_point_t *point)
+ {
+ gpi_t *gpi = closure;
+ double x, y;
+
+ x = _cairo_fixed_to_double (point->x);
+ y = _cairo_fixed_to_double (point->y);
+
+ cairo_matrix_transform_point (&gpi->ctm_inverse, &x, &y);
+
+ gpi->line_to (gpi->closure, x, y);
+ gpi->current_point = *point;
+
+ return CAIRO_STATUS_SUCCESS;
+ }
+
+ static cairo_status_t
+ _gpi_curve_to (void *closure,
+ cairo_point_t *p1,
+ cairo_point_t *p2,
+ cairo_point_t *p3)
+ {
+ gpi_t *gpi = closure;
+ cairo_status_t status;
+ cairo_spline_t spline;
+ double x1, y1, x2, y2, x3, y3;
+
+ if (gpi->curve_to) {
+ x1 = _cairo_fixed_to_double (p1->x);
+ y1 = _cairo_fixed_to_double (p1->y);
+ cairo_matrix_transform_point (&gpi->ctm_inverse, &x1, &y1);
+
+ x2 = _cairo_fixed_to_double (p2->x);
+ y2 = _cairo_fixed_to_double (p2->y);
+ cairo_matrix_transform_point (&gpi->ctm_inverse, &x2, &y2);
+
+ x3 = _cairo_fixed_to_double (p3->x);
+ y3 = _cairo_fixed_to_double (p3->y);
+ cairo_matrix_transform_point (&gpi->ctm_inverse, &x3, &y3);
+
+ gpi->curve_to (gpi->closure, x1, y1, x2, y2, x3, y3);
+ } else {
+ cairo_point_t *p0 = &gpi->current_point;
+ int i;
+ double x, y;
+
+ status = _cairo_spline_init (&spline, p0, p1, p2, p3);
+ if (status == CAIRO_INT_STATUS_DEGENERATE)
+ return CAIRO_STATUS_SUCCESS;
+
+ status = _cairo_spline_decompose (&spline, gpi->tolerance);
+ if (status)
+ return status;
+
+ for (i=1; i < spline.num_points; i++) {
+ x = _cairo_fixed_to_double (spline.points[i].x);
+ y = _cairo_fixed_to_double (spline.points[i].y);
+
+ cairo_matrix_transform_point (&gpi->ctm_inverse, &x, &y);
+
+ gpi->line_to (gpi->closure, x, y);
+ }
+ }
+
+ gpi->current_point = *p3;
+
+ return CAIRO_STATUS_SUCCESS;
+ }
+
+ static cairo_status_t
+ _gpi_close_path (void *closure)
+ {
+ gpi_t *gpi = closure;
+
+ gpi->close_path (gpi->closure);
+
+ gpi->current_point.x = 0;
+ gpi->current_point.y = 0;
+
+ return CAIRO_STATUS_SUCCESS;
+ }
+
+ /* It's OK for curve_path to be NULL. In that case, all curves in the
+ path will be decomposed into one or more calls to the line_to
+ function, (according to the current tolerance). */
+ cairo_status_t
+ _cairo_gstate_interpret_path (cairo_gstate_t *gstate,
+ cairo_move_to_func_t *move_to,
+ cairo_line_to_func_t *line_to,
+ cairo_curve_to_func_t *curve_to,
+ cairo_close_path_func_t *close_path,
+ void *closure)
+ {
+ cairo_path_t path;
+ gpi_t gpi;
+
+ /* Anything we want from gstate must be copied. We must not retain
+ pointers into gstate. */
+ _cairo_path_init_copy (&path, &gstate->path);
+
+ cairo_matrix_copy (&gpi.ctm_inverse, &gstate->ctm_inverse);
+ gpi.tolerance = gstate->tolerance;
+
+ gpi.move_to = move_to;
+ gpi.line_to = line_to;
+ gpi.curve_to = curve_to;
+ gpi.close_path = close_path;
+ gpi.closure = closure;
+
+ gpi.current_point.x = 0;
+ gpi.current_point.y = 0;
+
+ return _cairo_path_interpret (&path,
+ CAIRO_DIRECTION_FORWARD,
+ _gpi_move_to,
+ _gpi_line_to,
+ _gpi_curve_to,
+ _gpi_close_path,
+ &gpi);
+ }
+
static cairo_status_t
_cairo_gstate_ensure_source (cairo_gstate_t *gstate)
Index: cairoint.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairoint.h,v
retrieving revision 1.51
retrieving revision 1.52
diff -C2 -d -r1.51 -r1.52
*** a/cairoint.h 13 Feb 2004 03:02:33 -0000 1.51
--- b/cairoint.h 18 Feb 2004 02:38:23 -0000 1.52
***************
*** 721,724 ****
--- 721,732 ----
extern cairo_status_t __internal_linkage
+ _cairo_gstate_interpret_path (cairo_gstate_t *gstate,
+ cairo_move_to_func_t *move_to,
+ cairo_line_to_func_t *line_to,
+ cairo_curve_to_func_t *curve_to,
+ cairo_close_path_func_t *close_path,
+ void *closure);
+
+ extern cairo_status_t __internal_linkage
_cairo_gstate_stroke (cairo_gstate_t *gstate);
More information about the cairo-commit
mailing list