[cairo-commit] goocanvas/src goocanvasitemsimple.c,1.30,1.31
Damon Chaplin
commit at pdx.freedesktop.org
Mon Apr 16 06:40:09 PDT 2007
- Previous message: [cairo-commit] cairomm/cairomm Makefile.am, 1.5,
1.6 quartz_surface.cc, NONE, 1.1 quartz_surface.h, NONE,
1.1 surface.h, 1.18, 1.19
- Next message: [cairo-commit] goocanvas ChangeLog,1.106,1.107
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: damon
Update of /cvs/cairo/goocanvas/src
In directory kemper:/tmp/cvs-serv14537/src
Modified Files:
goocanvasitemsimple.c
Log Message:
2007-04-16 Damon Chaplin <damon at gnome.org>
* src/goocanvasitemsimple.c (goo_canvas_item_simple_get_path_bounds):
handle empty bounds for an item's fill or stroke. cairo 1.4.x returns
0.0 for x1/y1/x2/y2 in that case, though older versions of cairo
returned odd values. So I've added a workaround for that as well.
Index: goocanvasitemsimple.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemsimple.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- goocanvasitemsimple.c 3 Apr 2007 09:58:05 -0000 1.30
+++ goocanvasitemsimple.c 16 Apr 2007 13:40:00 -0000 1.31
@@ -1517,37 +1517,66 @@
GooCanvasBounds *bounds)
{
GooCanvasStyle *style = item->simple_data->style;
- GooCanvasBounds tmp_bounds, tmp_bounds2;
+ GooCanvasBounds fill_bounds, stroke_bounds;
/* Calculate the filled extents. */
goo_canvas_style_set_fill_options (style, cr);
- cairo_fill_extents (cr, &tmp_bounds.x1, &tmp_bounds.y1,
- &tmp_bounds.x2, &tmp_bounds.y2);
+ cairo_fill_extents (cr, &fill_bounds.x1, &fill_bounds.y1,
+ &fill_bounds.x2, &fill_bounds.y2);
/* Check the stroke. */
goo_canvas_style_set_stroke_options (style, cr);
- cairo_stroke_extents (cr, &tmp_bounds2.x1, &tmp_bounds2.y1,
- &tmp_bounds2.x2, &tmp_bounds2.y2);
+ cairo_stroke_extents (cr, &stroke_bounds.x1, &stroke_bounds.y1,
+ &stroke_bounds.x2, &stroke_bounds.y2);
- /* FIXME: Handle whatever cairo returns for NULL bounds. Cairo starts with
- INT16_MAX << 16 in cairo-traps.c, but this may get converted to user
- space so could be anything? cairo 1.4 handles this better, I think. */
+ /* Workaround for cairo < 1.4.0. It used to just return odd values
+ if the path had empty bounds. This fix will work, but only if there is
+ no transform currently set, since cairo will convert to user space. */
+ if (cairo_version () < CAIRO_VERSION_ENCODE (1, 4, 0))
+ {
+ if (fill_bounds.x1 == 32767.0 && fill_bounds.x2 == -32768.0)
+ fill_bounds.x1 = fill_bounds.x2 = 0.0;
+ if (stroke_bounds.x1 == 32767.0 && stroke_bounds.x2 == -32768.0)
+ stroke_bounds.x1 = stroke_bounds.x2 = 0.0;
+ }
- bounds->x1 = MIN (tmp_bounds.x1, tmp_bounds.x2);
- bounds->x1 = MIN (bounds->x1, tmp_bounds2.x1);
- bounds->x1 = MIN (bounds->x1, tmp_bounds2.x2);
+ if (fill_bounds.x1 == 0.0 && fill_bounds.x2 == 0.0)
+ {
+ /* The fill bounds are empty so just use the stroke bounds.
+ If the stroke bounds are also empty the bounds will be all 0.0. */
+ bounds->x1 = MIN (stroke_bounds.x1, stroke_bounds.x2);
+ bounds->x2 = MAX (stroke_bounds.x1, stroke_bounds.x2);
+ bounds->y1 = MIN (stroke_bounds.y1, stroke_bounds.y2);
+ bounds->y2 = MAX (stroke_bounds.y1, stroke_bounds.y2);
+ }
+ else if (stroke_bounds.x1 == 0.0 && stroke_bounds.x2 == 0.0)
+ {
+ /* The stroke bounds are empty so just use the fill bounds. */
+ bounds->x1 = MIN (fill_bounds.x1, fill_bounds.x2);
+ bounds->x2 = MAX (fill_bounds.x1, fill_bounds.x2);
+ bounds->y1 = MIN (fill_bounds.y1, fill_bounds.y2);
+ bounds->y2 = MAX (fill_bounds.y1, fill_bounds.y2);
+ }
+ else
+ {
+ /* Both fill & stoke bounds are non-empty so combine them. */
+ bounds->x1 = MIN (fill_bounds.x1, fill_bounds.x2);
+ bounds->x2 = MAX (fill_bounds.x1, fill_bounds.x2);
+ bounds->y1 = MIN (fill_bounds.y1, fill_bounds.y2);
+ bounds->y2 = MAX (fill_bounds.y1, fill_bounds.y2);
- bounds->x2 = MAX (tmp_bounds.x1, tmp_bounds.x2);
- bounds->x2 = MAX (bounds->x2, tmp_bounds2.x1);
- bounds->x2 = MAX (bounds->x2, tmp_bounds2.x2);
+ bounds->x1 = MIN (bounds->x1, stroke_bounds.x1);
+ bounds->x1 = MIN (bounds->x1, stroke_bounds.x2);
- bounds->y1 = MIN (tmp_bounds.y1, tmp_bounds.y2);
- bounds->y1 = MIN (bounds->y1, tmp_bounds2.y1);
- bounds->y1 = MIN (bounds->y1, tmp_bounds2.y2);
+ bounds->x2 = MAX (bounds->x2, stroke_bounds.x1);
+ bounds->x2 = MAX (bounds->x2, stroke_bounds.x2);
- bounds->y2 = MAX (tmp_bounds.y1, tmp_bounds.y2);
- bounds->y2 = MAX (bounds->y2, tmp_bounds2.y1);
- bounds->y2 = MAX (bounds->y2, tmp_bounds2.y2);
+ bounds->y1 = MIN (bounds->y1, stroke_bounds.y1);
+ bounds->y1 = MIN (bounds->y1, stroke_bounds.y2);
+
+ bounds->y2 = MAX (bounds->y2, stroke_bounds.y1);
+ bounds->y2 = MAX (bounds->y2, stroke_bounds.y2);
+ }
}
- Previous message: [cairo-commit] cairomm/cairomm Makefile.am, 1.5,
1.6 quartz_surface.cc, NONE, 1.1 quartz_surface.h, NONE,
1.1 surface.h, 1.18, 1.19
- Next message: [cairo-commit] goocanvas ChangeLog,1.106,1.107
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the cairo-commit
mailing list