[cairo-commit]
cairo/src cairo-gstate.c, 1.114, 1.115 cairo-traps.c,
1.26, 1.27 cairo.c, 1.82, 1.83 cairoint.h, 1.129, 1.130
Owen Taylor
commit at pdx.freedesktop.org
Wed Apr 27 10:16:50 PDT 2005
Committed by: otaylor
Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv2497/src
Modified Files:
cairo-gstate.c cairo-traps.c cairo.c cairoint.h
Log Message:
2005-04-27 Owen Taylor <otaylor at redhat.com>
* src/cairo-traps.c src/cairoint.h (_cairo_traps_init_box):
New function to create a single trapezoid box.
* src/cairo.c src/cairo-gstate.c src/cairoint.h: Move
the implementation of cairo_paint() into cairo-gstate.c
for a better fix for the problem with backend/user coordinate
confusion. Also no longer clear the current path on
cairo_paint()
Index: cairo-gstate.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-gstate.c,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -d -r1.114 -r1.115
--- cairo-gstate.c 26 Apr 2005 19:38:06 -0000 1.114
+++ cairo-gstate.c 27 Apr 2005 17:16:47 -0000 1.115
@@ -715,10 +715,34 @@
}
cairo_status_t
-_cairo_gstate_get_clip_extents (cairo_gstate_t *gstate,
- cairo_rectangle_t *rectangle)
+_cairo_gstate_paint (cairo_gstate_t *gstate)
{
- return _cairo_surface_get_clip_extents (gstate->surface, rectangle);
+ cairo_rectangle_t rectangle;
+ cairo_status_t status;
+ cairo_box_t box;
+ cairo_traps_t traps;
+
+ status = _cairo_surface_get_clip_extents (gstate->surface, &rectangle);
+ if (!CAIRO_OK (status))
+ return status;
+
+ box.p1.x = _cairo_fixed_from_int (rectangle.x);
+ box.p1.y = _cairo_fixed_from_int (rectangle.y);
+ box.p2.x = _cairo_fixed_from_int (rectangle.x + rectangle.width);
+ box.p2.y = _cairo_fixed_from_int (rectangle.y + rectangle.height);
+ status = _cairo_traps_init_box (&traps, &box);
+ if (!CAIRO_OK (status))
+ return status;
+
+ _cairo_gstate_clip_and_composite_trapezoids (gstate,
+ gstate->source,
+ gstate->operator,
+ gstate->surface,
+ &traps);
+
+ _cairo_traps_fini (&traps);
+
+ return CAIRO_STATUS_SUCCESS;
}
cairo_status_t
Index: cairo-traps.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-traps.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- cairo-traps.c 13 Apr 2005 21:04:33 -0000 1.26
+++ cairo-traps.c 27 Apr 2005 17:16:47 -0000 1.27
@@ -88,6 +88,43 @@
}
}
+/**
+ * _cairo_traps_init_box:
+ * @traps: a #cairo_traps_t
+ * @box: a box that will be converted to a single trapezoid
+ * to store in @traps.
+ *
+ * Initializes a cairo_traps_t to contain a single rectangular
+ * trapezoid.
+ **/
+cairo_status_t
+_cairo_traps_init_box (cairo_traps_t *traps,
+ cairo_box_t *box)
+{
+ cairo_status_t status;
+
+ _cairo_traps_init (traps);
+
+ status = _cairo_traps_grow_by (traps, 1);
+ if (status)
+ return status;
+
+ traps->num_traps = 1;
+
+ traps->traps[0].top = box->p1.y;
+ traps->traps[0].bottom = box->p2.y;
+ traps->traps[0].left.p1 = box->p1;
+ traps->traps[0].left.p2.x = box->p1.x;
+ traps->traps[0].left.p2.y = box->p2.y;
+ traps->traps[0].right.p1.x = box->p2.x;
+ traps->traps[0].right.p1.y = box->p1.y;
+ traps->traps[0].right.p2 = box->p2;
+
+ traps->extents = *box;
+
+ return CAIRO_STATUS_SUCCESS;
+}
+
static cairo_status_t
_cairo_traps_add_trap (cairo_traps_t *traps, cairo_fixed_t top, cairo_fixed_t bottom,
cairo_line_t *left, cairo_line_t *right)
Index: cairo.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo.c,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -d -r1.82 -r1.83
--- cairo.c 27 Apr 2005 02:04:48 -0000 1.82
+++ cairo.c 27 Apr 2005 17:16:47 -0000 1.83
@@ -1485,35 +1485,11 @@
void
cairo_paint (cairo_t *cr)
{
- cairo_rectangle_t rectangle;
-
CAIRO_CHECK_SANITY (cr);
if (cr->status)
return;
- cr->status = _cairo_gstate_get_clip_extents (cr->gstate, &rectangle);
- if (cr->status)
- return;
-
- /* Use an indentity matrix, but only while creating the path,
- * since _cairo_gstate_get_clip_extents returns a rectangle in
- * device space. Using an identity matrix simply saves a pair of
- * conversions from device to user space then back again.
- *
- * The identity matrix is not used for the fill so that the source
- * will be properly transformed.
- */
-
- cairo_save (cr);
- cairo_identity_matrix (cr);
-
- cairo_rectangle (cr,
- rectangle.x, rectangle.y,
- rectangle.width, rectangle.height);
-
- cairo_restore (cr);
-
- cairo_fill (cr);
+ cr->status = _cairo_gstate_paint (cr->gstate);
CAIRO_CHECK_SANITY (cr);
}
Index: cairoint.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairoint.h,v
retrieving revision 1.129
retrieving revision 1.130
diff -u -d -r1.129 -r1.130
--- cairoint.h 26 Apr 2005 19:38:06 -0000 1.129
+++ cairoint.h 27 Apr 2005 17:16:47 -0000 1.130
@@ -1049,14 +1049,13 @@
_cairo_gstate_backend_to_user (cairo_gstate_t *gstate, double *x, double *y);
cairo_private cairo_status_t
-_cairo_gstate_stroke (cairo_gstate_t *gstate, cairo_path_fixed_t *path);
+_cairo_gstate_paint (cairo_gstate_t *gstate);
cairo_private cairo_status_t
-_cairo_gstate_fill (cairo_gstate_t *gstate, cairo_path_fixed_t *path);
+_cairo_gstate_stroke (cairo_gstate_t *gstate, cairo_path_fixed_t *path);
cairo_private cairo_status_t
-_cairo_gstate_get_clip_extents (cairo_gstate_t *gstate,
- cairo_rectangle_t *rectangle);
+_cairo_gstate_fill (cairo_gstate_t *gstate, cairo_path_fixed_t *path);
cairo_private cairo_status_t
_cairo_gstate_copy_page (cairo_gstate_t *gstate);
@@ -1615,6 +1614,10 @@
cairo_private void
_cairo_traps_init (cairo_traps_t *traps);
+cairo_private cairo_status_t
+_cairo_traps_init_box (cairo_traps_t *traps,
+ cairo_box_t *box);
+
cairo_private void
_cairo_traps_fini (cairo_traps_t *traps);
More information about the cairo-commit
mailing list