[cairo-commit] cairo/src cairo_path.c,1.10,1.11 cairo_path_fill.c,1.7,1.8 cairo_path_stroke.c,1.12,1.13 cairo_pen.c,1.13,1.14 cairo_polygon.c,1.5,1.6 cairoint.h,1.40,1.41
Carl Worth
commit at pdx.freedesktop.org
Mon Dec 8 13:38:28 PST 2003
Committed by: cworth
Update of /cvs/cairo/cairo/src
In directory pdx:/tmp/cvs-serv26623/src
Modified Files:
cairo_path.c cairo_path_fill.c cairo_path_stroke.c cairo_pen.c
cairo_polygon.c cairoint.h
Log Message:
* src/cairoint.h:
* src/cairo_path_stroke.c:
* src/cairo_path_fill.c:
* src/cairo_path.c: Clean up cairo_path_callbacks to have move_to,
line_to, curve_to, abd close_path instead of add_edge, add_spline,
and done_sub_path. Much, much nicer.
* src/cairo_polygon.c (_cairo_polygon_move_to): Provide
cairo_polygon_move_to and cairo_polygon_line_to instead of
cairo_polygon_add_point.
* src/cairo_pen.c (_cairo_pen_stroke_spline_half): Track change in
cairo_polygon interface.
Index: cairo_path.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_path.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** cairo_path.c 7 Nov 2003 02:33:28 -0000 1.10
--- cairo_path.c 8 Dec 2003 21:38:26 -0000 1.11
***************
*** 330,337 ****
int buf_i = 0;
cairo_point_t point[CAIRO_PATH_OP_MAX_ARGS];
- cairo_point_t current = {0, 0};
- cairo_point_t first = {0, 0};
- int has_current = 0;
- int has_edge = 0;
int step = (dir == CAIRO_DIRECTION_FORWARD) ? 1 : -1;
--- 330,333 ----
***************
*** 375,433 ****
switch (op) {
case CAIRO_PATH_OP_MOVE_TO:
! if (has_edge) {
! status = (*cb->done_sub_path) (closure, CAIRO_SUB_PATH_DONE_CAP);
! if (status)
! return status;
! }
! first = point[0];
! current = point[0];
! has_current = 1;
! has_edge = 0;
break;
case CAIRO_PATH_OP_LINE_TO:
! if (has_current) {
! status = (*cb->add_edge) (closure, ¤t, &point[0]);
! if (status)
! return status;
! current = point[0];
! has_edge = 1;
! } else {
! first = point[0];
! current = point[0];
! has_current = 1;
! has_edge = 0;
! }
break;
case CAIRO_PATH_OP_CURVE_TO:
! if (has_current) {
! status = (*cb->add_spline) (closure, ¤t, &point[0], &point[1], &point[2]);
! if (status)
! return status;
! current = point[2];
! has_edge = 1;
! } else {
! first = point[2];
! current = point[2];
! has_current = 1;
! has_edge = 0;
! }
break;
case CAIRO_PATH_OP_CLOSE_PATH:
! if (has_edge) {
! (*cb->add_edge) (closure, ¤t, &first);
! (*cb->done_sub_path) (closure, CAIRO_SUB_PATH_DONE_JOIN);
! }
! current.x = 0;
! current.y = 0;
! first.x = 0;
! first.y = 0;
! has_current = 0;
! has_edge = 0;
break;
}
}
}
- if (has_edge)
- (*cb->done_sub_path) (closure, CAIRO_SUB_PATH_DONE_CAP);
return (*cb->done_path) (closure);
--- 371,391 ----
switch (op) {
case CAIRO_PATH_OP_MOVE_TO:
! status = (*cb->move_to) (closure, &point[0]);
break;
case CAIRO_PATH_OP_LINE_TO:
! status = (*cb->line_to) (closure, &point[0]);
break;
case CAIRO_PATH_OP_CURVE_TO:
! status = (*cb->curve_to) (closure, &point[0], &point[1], &point[2]);
break;
case CAIRO_PATH_OP_CLOSE_PATH:
! default:
! status = (*cb->close_path) (closure);
break;
}
+ if (status)
+ return status;
}
}
return (*cb->done_path) (closure);
Index: cairo_path_fill.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_path_fill.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** cairo_path_fill.c 23 Oct 2003 14:47:29 -0000 1.7
--- cairo_path_fill.c 8 Dec 2003 21:38:26 -0000 1.8
***************
*** 32,35 ****
--- 32,37 ----
cairo_traps_t *traps;
+ cairo_point_t current_point;
+
cairo_polygon_t polygon;
} cairo_filler_t;
***************
*** 42,54 ****
static cairo_status_t
! _cairo_filler_add_edge (void *closure, cairo_point_t *p1, cairo_point_t *p2);
static cairo_status_t
! _cairo_filler_add_spline (void *closure,
! cairo_point_t *a, cairo_point_t *b,
! cairo_point_t *c, cairo_point_t *d);
static cairo_status_t
! _cairo_filler_done_sub_path (void *closure, cairo_sub_path_done_t done);
static cairo_status_t
--- 44,60 ----
static cairo_status_t
! _cairo_filler_move_to (void *closure, cairo_point_t *point);
static cairo_status_t
! _cairo_filler_line_to (void *closure, cairo_point_t *point);
static cairo_status_t
! _cairo_filler_curve_to (void *closure,
! cairo_point_t *b,
! cairo_point_t *c,
! cairo_point_t *d);
!
! static cairo_status_t
! _cairo_filler_close_path (void *closure);
static cairo_status_t
***************
*** 61,64 ****
--- 67,73 ----
filler->traps = traps;
+ filler->current_point.x = 0;
+ filler->current_point.y = 0;
+
_cairo_polygon_init (&filler->polygon);
}
***************
*** 71,86 ****
static cairo_status_t
! _cairo_filler_add_edge (void *closure, cairo_point_t *p1, cairo_point_t *p2)
{
cairo_filler_t *filler = closure;
cairo_polygon_t *polygon = &filler->polygon;
! return _cairo_polygon_add_edge (polygon, p1, p2);
}
static cairo_status_t
! _cairo_filler_add_spline (void *closure,
! cairo_point_t *a, cairo_point_t *b,
! cairo_point_t *c, cairo_point_t *d)
{
int i;
--- 80,123 ----
static cairo_status_t
! _cairo_filler_move_to (void *closure, cairo_point_t *point)
{
+ cairo_status_t status;
cairo_filler_t *filler = closure;
cairo_polygon_t *polygon = &filler->polygon;
! status = _cairo_polygon_close (polygon);
! if (status)
! return status;
!
! status = _cairo_polygon_move_to (polygon, point);
! if (status)
! return status;
!
! filler->current_point = *point;
!
! return CAIRO_STATUS_SUCCESS;
}
static cairo_status_t
! _cairo_filler_line_to (void *closure, cairo_point_t *point)
! {
! cairo_status_t status;
! cairo_filler_t *filler = closure;
! cairo_polygon_t *polygon = &filler->polygon;
!
! status = _cairo_polygon_line_to (polygon, point);
! if (status)
! return status;
!
! filler->current_point = *point;
!
! return CAIRO_STATUS_SUCCESS;
! }
!
! static cairo_status_t
! _cairo_filler_curve_to (void *closure,
! cairo_point_t *b,
! cairo_point_t *c,
! cairo_point_t *d)
{
int i;
***************
*** 91,95 ****
cairo_spline_t spline;
! status = _cairo_spline_init (&spline, a, b, c, d);
if (status == CAIRO_INT_STATUS_DEGENERATE)
return CAIRO_STATUS_SUCCESS;
--- 128,133 ----
cairo_spline_t spline;
! status = _cairo_spline_init (&spline, &filler->current_point, b, c, d);
!
if (status == CAIRO_INT_STATUS_DEGENERATE)
return CAIRO_STATUS_SUCCESS;
***************
*** 99,106 ****
goto CLEANUP_SPLINE;
! for (i = 0; i < spline.num_points - 1; i++) {
! status = _cairo_polygon_add_edge (polygon, &spline.points[i], &spline.points[i+1]);
if (status)
! goto CLEANUP_SPLINE;
}
--- 137,144 ----
goto CLEANUP_SPLINE;
! for (i = 1; i < spline.num_points; i++) {
! status = _cairo_polygon_line_to (polygon, &spline.points[i]);
if (status)
! break;
}
***************
*** 108,124 ****
_cairo_spline_fini (&spline);
return status;
}
static cairo_status_t
! _cairo_filler_done_sub_path (void *closure, cairo_sub_path_done_t done)
{
! cairo_status_t status = CAIRO_STATUS_SUCCESS;
cairo_filler_t *filler = closure;
cairo_polygon_t *polygon = &filler->polygon;
! _cairo_polygon_close (polygon);
! return status;
}
--- 146,166 ----
_cairo_spline_fini (&spline);
+ filler->current_point = *d;
+
return status;
}
static cairo_status_t
! _cairo_filler_close_path (void *closure)
{
! cairo_status_t status;
cairo_filler_t *filler = closure;
cairo_polygon_t *polygon = &filler->polygon;
! status = _cairo_polygon_close (polygon);
! if (status)
! return status;
! return CAIRO_STATUS_SUCCESS;
}
***************
*** 126,134 ****
_cairo_filler_done_path (void *closure)
{
cairo_filler_t *filler = closure;
! return _cairo_traps_tessellate_polygon (filler->traps,
! &filler->polygon,
! filler->gstate->fill_rule);
}
--- 168,186 ----
_cairo_filler_done_path (void *closure)
{
+ cairo_status_t status;
cairo_filler_t *filler = closure;
+ cairo_polygon_t *polygon = &filler->polygon;
! status = _cairo_polygon_close (polygon);
! if (status)
! return status;
!
! status = _cairo_traps_tessellate_polygon (filler->traps,
! &filler->polygon,
! filler->gstate->fill_rule);
! if (status)
! return status;
!
! return CAIRO_STATUS_SUCCESS;
}
***************
*** 137,143 ****
{
static const cairo_path_callbacks_t filler_callbacks = {
! _cairo_filler_add_edge,
! _cairo_filler_add_spline,
! _cairo_filler_done_sub_path,
_cairo_filler_done_path
};
--- 189,196 ----
{
static const cairo_path_callbacks_t filler_callbacks = {
! _cairo_filler_move_to,
! _cairo_filler_line_to,
! _cairo_filler_curve_to,
! _cairo_filler_close_path,
_cairo_filler_done_path
};
Index: cairo_path_stroke.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_path_stroke.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** cairo_path_stroke.c 21 Nov 2003 14:22:02 -0000 1.12
--- cairo_path_stroke.c 8 Dec 2003 21:38:26 -0000 1.13
***************
*** 32,40 ****
cairo_traps_t *traps;
! int have_prev;
! int have_first;
! int is_first;
! cairo_stroke_face_t prev;
! cairo_stroke_face_t first;
int dash_index;
int dash_on;
--- 32,46 ----
cairo_traps_t *traps;
! int has_current_point;
! cairo_point_t current_point;
! cairo_point_t first_point;
!
! int has_current_face;
! cairo_stroke_face_t current_face;
!
! int has_first_face;
! cairo_stroke_face_t first_face;
!
! int dashed;
int dash_index;
int dash_on;
***************
*** 50,65 ****
static cairo_status_t
! _cairo_stroker_add_edge (void *closure, cairo_point_t *p1, cairo_point_t *p2);
static cairo_status_t
! _cairo_stroker_add_edge_dashed (void *closure, cairo_point_t *p1, cairo_point_t *p2);
static cairo_status_t
! _cairo_stroker_add_spline (void *closure,
! cairo_point_t *a, cairo_point_t *b,
! cairo_point_t *c, cairo_point_t *d);
static cairo_status_t
! _cairo_stroker_done_sub_path (void *closure, cairo_sub_path_done_t done);
static cairo_status_t
--- 56,75 ----
static cairo_status_t
! _cairo_stroker_move_to (void *closure, cairo_point_t *point);
static cairo_status_t
! _cairo_stroker_line_to (void *closure, cairo_point_t *point);
static cairo_status_t
! _cairo_stroker_line_to_dashed (void *closure, cairo_point_t *point);
static cairo_status_t
! _cairo_stroker_curve_to (void *closure,
! cairo_point_t *b,
! cairo_point_t *c,
! cairo_point_t *d);
!
! static cairo_status_t
! _cairo_stroker_close_path (void *closure);
static cairo_status_t
***************
*** 90,93 ****
--- 100,104 ----
i = 0;
}
+ stroker->dashed = 1;
stroker->dash_index = i;
stroker->dash_on = on;
***************
*** 114,122 ****
stroker->gstate = gstate;
stroker->traps = traps;
! stroker->have_prev = 0;
! stroker->have_first = 0;
! stroker->is_first = 1;
if (gstate->dash)
_cairo_stroker_start_dash (stroker);
}
--- 125,137 ----
stroker->gstate = gstate;
stroker->traps = traps;
!
! stroker->has_current_point = 0;
! stroker->has_current_face = 0;
! stroker->has_first_face = 0;
!
if (gstate->dash)
_cairo_stroker_start_dash (stroker);
+ else
+ stroker->dashed = 0;
}
***************
*** 287,294 ****
outer.y = _cairo_fixed_from_double (my);
_cairo_polygon_init (&polygon);
! _cairo_polygon_add_edge (&polygon, &in->point, inpt);
! _cairo_polygon_add_edge (&polygon, inpt, &outer);
! _cairo_polygon_add_edge (&polygon, &outer, outpt);
! _cairo_polygon_add_edge (&polygon, outpt, &in->point);
status = _cairo_traps_tessellate_polygon (stroker->traps,
&polygon,
--- 302,310 ----
outer.y = _cairo_fixed_from_double (my);
_cairo_polygon_init (&polygon);
! _cairo_polygon_move_to (&polygon, &in->point);
! _cairo_polygon_line_to (&polygon, inpt);
! _cairo_polygon_line_to (&polygon, &outer);
! _cairo_polygon_line_to (&polygon, outpt);
! _cairo_polygon_close (&polygon);
status = _cairo_traps_tessellate_polygon (stroker->traps,
&polygon,
***************
*** 352,357 ****
cairo_polygon_t polygon;
- _cairo_polygon_init (&polygon);
-
dx = f->usr_vector.x;
dy = f->usr_vector.y;
--- 368,371 ----
***************
*** 366,373 ****
ocw.y = f->cw.y + fvector.dy;
! _cairo_polygon_add_edge (&polygon, &f->cw, &ocw);
! _cairo_polygon_add_edge (&polygon, &ocw, &occw);
! _cairo_polygon_add_edge (&polygon, &occw, &f->ccw);
! _cairo_polygon_add_edge (&polygon, &f->ccw, &f->cw);
status = _cairo_traps_tessellate_polygon (stroker->traps, &polygon, CAIRO_FILL_RULE_WINDING);
--- 380,389 ----
ocw.y = f->cw.y + fvector.dy;
! _cairo_polygon_init (&polygon);
! _cairo_polygon_move_to (&polygon, &f->cw);
! _cairo_polygon_line_to (&polygon, &ocw);
! _cairo_polygon_line_to (&polygon, &occw);
! _cairo_polygon_line_to (&polygon, &f->ccw);
! _cairo_polygon_close (&polygon);
status = _cairo_traps_tessellate_polygon (stroker->traps, &polygon, CAIRO_FILL_RULE_WINDING);
***************
*** 483,491 ****
static cairo_status_t
! _cairo_stroker_add_edge (void *closure, cairo_point_t *p1, cairo_point_t *p2)
{
cairo_status_t status;
cairo_stroker_t *stroker = closure;
cairo_stroke_face_t start, end;
if (p1->x == p2->x && p1->y == p2->y) {
--- 499,527 ----
static cairo_status_t
! _cairo_stroker_move_to (void *closure, cairo_point_t *point)
! {
! cairo_stroker_t *stroker = closure;
!
! stroker->first_point = *point;
! stroker->current_point = *point;
! stroker->has_current_point = 1;
!
! stroker->has_first_face = 0;
! stroker->has_current_face = 0;
!
! return CAIRO_STATUS_SUCCESS;
! }
!
! static cairo_status_t
! _cairo_stroker_line_to (void *closure, cairo_point_t *point)
{
cairo_status_t status;
cairo_stroker_t *stroker = closure;
cairo_stroke_face_t start, end;
+ cairo_point_t *p1 = &stroker->current_point;
+ cairo_point_t *p2 = point;
+
+ if (!stroker->has_current_point)
+ return _cairo_stroker_move_to (stroker, point);
if (p1->x == p2->x && p1->y == p2->y) {
***************
*** 501,517 ****
return status;
! if (stroker->have_prev) {
! status = _cairo_stroker_join (stroker, &stroker->prev, &start);
if (status)
return status;
} else {
! stroker->have_prev = 1;
! if (stroker->is_first) {
! stroker->have_first = 1;
! stroker->first = start;
}
}
! stroker->prev = end;
! stroker->is_first = 0;
return CAIRO_STATUS_SUCCESS;
--- 537,554 ----
return status;
! if (stroker->has_current_face) {
! status = _cairo_stroker_join (stroker, &stroker->current_face, &start);
if (status)
return status;
} else {
! if (!stroker->has_first_face) {
! stroker->first_face = start;
! stroker->has_first_face = 1;
}
}
! stroker->current_face = end;
! stroker->has_current_face = 1;
!
! stroker->current_point = *point;
return CAIRO_STATUS_SUCCESS;
***************
*** 522,526 ****
*/
static cairo_status_t
! _cairo_stroker_add_edge_dashed (void *closure, cairo_point_t *p1, cairo_point_t *p2)
{
cairo_status_t status = CAIRO_STATUS_SUCCESS;
--- 559,563 ----
*/
static cairo_status_t
! _cairo_stroker_line_to_dashed (void *closure, cairo_point_t *point)
{
cairo_status_t status = CAIRO_STATUS_SUCCESS;
***************
*** 533,536 ****
--- 570,578 ----
int first = 1;
cairo_stroke_face_t sub_start, sub_end;
+ cairo_point_t *p1 = &stroker->current_point;
+ cairo_point_t *p2 = point;
+
+ if (!stroker->has_current_point)
+ return _cairo_stroker_move_to (stroker, point);
dx = _cairo_fixed_to_double (p2->x - p1->x);
***************
*** 570,585 ****
} else {
/*
! * First in this segment, join to any prev, else
* if at start of sub-path, mark position, else
* cap
*/
! if (stroker->have_prev) {
! status = _cairo_stroker_join (stroker, &stroker->prev, &sub_start);
if (status)
return status;
} else {
! if (stroker->is_first) {
! stroker->have_first = 1;
! stroker->first = sub_start;
} else {
status = _cairo_stroker_cap (stroker, &sub_start);
--- 612,627 ----
} else {
/*
! * First in this segment, join to any current_face, else
* if at start of sub-path, mark position, else
* cap
*/
! if (stroker->has_current_face) {
! status = _cairo_stroker_join (stroker, &stroker->current_face, &sub_start);
if (status)
return status;
} else {
! if (!stroker->has_first_face) {
! stroker->first_face = sub_start;
! stroker->has_first_face = 1;
} else {
status = _cairo_stroker_cap (stroker, &sub_start);
***************
*** 601,606 ****
* through
*/
! stroker->prev = sub_end;
! stroker->have_prev = 1;
}
} else {
--- 643,648 ----
* through
*/
! stroker->current_face = sub_end;
! stroker->has_current_face = 1;
}
} else {
***************
*** 610,615 ****
*/
if (first) {
! if (stroker->have_prev) {
! status = _cairo_stroker_cap (stroker, &stroker->prev);
if (status)
return status;
--- 652,657 ----
*/
if (first) {
! if (stroker->has_current_face) {
! status = _cairo_stroker_cap (stroker, &stroker->current_face);
if (status)
return status;
***************
*** 617,621 ****
}
if (!remain)
! stroker->have_prev = 0;
}
_cairo_stroker_step_dash (stroker, tmp);
--- 659,663 ----
}
if (!remain)
! stroker->has_current_face = 0;
}
_cairo_stroker_step_dash (stroker, tmp);
***************
*** 623,634 ****
first = 0;
}
! stroker->is_first = 0;
return status;
}
static cairo_status_t
! _cairo_stroker_add_spline (void *closure,
! cairo_point_t *a, cairo_point_t *b,
! cairo_point_t *c, cairo_point_t *d)
{
cairo_status_t status = CAIRO_STATUS_SUCCESS;
--- 665,679 ----
first = 0;
}
!
! stroker->current_point = *point;
!
return status;
}
static cairo_status_t
! _cairo_stroker_curve_to (void *closure,
! cairo_point_t *b,
! cairo_point_t *c,
! cairo_point_t *d)
{
cairo_status_t status = CAIRO_STATUS_SUCCESS;
***************
*** 639,642 ****
--- 684,688 ----
cairo_stroke_face_t start, end;
cairo_point_t extra_points[4];
+ cairo_point_t *a = &stroker->current_point;
status = _cairo_spline_init (&spline, a, b, c, d);
***************
*** 651,667 ****
_compute_face (d, &spline.final_slope, gstate, &end);
! if (stroker->have_prev) {
! status = _cairo_stroker_join (stroker, &stroker->prev, &start);
if (status)
return status;
} else {
! stroker->have_prev = 1;
! if (stroker->is_first) {
! stroker->have_first = 1;
! stroker->first = start;
}
}
! stroker->prev = end;
! stroker->is_first = 0;
extra_points[0] = start.cw;
--- 697,712 ----
_compute_face (d, &spline.final_slope, gstate, &end);
! if (stroker->has_current_face) {
! status = _cairo_stroker_join (stroker, &stroker->current_face, &start);
if (status)
return status;
} else {
! if (!stroker->has_first_face) {
! stroker->first_face = start;
! stroker->has_first_face = 1;
}
}
! stroker->current_face = end;
! stroker->has_current_face = 1;
extra_points[0] = start.cw;
***************
*** 691,738 ****
_cairo_spline_fini (&spline);
return status;
}
static cairo_status_t
! _cairo_stroker_done_sub_path (void *closure, cairo_sub_path_done_t done)
{
cairo_status_t status;
cairo_stroker_t *stroker = closure;
! switch (done) {
! case CAIRO_SUB_PATH_DONE_JOIN:
! if (stroker->have_first && stroker->have_prev) {
! status = _cairo_stroker_join (stroker, &stroker->prev, &stroker->first);
! if (status)
! return status;
! break;
! }
! /* fall through... */
! case CAIRO_SUB_PATH_DONE_CAP:
! if (stroker->have_first) {
! cairo_point_t t;
! /* The initial cap needs an outward facing vector. Reverse everything */
! stroker->first.usr_vector.x = -stroker->first.usr_vector.x;
! stroker->first.usr_vector.y = -stroker->first.usr_vector.y;
! stroker->first.dev_vector.dx = -stroker->first.dev_vector.dx;
! stroker->first.dev_vector.dy = -stroker->first.dev_vector.dy;
! t = stroker->first.cw;
! stroker->first.cw = stroker->first.ccw;
! stroker->first.ccw = t;
! status = _cairo_stroker_cap (stroker, &stroker->first);
! if (status)
! return status;
! }
! if (stroker->have_prev) {
! status = _cairo_stroker_cap (stroker, &stroker->prev);
! if (status)
! return status;
! }
! break;
}
! stroker->have_prev = 0;
! stroker->have_first = 0;
! stroker->is_first = 1;
return CAIRO_STATUS_SUCCESS;
--- 736,768 ----
_cairo_spline_fini (&spline);
+ stroker->current_point = *d;
+
return status;
}
static cairo_status_t
! _cairo_stroker_close_path (void *closure)
{
cairo_status_t status;
cairo_stroker_t *stroker = closure;
! if (stroker->has_current_point) {
! if (stroker->dashed)
! status = _cairo_stroker_line_to_dashed (stroker, &stroker->first_point);
! else
! status = _cairo_stroker_line_to (stroker, &stroker->first_point);
! if (status)
! return status;
}
! if (stroker->has_first_face && stroker->has_current_face) {
! status = _cairo_stroker_join (stroker, &stroker->current_face, &stroker->first_face);
! if (status)
! return status;
! }
!
! stroker->has_first_face = 0;
! stroker->has_current_face = 0;
! stroker->has_current_point = 0;
return CAIRO_STATUS_SUCCESS;
***************
*** 742,745 ****
--- 772,802 ----
_cairo_stroker_done_path (void *closure)
{
+ cairo_status_t status;
+ cairo_stroker_t *stroker = closure;
+
+ if (stroker->has_first_face) {
+ cairo_point_t t;
+ /* The initial cap needs an outward facing vector. Reverse everything */
+ stroker->first_face.usr_vector.x = -stroker->first_face.usr_vector.x;
+ stroker->first_face.usr_vector.y = -stroker->first_face.usr_vector.y;
+ stroker->first_face.dev_vector.dx = -stroker->first_face.dev_vector.dx;
+ stroker->first_face.dev_vector.dy = -stroker->first_face.dev_vector.dy;
+ t = stroker->first_face.cw;
+ stroker->first_face.cw = stroker->first_face.ccw;
+ stroker->first_face.ccw = t;
+ status = _cairo_stroker_cap (stroker, &stroker->first_face);
+ if (status)
+ return status;
+ }
+ if (stroker->has_current_face) {
+ status = _cairo_stroker_cap (stroker, &stroker->current_face);
+ if (status)
+ return status;
+ }
+
+ stroker->has_first_face = 0;
+ stroker->has_current_face = 0;
+ stroker->has_current_point = 0;
+
return CAIRO_STATUS_SUCCESS;
}
***************
*** 749,761 ****
{
static const cairo_path_callbacks_t stroker_solid_cb = {
! _cairo_stroker_add_edge,
! _cairo_stroker_add_spline,
! _cairo_stroker_done_sub_path,
_cairo_stroker_done_path
};
static const cairo_path_callbacks_t stroker_dashed_cb = {
! _cairo_stroker_add_edge_dashed,
! _cairo_stroker_add_spline,
! _cairo_stroker_done_sub_path,
_cairo_stroker_done_path
};
--- 806,820 ----
{
static const cairo_path_callbacks_t stroker_solid_cb = {
! _cairo_stroker_move_to,
! _cairo_stroker_line_to,
! _cairo_stroker_curve_to,
! _cairo_stroker_close_path,
_cairo_stroker_done_path
};
static const cairo_path_callbacks_t stroker_dashed_cb = {
! _cairo_stroker_move_to,
! _cairo_stroker_line_to_dashed,
! _cairo_stroker_curve_to,
! _cairo_stroker_close_path,
_cairo_stroker_done_path
};
Index: cairo_pen.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_pen.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** cairo_pen.c 17 Nov 2003 15:04:16 -0000 1.13
--- cairo_pen.c 8 Dec 2003 21:38:26 -0000 1.14
***************
*** 289,293 ****
hull_point.x = point[i].x + pen->vertices[active].point.x;
hull_point.y = point[i].y + pen->vertices[active].point.y;
! status = _cairo_polygon_add_point (polygon, &hull_point);
if (status)
return status;
--- 289,293 ----
hull_point.x = point[i].x + pen->vertices[active].point.x;
hull_point.y = point[i].y + pen->vertices[active].point.y;
! status = _cairo_polygon_line_to (polygon, &hull_point);
if (status)
return status;
Index: cairo_polygon.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_polygon.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** cairo_polygon.c 21 Nov 2003 14:22:02 -0000 1.5
--- cairo_polygon.c 8 Dec 2003 21:38:26 -0000 1.6
***************
*** 36,42 ****
_cairo_polygon_grow_by (cairo_polygon_t *polygon, int additional);
- static void
- _cairo_polygon_set_last_point (cairo_polygon_t *polygon, cairo_point_t *point);
-
void
_cairo_polygon_init (cairo_polygon_t *polygon)
--- 36,39 ----
***************
*** 47,54 ****
polygon->edges = NULL;
! polygon->first_point_defined = 0;
! polygon->last_point_defined = 0;
!
! polygon->closed = 0;
}
--- 44,48 ----
polygon->edges = NULL;
! polygon->has_current_point = 0;
}
***************
*** 63,70 ****
}
! polygon->first_point_defined = 0;
! polygon->last_point_defined = 0;
!
! polygon->closed = 0;
}
--- 57,61 ----
}
! polygon->has_current_point = 0;
}
***************
*** 93,103 ****
}
- static void
- _cairo_polygon_set_last_point (cairo_polygon_t *polygon, cairo_point_t *point)
- {
- polygon->last_point = *point;
- polygon->last_point_defined = 1;
- }
-
cairo_status_t
_cairo_polygon_add_edge (cairo_polygon_t *polygon, cairo_point_t *p1, cairo_point_t *p2)
--- 84,87 ----
***************
*** 106,115 ****
cairo_edge_t *edge;
- if (! polygon->first_point_defined) {
- polygon->first_point = *p1;
- polygon->first_point_defined = 1;
- polygon->closed = 0;
- }
-
/* drop horizontal edges */
if (p1->y == p2->y) {
--- 90,93 ----
***************
*** 138,142 ****
DONE:
! _cairo_polygon_set_last_point (polygon, p2);
return CAIRO_STATUS_SUCCESS;
--- 116,131 ----
DONE:
! _cairo_polygon_move_to (polygon, p2);
!
! return CAIRO_STATUS_SUCCESS;
! }
!
! cairo_status_t
! _cairo_polygon_move_to (cairo_polygon_t *polygon, cairo_point_t *point)
! {
! if (! polygon->has_current_point)
! polygon->first_point = *point;
! polygon->current_point = *point;
! polygon->has_current_point = 1;
return CAIRO_STATUS_SUCCESS;
***************
*** 144,155 ****
cairo_status_t
! _cairo_polygon_add_point (cairo_polygon_t *polygon, cairo_point_t *point)
{
cairo_status_t status = CAIRO_STATUS_SUCCESS;
! if (polygon->last_point_defined) {
! status = _cairo_polygon_add_edge (polygon, &polygon->last_point, point);
} else {
! _cairo_polygon_set_last_point (polygon, point);
}
--- 133,144 ----
cairo_status_t
! _cairo_polygon_line_to (cairo_polygon_t *polygon, cairo_point_t *point)
{
cairo_status_t status = CAIRO_STATUS_SUCCESS;
! if (polygon->has_current_point) {
! status = _cairo_polygon_add_edge (polygon, &polygon->current_point, point);
} else {
! _cairo_polygon_move_to (polygon, point);
}
***************
*** 162,172 ****
cairo_status_t status;
! if (polygon->closed == 0 && polygon->last_point_defined) {
! status = _cairo_polygon_add_edge (polygon, &polygon->last_point, &polygon->first_point);
if (status)
return status;
! polygon->closed = 1;
! polygon->first_point_defined = 0;
}
--- 151,162 ----
cairo_status_t status;
! if (polygon->has_current_point) {
! status = _cairo_polygon_add_edge (polygon,
! &polygon->current_point,
! &polygon->first_point);
if (status)
return status;
! polygon->has_current_point = 0;
}
Index: cairoint.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairoint.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -d -r1.40 -r1.41
*** cairoint.h 3 Dec 2003 20:27:44 -0000 1.40
--- cairoint.h 8 Dec 2003 21:38:26 -0000 1.41
***************
*** 145,157 ****
} cairo_direction_t;
- typedef enum cairo_sub_path_done {
- CAIRO_SUB_PATH_DONE_CAP,
- CAIRO_SUB_PATH_DONE_JOIN
- } cairo_sub_path_done_t;
-
typedef struct cairo_path_callbacks {
! cairo_status_t (*add_edge) (void *closure, cairo_point_t *p1, cairo_point_t *p2);
! cairo_status_t (*add_spline) (void *closure, cairo_point_t *a, cairo_point_t *b, cairo_point_t *c, cairo_point_t *d);
! cairo_status_t (*done_sub_path) (void *closure, cairo_sub_path_done_t done);
cairo_status_t (*done_path) (void *closure);
} cairo_path_callbacks_t;
--- 145,153 ----
} cairo_direction_t;
typedef struct cairo_path_callbacks {
! cairo_status_t (*move_to) (void *closure, cairo_point_t *point);
! cairo_status_t (*line_to) (void *closure, cairo_point_t *point);
! cairo_status_t (*curve_to) (void *closure, cairo_point_t *b, cairo_point_t *c, cairo_point_t *d);
! cairo_status_t (*close_path) (void *closure);
cairo_status_t (*done_path) (void *closure);
} cairo_path_callbacks_t;
***************
*** 194,200 ****
cairo_point_t first_point;
! int first_point_defined;
! cairo_point_t last_point;
! int last_point_defined;
int closed;
--- 190,195 ----
cairo_point_t first_point;
! cairo_point_t current_point;
! int has_current_point;
int closed;
***************
*** 1066,1070 ****
extern cairo_status_t __internal_linkage
! _cairo_polygon_add_point (cairo_polygon_t *polygon, cairo_point_t *point);
extern cairo_status_t __internal_linkage
--- 1061,1068 ----
extern cairo_status_t __internal_linkage
! _cairo_polygon_move_to (cairo_polygon_t *polygon, cairo_point_t *point);
!
! extern cairo_status_t __internal_linkage
! _cairo_polygon_line_to (cairo_polygon_t *polygon, cairo_point_t *point);
extern cairo_status_t __internal_linkage
More information about the cairo-commit
mailing list