cairo/xrint.h

592 lines
12 KiB
C
Raw Normal View History

2002-06-11 04:02:23 +00:00
/*
* $XFree86: $
*
* Copyright <EFBFBD> 2002 Carl D. Worth
2002-06-11 04:02:23 +00:00
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies
* and that both that copyright notice and this permission notice
* appear in supporting documentation, and that the name of Carl
* D. Worth not be used in advertising or publicity pertaining to
* distribution of the software without specific, written prior
* permission. Carl D. Worth makes no representations about the
* suitability of this software for any purpose. It is provided "as
* is" without express or implied warranty.
2002-06-11 04:02:23 +00:00
*
* CARL D. WORTH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL CARL D. WORTH BE LIABLE FOR ANY SPECIAL,
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
2002-06-11 04:02:23 +00:00
/*
* These definitions are solely for use by the implementation of Xr
* and constitute no kind of standard. If you need any of these
* functions, please drop me a note. Either the library needs new
* functionality, or there's a way to do what you need using the
* existing published interfaces. cworth@isi.edu
*/
#ifndef _XRINT_H_
#define _XRINT_H_
#include <math.h>
2002-07-23 07:22:23 +00:00
#include <X11/Xlibint.h>
2002-06-11 04:02:23 +00:00
#include "Xr.h"
#ifndef __GCC__
#define __attribute__(x)
#endif
/* Sure wish C had a real enum type so that this would be distinct
from XrStatus. Oh well, without that, I'll use this bogus 1000
offset */
typedef enum _XrIntStatus {
XrIntStatusDegenerate = 1000
} XrIntStatus;
typedef enum _XrPathOp {
XrPathOpMoveTo = 0,
XrPathOpLineTo = 1,
XrPathOpCurveTo = 2,
XrPathOpRelMoveTo = 3,
XrPathOpRelLineTo = 4,
XrPathOpRelCurveTo = 5,
XrPathOpClosePath = 6
} __attribute__ ((packed)) XrPathOp; /* Don't want 32 bits if we can avoid it. */
typedef enum _XrPathDirection {
XrPathDirectionForward,
XrPathDirectionReverse
} XrPathDirection;
2002-08-14 18:32:42 +00:00
typedef enum _XrSubPathDone {
XrSubPathDoneCap,
XrSubPathDoneJoin
} XrSubPathDone;
typedef struct _XrPathCallbacks {
XrStatus (*AddEdge)(void *closure, XPointFixed *p1, XPointFixed *p2);
XrStatus (*AddSpline)(void *closure, XPointFixed *a, XPointFixed *b, XPointFixed *c, XPointFixed *d);
XrStatus (*DoneSubPath) (void *closure, XrSubPathDone done);
XrStatus (*DonePath) (void *closure);
} XrPathCallbacks;
#define XR_PATH_BUF_SZ 64
typedef struct _XrPathOpBuf {
int num_ops;
XrPathOp op[XR_PATH_BUF_SZ];
struct _XrPathOpBuf *next, *prev;
} XrPathOpBuf;
typedef struct _XrPathArgBuf {
2002-06-11 04:02:23 +00:00
int num_pts;
XPointFixed pt[XR_PATH_BUF_SZ];
2002-06-11 04:02:23 +00:00
struct _XrPathArgBuf *next, *prev;
} XrPathArgBuf;
2002-06-11 04:02:23 +00:00
typedef struct _XrPath {
XrPathOpBuf *op_head;
XrPathOpBuf *op_tail;
XrPathArgBuf *arg_head;
XrPathArgBuf *arg_tail;
2002-06-11 04:02:23 +00:00
} XrPath;
typedef struct _XrEdge {
XLineFixed edge;
Bool clockWise;
XFixed current_x;
struct _XrEdge *next, *prev;
} XrEdge;
typedef struct _XrPolygon {
int num_edges;
int edges_size;
XrEdge *edges;
XPointFixed first_pt;
int first_pt_defined;
XPointFixed last_pt;
int last_pt_defined;
int closed;
} XrPolygon;
typedef struct _XrSlopeFixed
{
XFixed dx;
XFixed dy;
} XrSlopeFixed;
typedef struct _XrSpline {
XPointFixed a, b, c, d;
XrSlopeFixed initial_slope;
XrSlopeFixed final_slope;
int num_pts;
int pts_size;
XPointFixed *pts;
} XrSpline;
typedef enum _XrPenVertexFlag {
XrPenVertexFlagNone = 0,
XrPenVertexFlagForward = 1,
XrPenVertexFlagReverse = 2
} XrPenVertexFlag;
typedef struct _XrPenFlaggedPoint {
XPointFixed pt;
XrPenVertexFlag flag;
} XrPenFlaggedPoint;
typedef struct _XrPenVertex {
XPointFixed pt;
XrPenVertexFlag flag;
double theta;
XrSlopeFixed slope_ccw;
XrSlopeFixed slope_cw;
} XrPenVertex;
typedef struct _XrPen {
double radius;
double tolerance;
int num_vertices;
XrPenVertex *vertex;
} XrPen;
2002-07-23 07:22:23 +00:00
typedef struct _XrSurface {
2002-06-11 04:02:23 +00:00
Display *dpy;
Drawable drawable;
unsigned int depth;
2002-07-23 07:22:23 +00:00
unsigned long sa_mask;
XcSurfaceAttributes sa;
XcFormat *xcformat;
2002-06-11 04:02:23 +00:00
2002-07-23 07:22:23 +00:00
XcSurface *xcsurface;
XcSurface *alpha;
} XrSurface;
2002-06-11 04:02:23 +00:00
typedef struct _XrColor {
double red;
double green;
double blue;
double alpha;
2002-07-23 07:22:23 +00:00
XcColor xccolor;
2002-06-11 04:02:23 +00:00
} XrColor;
typedef struct _XrTransform {
double m[3][2];
2002-06-11 04:02:23 +00:00
} XrTransform;
2002-07-23 07:22:23 +00:00
typedef struct _XrTraps {
int num_xtraps;
int xtraps_size;
XTrapezoid *xtraps;
} XrTraps;
#define XR_GSTATE_OPERATOR_DEFAULT XrOperatorOver
#define XR_GSTATE_TOLERANCE_DEFAULT 0.1
2002-06-11 04:02:23 +00:00
#define XR_GSTATE_WINDING_DEFAULT 1
#define XR_GSTATE_LINE_WIDTH_DEFAULT 2.0
2002-07-23 07:22:23 +00:00
#define XR_GSTATE_LINE_CAP_DEFAULT XrLineCapButt
#define XR_GSTATE_LINE_JOIN_DEFAULT XrLineJoinMiter
#define XR_GSTATE_MITER_LIMIT_DEFAULT 10.0
2002-06-11 04:02:23 +00:00
typedef struct _XrGState {
Display *dpy;
double tolerance;
/* stroke style */
2002-06-11 04:02:23 +00:00
double line_width;
XrLineCap line_cap;
2002-07-23 07:22:23 +00:00
XrLineJoin line_join;
double *dashes;
int ndashes;
double dash_offset;
2002-07-23 07:22:23 +00:00
double miter_limit;
/* fill style */
int winding;
XrOperator operator;
2002-07-23 07:22:23 +00:00
XcFormat *solidFormat;
XcFormat *alphaFormat;
2002-06-11 04:02:23 +00:00
XrColor color;
2002-07-23 07:22:23 +00:00
XrSurface src;
XrSurface surface;
XrTransform ctm;
XrTransform ctm_inverse;
2002-06-11 04:02:23 +00:00
XrPath path;
XrPen pen_regular;
2002-06-11 04:02:23 +00:00
struct _XrGState *next;
} XrGState;
struct _XrState {
Display *dpy;
XrGState *stack;
XrStatus status;
2002-06-11 04:02:23 +00:00
};
2002-08-14 18:32:42 +00:00
typedef struct _XrStrokeFace {
XPointFixed ccw;
XPointFixed pt;
XPointFixed cw;
XPointDouble vector;
2002-08-14 18:32:42 +00:00
} XrStrokeFace;
typedef struct _XrStroker {
XrGState *gstate;
XrTraps *traps;
2002-08-14 18:32:42 +00:00
int have_prev;
int have_first;
int is_first;
2002-08-14 18:32:42 +00:00
XrStrokeFace prev;
XrStrokeFace first;
int dash_index;
int dash_on;
double dash_remain;
} XrStroker;
typedef struct _XrFiller {
XrGState *gstate;
XrTraps *traps;
XrPolygon polygon;
} XrFiller;
2002-06-11 04:02:23 +00:00
/* xrstate.c */
XrState *
_XrStateCreate(Display *dpy);
2002-06-11 04:02:23 +00:00
XrStatus
_XrStateInit(XrState *state, Display *dpy);
2002-06-11 04:02:23 +00:00
void
_XrStateDeinit(XrState *xrs);
2002-06-11 04:02:23 +00:00
void
_XrStateDestroy(XrState *state);
2002-06-11 04:02:23 +00:00
XrStatus
_XrStatePush(XrState *xrs);
2002-06-11 04:02:23 +00:00
void
_XrStatePop(XrState *xrs);
2002-06-11 04:02:23 +00:00
/* xrgstate.c */
XrGState *
_XrGStateCreate(Display *dpy);
2002-06-11 04:02:23 +00:00
void
_XrGStateInit(XrGState *gstate, Display *dpy);
2002-06-11 04:02:23 +00:00
XrStatus
_XrGStateInitCopy(XrGState *gstate, XrGState *other);
2002-06-11 04:02:23 +00:00
void
_XrGStateDeinit(XrGState *gstate);
2002-06-11 04:02:23 +00:00
void
_XrGStateDestroy(XrGState *gstate);
2002-06-11 04:02:23 +00:00
XrGState *
_XrGStateClone(XrGState *gstate);
2002-06-11 04:02:23 +00:00
void
_XrGStateSetDrawable(XrGState *gstate, Drawable drawable);
void
_XrGStateSetVisual(XrGState *gstate, Visual *visual);
void
_XrGStateSetFormat(XrGState *gstate, XrFormat format);
2002-06-11 04:02:23 +00:00
void
_XrGStateSetOperator(XrGState *gstate, XrOperator operator);
2002-07-23 07:22:23 +00:00
void
_XrGStateSetRGBColor(XrGState *gstate, double red, double green, double blue);
2002-06-11 04:02:23 +00:00
void
_XrGStateSetTolerance(XrGState *gstate, double tolerance);
2002-06-11 04:02:23 +00:00
void
_XrGStateSetAlpha(XrGState *gstate, double alpha);
2002-06-11 04:02:23 +00:00
void
_XrGStateSetLineWidth(XrGState *gstate, double width);
2002-06-11 04:02:23 +00:00
2002-07-23 07:22:23 +00:00
void
_XrGStateSetLineCap(XrGState *gstate, XrLineCap line_cap);
2002-07-23 07:22:23 +00:00
void
_XrGStateSetLineJoin(XrGState *gstate, XrLineJoin line_join);
2002-07-23 07:22:23 +00:00
XrStatus
_XrGStateSetDash(XrGState *gstate, double *dashes, int ndash, double offset);
2002-07-23 07:22:23 +00:00
void
_XrGStateSetMiterLimit(XrGState *gstate, double limit);
2002-07-23 07:22:23 +00:00
2002-06-11 04:02:23 +00:00
void
_XrGStateTranslate(XrGState *gstate, double tx, double ty);
2002-06-11 04:02:23 +00:00
void
_XrGStateScale(XrGState *gstate, double sx, double sy);
2002-06-11 04:02:23 +00:00
void
_XrGStateRotate(XrGState *gstate, double angle);
2002-06-11 04:02:23 +00:00
void
_XrGStateConcatMatrix(XrGState *gstate,
double a, double b,
double c, double d,
double tx, double ty);
2002-06-11 04:02:23 +00:00
void
_XrGStateNewPath(XrGState *gstate);
2002-06-11 04:02:23 +00:00
XrStatus
_XrGStateAddPathOp(XrGState *gstate, XrPathOp op, XPointDouble *pt, int num_pts);
XrStatus
_XrGStateAddUnaryPathOp(XrGState *gstate, XrPathOp op, double x, double y);
2002-06-11 04:02:23 +00:00
XrStatus
_XrGStateClosePath(XrGState *gstate);
2002-06-11 04:02:23 +00:00
XrStatus
_XrGStateStroke(XrGState *gstate);
2002-06-11 04:02:23 +00:00
XrStatus
_XrGStateFill(XrGState *fill);
2002-06-11 04:02:23 +00:00
/* xrcolor.c */
void
_XrColorInit(XrColor *color);
2002-06-11 04:02:23 +00:00
void
_XrColorDeinit(XrColor *color);
2002-06-11 04:02:23 +00:00
void
_XrColorSetRGB(XrColor *color, double red, double green, double blue);
2002-06-11 04:02:23 +00:00
void
_XrColorSetAlpha(XrColor *color, double alpha);
2002-06-11 04:02:23 +00:00
/* xrpath.c */
void
_XrPathInit(XrPath *path);
2002-06-11 04:02:23 +00:00
XrStatus
_XrPathInitCopy(XrPath *path, XrPath *other);
2002-06-11 04:02:23 +00:00
void
_XrPathDeinit(XrPath *path);
2002-06-11 04:02:23 +00:00
XrStatus
_XrPathAdd(XrPath *path, XrPathOp op, XPointFixed *pts, int num_pts);
2002-06-11 04:02:23 +00:00
XrStatus
_XrPathInterpret(XrPath *path, XrPathDirection dir, XrPathCallbacks *cb, void *closure);
2002-06-11 04:02:23 +00:00
/* xrsurface.c */
2002-06-11 04:02:23 +00:00
void
_XrSurfaceInit(XrSurface *surface, Display *dpy);
2002-06-11 04:02:23 +00:00
void
_XrSurfaceDeinit(XrSurface *surface);
2002-06-11 04:02:23 +00:00
void
_XrSurfaceSetSolidColor(XrSurface *surface, XrColor *color, XcFormat *xcformat);
2002-06-11 04:02:23 +00:00
void
_XrSurfaceSetDrawable(XrSurface *surface, Drawable drawable);
2002-06-11 04:02:23 +00:00
void
_XrSurfaceSetVisual(XrSurface *surface, Visual *visual);
2002-06-11 04:02:23 +00:00
void
_XrSurfaceSetFormat(XrSurface *surface, XrFormat format);
2002-06-11 04:02:23 +00:00
/* xrpen.c */
XrStatus
_XrPenInit(XrPen *pen, double radius, XrGState *gstate);
XrStatus
_XrPenInitEmpty(XrPen *pen);
XrStatus
_XrPenInitCopy(XrPen *pen, XrPen *other);
void
_XrPenDeinit(XrPen *pen);
XrStatus
_XrPenAddPoints(XrPen *pen, XrPenFlaggedPoint *pt, int num_pts);
XrStatus
_XrPenAddPointsForSlopes(XrPen *pen, XPointFixed *a, XPointFixed *b, XPointFixed *c, XPointFixed *d);
XrStatus
_XrPenStrokeSpline(XrPen *pen, XrSpline *spline, double tolerance, XrTraps *traps);
/* xrpolygon.c */
2002-06-11 04:02:23 +00:00
void
_XrPolygonInit(XrPolygon *polygon);
2002-06-11 04:02:23 +00:00
void
_XrPolygonDeinit(XrPolygon *polygon);
2002-06-11 04:02:23 +00:00
XrStatus
_XrPolygonAddEdge(XrPolygon *polygon, XPointFixed *p1, XPointFixed *p2);
XrStatus
_XrPolygonAddPoint(XrPolygon *polygon, XPointFixed *pt);
XrStatus
_XrPolygonClose(XrPolygon *polygon);
/* xrspline.c */
XrIntStatus
_XrSplineInit(XrSpline *spline, XPointFixed *a, XPointFixed *b, XPointFixed *c, XPointFixed *d);
2002-06-11 04:02:23 +00:00
XrStatus
_XrSplineDecompose(XrSpline *spline, double tolerance);
void
_XrSplineDeinit(XrSpline *spline);
/* xrstroker.c */
2002-06-11 04:02:23 +00:00
void
_XrStrokerInit(XrStroker *stroker, XrGState *gstate, XrTraps *traps);
void
_XrStrokerDeinit(XrStroker *stroker);
XrStatus
_XrStrokerAddEdge(void *closure, XPointFixed *p1, XPointFixed *p2);
2002-06-11 04:02:23 +00:00
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);
2002-08-14 18:32:42 +00:00
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);
2002-06-11 04:02:23 +00:00
/* xrtransform.c */
void
_XrTransformInit(XrTransform *transform);
2002-06-11 04:02:23 +00:00
void
_XrTransformDeinit(XrTransform *transform);
2002-06-11 04:02:23 +00:00
void
_XrTransformInitMatrix(XrTransform *transform,
double a, double b,
double c, double d,
double tx, double ty);
2002-06-11 04:02:23 +00:00
void
_XrTransformInitTranslate(XrTransform *transform,
double tx, double ty);
2002-06-11 04:02:23 +00:00
void
_XrTransformInitScale(XrTransform *transform,
double sx, double sy);
2002-06-11 04:02:23 +00:00
void
_XrTransformInitRotate(XrTransform *transform,
double angle);
2002-06-11 04:02:23 +00:00
void
_XrTransformMultiplyIntoLeft(XrTransform *t1, const XrTransform *t2);
void
_XrTransformMultiplyIntoRight(const XrTransform *t1, XrTransform *t2);
void
_XrTransformMultiply(const XrTransform *t1, const XrTransform *t2, XrTransform *new);
2002-06-11 04:02:23 +00:00
void
_XrTransformDistance(XrTransform *transform, XPointDouble *pt);
2002-06-11 04:02:23 +00:00
void
_XrTransformPoint(XrTransform *transform, XPointDouble *pt);
2002-06-11 04:02:23 +00:00
void
_XrTransformComputeInverse(XrTransform *transform);
2002-06-11 04:02:23 +00:00
void
_XrTransformEigenValues(XrTransform *transform, double *lambda1, double *lambda2);
2002-07-23 07:22:23 +00:00
/* xrtraps.c */
void
_XrTrapsInit(XrTraps *traps);
2002-07-23 07:22:23 +00:00
void
_XrTrapsDeinit(XrTraps *traps);
2002-07-23 07:22:23 +00:00
XrStatus
_XrTrapsTessellateRectangle (XrTraps *traps, XPointFixed q[4]);
2002-07-23 07:22:23 +00:00
XrStatus
_XrTrapsTessellatePolygon (XrTraps *traps, XrPolygon *poly, int winding);
2002-07-23 07:22:23 +00:00
/* xrmisc.c */
void
_ComputeSlope(XPointFixed *a, XPointFixed *b, XrSlopeFixed *slope);
2002-06-11 04:02:23 +00:00
#endif
2002-07-23 07:22:23 +00:00