[Commit] Xr/src xrpathbounds.c,NONE,1.1 xrpathfill.c,NONE,1.1 xrpathstroke.c,NONE,1.1 Makefile.am,1.3,1.4 xrgstate.c,1.30,1.31 xrint.h,1.36,1.37 xrpath.c,1.15,1.16
Carl Worth
commit@keithp.com
Mon, 12 May 2003 09:24:20 -0700
Committed by: cworth
Update of /local/src/CVS/Xr/src
In directory home.keithp.com:/tmp/cvs-serv13928/src
Modified Files:
Makefile.am xrgstate.c xrint.h xrpath.c
Added Files:
xrpathbounds.c xrpathfill.c xrpathstroke.c
Log Message:
XrStroke and XrFill now both go through the same clipping.
Cleaned up the three path interpreters (stroke, fill, and bounds), to each be in their own
files
--- NEW FILE: xrpathbounds.c ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: xrpathfill.c ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: xrpathstroke.c ---
(This appears to be a binary file; contents omitted.)
Index: Makefile.am
===================================================================
RCS file: /local/src/CVS/Xr/src/Makefile.am,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Makefile.am 2 May 2003 21:07:42 -0000 1.3
+++ Makefile.am 12 May 2003 16:24:17 -0000 1.4
@@ -6,16 +6,17 @@
xr.c \
xrint.h \
xrcolor.c \
- xrfiller.c \
xrfont.c \
xrgstate.c \
xrmisc.c \
xrpath.c \
+ xrpathbounds.c \
+ xrpathfill.c \
+ xrpathstroke.c \
xrpen.c \
xrpolygon.c \
xrspline.c \
xrstate.c \
- xrstroker.c \
xrsurface.c \
xrtransform.c \
xrtraps.c
Index: xrgstate.c
===================================================================
RCS file: /local/src/CVS/Xr/src/xrgstate.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- xrgstate.c 1 May 2003 15:18:25 -0000 1.30
+++ xrgstate.c 12 May 2003 16:24:17 -0000 1.31
@@ -32,7 +32,11 @@
_XrGStateSetCurrentPt(XrGState *gstate, double x, double y);
static XrStatus
-_XrGStateFillToSurface(XrGState *gstate, XrSurface *src, XrSurface *dst);
+_XrGStateClipAndCompositeTrapezoids(XrGState *gstate,
+ XrSurface *src,
+ XrOperator operator,
+ XrSurface *dst,
+ XrTraps *traps);
XrGState *
_XrGStateCreate()
@@ -717,36 +721,38 @@
{
XrStatus status;
- static XrPathCallbacks cb = {
- _XrStrokerAddEdge,
- _XrStrokerAddSpline,
- _XrStrokerDoneSubPath,
- _XrStrokerDonePath
- };
-
- static XrPathCallbacks cb_dash = {
- _XrStrokerAddEdgeDashed,
- _XrStrokerAddSpline,
- _XrStrokerDoneSubPath,
- _XrStrokerDonePath
- };
- XrPathCallbacks *cbs = gstate->dash ? &cb_dash : &cb;
-
- XrStroker stroker;
XrTraps traps;
_XrPenInit(&gstate->pen_regular, gstate->line_width / 2.0, gstate);
_XrTrapsInit(&traps);
- _XrStrokerInit(&stroker, gstate, &traps);
- status = _XrPathInterpret(&gstate->path, XrPathDirectionForward, cbs, &stroker);
+ status = _XrPathStrokeToTraps(&gstate->path, gstate, &traps);
if (status) {
- _XrStrokerDeinit(&stroker);
_XrTrapsDeinit(&traps);
return status;
}
+ _XrGStateClipAndCompositeTrapezoids(gstate,
+ gstate->pattern ? gstate->pattern : gstate->solid,
+ gstate->operator,
+ gstate->surface,
+ &traps);
+
+ _XrTrapsDeinit(&traps);
+
+ _XrGStateNewPath(gstate);
+
+ return XrStatusSuccess;
+}
+
+static XrStatus
+_XrGStateClipAndCompositeTrapezoids(XrGState *gstate,
+ XrSurface *src,
+ XrOperator operator,
+ XrSurface *dst,
+ XrTraps *traps)
+{
if (gstate->clip.surface) {
XrSurface *intermediate, *white;
@@ -763,18 +769,18 @@
white->xc_surface,
intermediate->xc_surface,
0, 0,
- traps.xtraps,
- traps.num_xtraps);
+ traps->xtraps,
+ traps->num_xtraps);
XcComposite(XrOperatorIn,
gstate->clip.surface->xc_surface,
NULL,
intermediate->xc_surface,
0, 0, 0, 0, 0, 0,
gstate->clip.width, gstate->clip.height);
- XcComposite(gstate->operator,
- gstate->pattern ? gstate->pattern->xc_surface : gstate->solid->xc_surface,
+ XcComposite(operator,
+ src->xc_surface,
intermediate->xc_surface,
- gstate->surface->xc_surface,
+ dst->xc_surface,
0, 0,
0, 0,
0, 0,
@@ -785,27 +791,40 @@
} else {
XcCompositeTrapezoids(gstate->operator,
- gstate->pattern ? gstate->pattern->xc_surface : gstate->solid->xc_surface,
- gstate->surface->xc_surface,
+ src->xc_surface,
+ dst->xc_surface,
0, 0,
- traps.xtraps,
- traps.num_xtraps);
+ traps->xtraps,
+ traps->num_xtraps);
}
- _XrStrokerDeinit(&stroker);
- _XrTrapsDeinit(&traps);
-
- _XrGStateNewPath(gstate);
-
return XrStatusSuccess;
}
XrStatus
_XrGStateFill(XrGState *gstate)
{
- return _XrGStateFillToSurface(gstate,
- gstate->pattern ? gstate->pattern : gstate->solid,
- gstate->surface);
+ XrStatus status;
+ XrTraps traps;
+
+ _XrTrapsInit(&traps);
+
+ status = _XrPathFillToTraps(&gstate->path, gstate, &traps);
+ if (status) {
+ _XrTrapsDeinit(&traps);
+ return status;
+ }
+
+ _XrGStateClipAndCompositeTrapezoids(gstate,
+ gstate->pattern ? gstate->pattern : gstate->solid,
+ gstate->operator,
+ gstate->surface,
+ &traps);
+ _XrTrapsDeinit(&traps);
+
+ _XrGStateNewPath(gstate);
+
+ return XrStatusSuccess;
}
XrStatus
@@ -813,6 +832,7 @@
{
XrStatus status;
XrSurface *alpha_one;
+ XrTraps traps;
if (gstate->clip.surface == NULL) {
double x1, y1, x2, y2;
@@ -822,12 +842,11 @@
gstate->clip.y = floor(y1);
gstate->clip.width = ceil(x2 - gstate->clip.x);
gstate->clip.height = ceil(y2 - gstate->clip.y);
- /* XXX: Should be able to make this work with XrFormatA8 */
gstate->clip.surface = XrSurfaceCreateNextToSolid(gstate->surface,
XrFormatA8,
gstate->clip.width,
gstate->clip.height,
- 0.0, 0.0, 0.0, 0.0);
+ 1.0, 1.0, 1.0, 1.0);
}
alpha_one = XrSurfaceCreateNextToSolid(gstate->surface, XrFormatA8,
@@ -835,50 +854,24 @@
0.0, 0.0, 0.0, 1.0);
XrSurfaceSetRepeat(alpha_one, 1);
- status = _XrGStateFillToSurface(gstate, alpha_one, gstate->clip.surface);
-
- XrSurfaceDestroy (alpha_one);
-
- return status;
-}
-
-static XrStatus
-_XrGStateFillToSurface(XrGState *gstate, XrSurface *src, XrSurface *dst)
-{
- XrStatus status;
- static XrPathCallbacks cb = {
- _XrFillerAddEdge,
- _XrFillerAddSpline,
- _XrFillerDoneSubPath,
- _XrFillerDonePath
- };
-
- XrFiller filler;
- XrTraps traps;
-
_XrTrapsInit(&traps);
- _XrFillerInit(&filler, gstate, &traps);
-
- status = _XrPathInterpret(&gstate->path, XrPathDirectionForward, &cb, &filler);
+ status = _XrPathFillToTraps(&gstate->path, gstate, &traps);
if (status) {
- _XrFillerDeinit(&filler);
_XrTrapsDeinit(&traps);
return status;
}
- XcCompositeTrapezoids(gstate->operator,
- src->xc_surface,
- dst->xc_surface,
- 0, 0,
- traps.xtraps,
- traps.num_xtraps);
+ _XrGStateClipAndCompositeTrapezoids(gstate,
+ alpha_one,
+ XrOperatorIn,
+ gstate->clip.surface,
+ &traps);
- _XrFillerDeinit(&filler);
_XrTrapsDeinit(&traps);
- _XrGStateNewPath(gstate);
+ XrSurfaceDestroy (alpha_one);
- return XrStatusSuccess;
+ return status;
}
XrStatus
@@ -947,6 +940,7 @@
/* XXX: Need to abandon Xft and use Xc instead */
/* (until I do, this call will croak on IcImage XrSurfaces */
+ /* (also, this means text clipping isn't working. Basically text is broken.) */
XftTextRenderUtf8(gstate->surface->dpy,
gstate->operator,
_XrSurfaceGetPicture (gstate->solid),
Index: xrint.h
===================================================================
RCS file: /local/src/CVS/Xr/src/xrint.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- xrint.h 1 May 2003 15:18:25 -0000 1.36
+++ xrint.h 12 May 2003 16:24:17 -0000 1.37
@@ -51,15 +51,6 @@
XrIntStatusDegenerate = 1000
} XrIntStatus;
-typedef struct _XrPathBounder {
- int has_pt;
-
- XFixed min_x;
- XFixed min_y;
- XFixed max_x;
- XFixed max_y;
-} XrPathBounder;
-
typedef enum _XrPathOp {
XrPathOpMoveTo = 0,
XrPathOpLineTo = 1,
@@ -283,27 +274,6 @@
XPointDouble usr_vector;
} XrStrokeFace;
-typedef struct _XrStroker {
- XrGState *gstate;
- XrTraps *traps;
-
- int have_prev;
- int have_first;
- int is_first;
- XrStrokeFace prev;
- XrStrokeFace first;
- int dash_index;
- int dash_on;
- double dash_remain;
-} XrStroker;
-
-typedef struct _XrFiller {
- XrGState *gstate;
- XrTraps *traps;
-
- XrPolygon polygon;
-} XrFiller;
-
/* xrstate.c */
XrState *
@@ -597,11 +567,21 @@
_XrPathClosePath(XrPath *path);
XrStatus
-_XrPathInterpret(XrPath *path, XrPathDirection dir, XrPathCallbacks *cb, void *closure);
+_XrPathInterpret(XrPath *path, XrPathDirection dir, const XrPathCallbacks *cb, void *closure);
XrStatus
_XrPathBounds(XrPath *path, double *x1, double *y1, double *x2, double *y2);
+/* xrpathfill.c */
+
+XrStatus
+_XrPathFillToTraps(XrPath *path, XrGState *gstate, XrTraps *traps);
+
+/* xrpathstroke.c */
+
+XrStatus
+_XrPathStrokeToTraps (XrPath *path, XrGState *gstate, XrTraps *traps);
+
/* xrsurface.c */
void
@@ -680,47 +660,6 @@
void
_XrSplineDeinit(XrSpline *spline);
-/* xrstroker.c */
-void
-_XrStrokerInit(XrStroker *stroker, XrGState *gstate, XrTraps *traps);
-
-void
-_XrStrokerDeinit(XrStroker *stroker);
-
-XrStatus
-_XrStrokerAddEdge(void *closure, XPointFixed *p1, XPointFixed *p2);
-
-XrStatus
-_XrStrokerAddEdgeDashed(void *closure, XPointFixed *p1, XPointFixed *p2);
-
-XrStatus
-_XrStrokerAddSpline (void *closure, XPointFixed *a, XPointFixed *b, XPointFixed *c, XPointFixed *d);
-
-XrStatus
-_XrStrokerDoneSubPath (void *closure, XrSubPathDone done);
-
-XrStatus
-_XrStrokerDonePath (void *closure);
-
-/* xrfiller.c */
-void
-_XrFillerInit(XrFiller *filler, XrGState *gstate, XrTraps *traps);
-
-void
-_XrFillerDeinit(XrFiller *filler);
-
-XrStatus
-_XrFillerAddEdge(void *closure, XPointFixed *p1, XPointFixed *p2);
-
-XrStatus
-_XrFillerAddSpline (void *closure, XPointFixed *a, XPointFixed *b, XPointFixed *c, XPointFixed *d);
-
-XrStatus
-_XrFillerDoneSubPath (void *closure, XrSubPathDone done);
-
-XrStatus
-_XrFillerDonePath (void *closure);
-
/* xrtransform.c */
void
_XrTransformInitIdentity(XrTransform *transform);
Index: xrpath.c
===================================================================
RCS file: /local/src/CVS/Xr/src/xrpath.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- xrpath.c 1 May 2003 15:18:25 -0000 1.15
+++ xrpath.c 12 May 2003 16:24:17 -0000 1.16
@@ -60,28 +60,6 @@
static void
_XrPathArgBufAdd(XrPathArgBuf *arg, XPointFixed *pts, int num_pts);
-static void
-_XrPathBounderInit(XrPathBounder *bounder);
-
-static void
-_XrPathBounderDeinit(XrPathBounder *bounder);
-
-static XrStatus
-_XrPathBounderAddPoint(XrPathBounder *bounder, XPointFixed *pt);
-
-static XrStatus
-_XrPathBounderAddEdge(void *closure, XPointFixed *p1, XPointFixed *p2);
-
-static XrStatus
-_XrPathBounderAddSpline(void *closure,
- XPointFixed *a, XPointFixed *b, XPointFixed *c, XPointFixed *d);
-
-static XrStatus
-_XrPathBounderDoneSubPath(void *closure, XrSubPathDone done);
-
-static XrStatus
-_XrPathBounderDonePath(void *closure);
-
void
_XrPathInit(XrPath *path)
{
@@ -340,7 +318,7 @@
};
XrStatus
-_XrPathInterpret(XrPath *path, XrPathDirection dir, XrPathCallbacks *cb, void *closure)
+_XrPathInterpret(XrPath *path, XrPathDirection dir, const XrPathCallbacks *cb, void *closure)
{
XrStatus status;
int i, arg;
@@ -453,112 +431,4 @@
return (*cb->DonePath)(closure);
}
-static void
-_XrPathBounderInit(XrPathBounder *bounder)
-{
- bounder->has_pt = 0;
-}
-
-static void
-_XrPathBounderDeinit(XrPathBounder *bounder)
-{
- bounder->has_pt = 0;
-}
-
-static XrStatus
-_XrPathBounderAddPoint(XrPathBounder *bounder, XPointFixed *pt)
-{
- if (bounder->has_pt) {
- if (pt->x < bounder->min_x)
- bounder->min_x = pt->x;
-
- if (pt->y < bounder->min_y)
- bounder->min_y = pt->y;
-
- if (pt->x > bounder->max_x)
- bounder->max_x = pt->x;
-
- if (pt->y > bounder->max_y)
- bounder->max_y = pt->y;
- } else {
- bounder->min_x = pt->x;
- bounder->min_y = pt->y;
- bounder->max_x = pt->x;
- bounder->max_y = pt->y;
-
- bounder->has_pt = 1;
- }
-
- return XrStatusSuccess;
-}
-
-static XrStatus
-_XrPathBounderAddEdge(void *closure, XPointFixed *p1, XPointFixed *p2)
-{
- XrPathBounder *bounder = closure;
-
- _XrPathBounderAddPoint(bounder, p1);
- _XrPathBounderAddPoint(bounder, p2);
-
- return XrStatusSuccess;
-}
-
-static XrStatus
-_XrPathBounderAddSpline(void *closure,
- XPointFixed *a, XPointFixed *b, XPointFixed *c, XPointFixed *d)
-{
- XrPathBounder *bounder = closure;
-
- _XrPathBounderAddPoint(bounder, a);
- _XrPathBounderAddPoint(bounder, b);
- _XrPathBounderAddPoint(bounder, c);
- _XrPathBounderAddPoint(bounder, d);
-
- return XrStatusSuccess;
-}
-
-static XrStatus
-_XrPathBounderDoneSubPath(void *closure, XrSubPathDone done)
-{
- return XrStatusSuccess;
-}
-
-static XrStatus
-_XrPathBounderDonePath(void *closure)
-{
- return XrStatusSuccess;
-}
-
-/* XXX: Perhaps this should compute a PixRegion rather than 4 doubles */
-XrStatus
-_XrPathBounds(XrPath *path, double *x1, double *y1, double *x2, double *y2)
-{
- XrStatus status;
- static XrPathCallbacks cb = {
- _XrPathBounderAddEdge,
- _XrPathBounderAddSpline,
- _XrPathBounderDoneSubPath,
- _XrPathBounderDonePath
- };
-
- XrPathBounder bounder;
-
- _XrPathBounderInit(&bounder);
-
- status = _XrPathInterpret(path, XrPathDirectionForward, &cb, &bounder);
- if (status) {
- *x1 = *y1 = *x2 = *y2 = 0.0;
- _XrPathBounderDeinit(&bounder);
- return status;
- }
-
- *x1 = XFixedToDouble(bounder.min_x);
- *y1 = XFixedToDouble(bounder.min_y);
- *x2 = XFixedToDouble(bounder.max_x);
- *y2 = XFixedToDouble(bounder.max_y);
-
- _XrPathBounderDeinit(&bounder);
-
- return XrStatusSuccess;
-}