[ART_HACK] libart patch
- From: Alex Larsson <alexl redhat com>
- To: <libart-hackers gnome org>, <raph acm org>, <gnome-libs-devel gnome org>
- Subject: [ART_HACK] libart patch
- Date: Fri, 16 Nov 2001 12:24:13 -0500 (EST)
art_drect_svp() and art_drect_svp_union() are broken for svps that only
contain segments that are "empty" accoding to art_drect_empty(). This is
true for i.e. rectangles. Since the bboxes of the segments either have
zero width or zero height the resultant union bbox is empty.
I will commit the attached patch to cvs that sort of fixes this for some
cases, but in general the way libart handles empty rects is pretty
broken. If your're using libart, please review your usage of
art_drect_svp(), art_drect_svp_union(), art_drect_empty() and
art_drect_union().
/ Alex
Index: art_rect_svp.c
===================================================================
RCS file: /cvs/gnome/libart_lgpl/art_rect_svp.c,v
retrieving revision 1.3
diff -u -p -r1.3 art_rect_svp.c
--- art_rect_svp.c 1999/09/01 07:04:21 1.3
+++ art_rect_svp.c 2001/11/16 17:03:49
@@ -22,6 +22,14 @@
#include "art_rect.h"
#include "art_rect_svp.h"
+#ifndef MAX
+#define MAX(a, b) (((a) > (b)) ? (a) : (b))
+#endif /* MAX */
+
+#ifndef MIN
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#endif /* MIN */
+
/**
* art_drect_svp: Find the bounding box of a sorted vector path.
* @bbox: Where to store the bounding box.
@@ -34,14 +42,23 @@ art_drect_svp (ArtDRect *bbox, const Art
{
int i;
- bbox->x0 = 0;
- bbox->y0 = 0;
- bbox->x1 = 0;
- bbox->y1 = 0;
+ if (svp->n_segs == 0)
+ {
+ bbox->x0 = 0;
+ bbox->y0 = 0;
+ bbox->x1 = 0;
+ bbox->y1 = 0;
+ return;
+ }
- for (i = 0; i < svp->n_segs; i++)
+ art_drect_copy (bbox, &svp->segs[0].bbox);
+
+ for (i = 1; i < svp->n_segs; i++)
{
- art_drect_union (bbox, bbox, &svp->segs[i].bbox);
+ bbox->x0 = MIN (bbox->x0, svp->segs[i].bbox.x0);
+ bbox->y0 = MIN (bbox->y0, svp->segs[i].bbox.y0);
+ bbox->x1 = MAX (bbox->x1, svp->segs[i].bbox.x1);
+ bbox->y1 = MAX (bbox->y1, svp->segs[i].bbox.y1);
}
}
@@ -56,10 +73,8 @@ art_drect_svp (ArtDRect *bbox, const Art
void
art_drect_svp_union (ArtDRect *bbox, const ArtSVP *svp)
{
- int i;
+ ArtDRect svp_bbox;
- for (i = 0; i < svp->n_segs; i++)
- {
- art_drect_union (bbox, bbox, &svp->segs[i].bbox);
- }
+ art_drect_svp (&svp_bbox, svp);
+ art_drect_union (bbox, bbox, &svp_bbox);
}
[Date Prev][Date Next] [Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]