[Cairo] Re: [Xr] Cairo
Trevor Woerner
xwin641 at vtnet.ca
Thu Jul 17 20:10:50 PDT 2003
On July 15, 2003 03:12 pm, Carl Worth wrote:
> None of the code has changed yet, but when it does, I'll also provide
> some scripts to simplify the effort to shift existing code from the
> old names to the new.
I humbly submit the attached python script to perform the
above-mentioned conversion. It's not perfect (see what it does with
identifiers that have "RGB" in them! :-) but it's a start.
I've also included a diff of Xr.h after running the script on it so you
can see for yourself. I hope you find it useful.
Trevor
--- Xr.h 2003-07-17 02:49:52.000000000 -0400
+++ out.h 2003-07-17 23:03:24.000000000 -0400
@@ -28,356 +28,356 @@
#include <Xc.h>
-typedef struct _XrState XrState;
-typedef struct _XrSurface XrSurface;
-typedef struct _XrMatrix XrMatrix;
+typedef struct _cairo_state cairo_state;
+typedef struct _cairo_surface cairo_surface;
+typedef struct _cairo_matrix cairo_matrix;
_XFUNCPROTOBEGIN
/* Functions for manipulating state objects */
-XrState *
-XrCreate(void);
+cairo_state *
+cairo_create(void);
void
-XrDestroy(XrState *xrs);
+cairo_destroy(cairo_state *xrs);
void
-XrSave(XrState *xrs);
+cairo_save(cairo_state *xrs);
void
-XrRestore(XrState *xrs);
+cairo_restore(cairo_state *xrs);
/* XXX: I want to rethink this API
void
-XrPushGroup(XrState *xrs);
+cairo_push_group(cairo_state *xrs);
void
-XrPopGroup(XrState *xrs);
+cairo_pop_group(cairo_state *xrs);
*/
/* Modify state */
void
-XrSetTargetSurface (XrState *xrs, XrSurface *surface);
+cairo_set_target_surface (cairo_state *xrs, cairo_surface *surface);
-typedef enum _XrFormat {
- XrFormatARGB32 = PictStandardARGB32,
- XrFormatRGB24 = PictStandardRGB24,
- XrFormatA8 = PictStandardA8,
- XrFormatA1 = PictStandardA1
-} XrFormat;
+typedef enum _cairo_format {
+ cairo_format_a_r_g_b32 = PictStandardARGB32,
+ cairo_format_r_g_b24 = PictStandardRGB24,
+ cairo_format_a8 = PictStandardA8,
+ cairo_format_a1 = PictStandardA1
+} cairo_format;
void
-XrSetTargetDrawable (XrState *xrs,
+cairo_set_target_drawable (cairo_state *xrs,
Display *dpy,
Drawable drawable);
void
-XrSetTargetImage (XrState *xrs,
+cairo_set_target_image (cairo_state *xrs,
char *data,
- XrFormat format,
+ cairo_format format,
int width,
int height,
int stride);
-typedef enum _XrOperator {
- XrOperatorClear = PictOpClear,
- XrOperatorSrc = PictOpSrc,
- XrOperatorDst = PictOpDst,
- XrOperatorOver = PictOpOver,
- XrOperatorOverReverse = PictOpOverReverse,
- XrOperatorIn = PictOpIn,
- XrOperatorInReverse = PictOpInReverse,
- XrOperatorOut = PictOpOut,
- XrOperatorOutReverse = PictOpOutReverse,
- XrOperatorAtop = PictOpAtop,
- XrOperatorAtopReverse = PictOpAtopReverse,
- XrOperatorXor = PictOpXor,
- XrOperatorAdd = PictOpAdd,
- XrOperatorSaturate = PictOpSaturate,
-
- XrOperatorDisjointClear = PictOpDisjointClear,
- XrOperatorDisjointSrc = PictOpDisjointSrc,
- XrOperatorDisjointDst = PictOpDisjointDst,
- XrOperatorDisjointOver = PictOpDisjointOver,
- XrOperatorDisjointOverReverse = PictOpDisjointOverReverse,
- XrOperatorDisjointIn = PictOpDisjointIn,
- XrOperatorDisjointInReverse = PictOpDisjointInReverse,
- XrOperatorDisjointOut = PictOpDisjointOut,
- XrOperatorDisjointOutReverse = PictOpDisjointOutReverse,
- XrOperatorDisjointAtop = PictOpDisjointAtop,
- XrOperatorDisjointAtopReverse = PictOpDisjointAtopReverse,
- XrOperatorDisjointXor = PictOpDisjointXor,
-
- XrOperatorConjointClear = PictOpConjointClear,
- XrOperatorConjointSrc = PictOpConjointSrc,
- XrOperatorConjointDst = PictOpConjointDst,
- XrOperatorConjointOver = PictOpConjointOver,
- XrOperatorConjointOverReverse = PictOpConjointOverReverse,
- XrOperatorConjointIn = PictOpConjointIn,
- XrOperatorConjointInReverse = PictOpConjointInReverse,
- XrOperatorConjointOut = PictOpConjointOut,
- XrOperatorConjointOutReverse = PictOpConjointOutReverse,
- XrOperatorConjointAtop = PictOpConjointAtop,
- XrOperatorConjointAtopReverse = PictOpConjointAtopReverse,
- XrOperatorConjointXor = PictOpConjointXor
-} XrOperator;
-
-void
-XrSetOperator(XrState *xrs, XrOperator op);
-
-/* XXX: Probably want to bite the bullet and expose an XrColor object */
-
-void
-XrSetRGBColor(XrState *xrs, double red, double green, double blue);
-
-void
-XrGetRGBColor(XrState *xrs, double *red, double *green, double *blue);
-
-/* XXX: Do we want XrGetPattern as well? */
+typedef enum _cairo_operator {
+ cairo_operator_clear = PictOpClear,
+ cairo_operator_src = PictOpSrc,
+ cairo_operator_dst = PictOpDst,
+ cairo_operator_over = PictOpOver,
+ cairo_operator_over_reverse = PictOpOverReverse,
+ cairo_operator_in = PictOpIn,
+ cairo_operator_in_reverse = PictOpInReverse,
+ cairo_operator_out = PictOpOut,
+ cairo_operator_out_reverse = PictOpOutReverse,
+ cairo_operator_atop = PictOpAtop,
+ cairo_operator_atop_reverse = PictOpAtopReverse,
+ cairo_operator_xor = PictOpXor,
+ cairo_operator_add = PictOpAdd,
+ cairo_operator_saturate = PictOpSaturate,
+
+ cairo_operator_disjoint_clear = PictOpDisjointClear,
+ cairo_operator_disjoint_src = PictOpDisjointSrc,
+ cairo_operator_disjoint_dst = PictOpDisjointDst,
+ cairo_operator_disjoint_over = PictOpDisjointOver,
+ cairo_operator_disjoint_over_reverse = PictOpDisjointOverReverse,
+ cairo_operator_disjoint_in = PictOpDisjointIn,
+ cairo_operator_disjoint_in_reverse = PictOpDisjointInReverse,
+ cairo_operator_disjoint_out = PictOpDisjointOut,
+ cairo_operator_disjoint_out_reverse = PictOpDisjointOutReverse,
+ cairo_operator_disjoint_atop = PictOpDisjointAtop,
+ cairo_operator_disjoint_atop_reverse = PictOpDisjointAtopReverse,
+ cairo_operator_disjoint_xor = PictOpDisjointXor,
+
+ cairo_operator_conjoint_clear = PictOpConjointClear,
+ cairo_operator_conjoint_src = PictOpConjointSrc,
+ cairo_operator_conjoint_dst = PictOpConjointDst,
+ cairo_operator_conjoint_over = PictOpConjointOver,
+ cairo_operator_conjoint_over_reverse = PictOpConjointOverReverse,
+ cairo_operator_conjoint_in = PictOpConjointIn,
+ cairo_operator_conjoint_in_reverse = PictOpConjointInReverse,
+ cairo_operator_conjoint_out = PictOpConjointOut,
+ cairo_operator_conjoint_out_reverse = PictOpConjointOutReverse,
+ cairo_operator_conjoint_atop = PictOpConjointAtop,
+ cairo_operator_conjoint_atop_reverse = PictOpConjointAtopReverse,
+ cairo_operator_conjoint_xor = PictOpConjointXor
+} cairo_operator;
+
+void
+cairo_set_operator(cairo_state *xrs, cairo_operator op);
+
+/* XXX: Probably want to bite the bullet and expose an cairo_color object */
+
+void
+cairo_set_r_g_b_color(cairo_state *xrs, double red, double green, double blue);
+
+void
+cairo_get_r_g_b_color(cairo_state *xrs, double *red, double *green, double *blue);
+
+/* XXX: Do we want cairo_get_pattern as well? */
void
-XrSetPattern(XrState *xrs, XrSurface *pattern);
+cairo_set_pattern(cairo_state *xrs, cairo_surface *pattern);
void
-XrSetTolerance(XrState *xrs, double tolerance);
+cairo_set_tolerance(cairo_state *xrs, double tolerance);
void
-XrSetAlpha(XrState *xrs, double alpha);
+cairo_set_alpha(cairo_state *xrs, double alpha);
double
-XrGetAlpha(XrState *xrs);
+cairo_get_alpha(cairo_state *xrs);
-typedef enum _XrFillRule { XrFillRuleWinding, XrFillRuleEvenOdd } XrFillRule;
+typedef enum _cairo_fill_rule { cairo_fill_rule_winding, cairo_fill_rule_even_odd } cairo_fill_rule;
void
-XrSetFillRule(XrState *xrs, XrFillRule fill_rule);
+cairo_set_fill_rule(cairo_state *xrs, cairo_fill_rule fill_rule);
void
-XrSetLineWidth(XrState *xrs, double width);
+cairo_set_line_width(cairo_state *xrs, double width);
-typedef enum _XrLineCap { XrLineCapButt, XrLineCapRound, XrLineCapSquare } XrLineCap;
+typedef enum _cairo_line_cap { cairo_line_cap_butt, cairo_line_cap_round, cairo_line_cap_square } cairo_line_cap;
void
-XrSetLineCap(XrState *xrs, XrLineCap line_cap);
+cairo_set_line_cap(cairo_state *xrs, cairo_line_cap line_cap);
-typedef enum _XrLineJoin { XrLineJoinMiter, XrLineJoinRound, XrLineJoinBevel } XrLineJoin;
+typedef enum _cairo_line_join { cairo_line_join_miter, cairo_line_join_round, cairo_line_join_bevel } cairo_line_join;
void
-XrSetLineJoin(XrState *xrs, XrLineJoin line_join);
+cairo_set_line_join(cairo_state *xrs, cairo_line_join line_join);
void
-XrSetDash(XrState *xrs, double *dashes, int ndash, double offset);
+cairo_set_dash(cairo_state *xrs, double *dashes, int ndash, double offset);
void
-XrSetMiterLimit(XrState *xrs, double limit);
+cairo_set_miter_limit(cairo_state *xrs, double limit);
void
-XrTranslate(XrState *xrs, double tx, double ty);
+cairo_translate(cairo_state *xrs, double tx, double ty);
void
-XrScale(XrState *xrs, double sx, double sy);
+cairo_scale(cairo_state *xrs, double sx, double sy);
void
-XrRotate(XrState *xrs, double angle);
+cairo_rotate(cairo_state *xrs, double angle);
void
-XrConcatMatrix(XrState *xrs,
- XrMatrix *matrix);
+cairo_concat_matrix(cairo_state *xrs,
+ cairo_matrix *matrix);
void
-XrSetMatrix(XrState *xrs,
- XrMatrix *matrix);
+cairo_set_matrix(cairo_state *xrs,
+ cairo_matrix *matrix);
void
-XrDefaultMatrix(XrState *xrs);
+cairo_default_matrix(cairo_state *xrs);
-/* XXX: There's been a proposal to add XrDefaultMatrixExact */
+/* XXX: There's been a proposal to add cairo_default_matrix_exact */
void
-XrIdentityMatrix(XrState *xrs);
+cairo_identity_matrix(cairo_state *xrs);
void
-XrTransformPoint (XrState *xrs, double *x, double *y);
+cairo_transform_point (cairo_state *xrs, double *x, double *y);
void
-XrTransformDistance (XrState *xrs, double *dx, double *dy);
+cairo_transform_distance (cairo_state *xrs, double *dx, double *dy);
void
-XrInverseTransformPoint (XrState *xrs, double *x, double *y);
+cairo_inverse_transform_point (cairo_state *xrs, double *x, double *y);
void
-XrInverseTransformDistance (XrState *xrs, double *dx, double *dy);
+cairo_inverse_transform_distance (cairo_state *xrs, double *dx, double *dy);
/* Path creation functions */
void
-XrNewPath(XrState *xrs);
+cairo_new_path(cairo_state *xrs);
void
-XrMoveTo(XrState *xrs, double x, double y);
+cairo_move_to(cairo_state *xrs, double x, double y);
void
-XrLineTo(XrState *xrs, double x, double y);
+cairo_line_to(cairo_state *xrs, double x, double y);
void
-XrCurveTo(XrState *xrs,
+cairo_curve_to(cairo_state *xrs,
double x1, double y1,
double x2, double y2,
double x3, double y3);
void
-XrRelMoveTo(XrState *xrs, double dx, double dy);
+cairo_rel_move_to(cairo_state *xrs, double dx, double dy);
void
-XrRelLineTo(XrState *xrs, double dx, double dy);
+cairo_rel_line_to(cairo_state *xrs, double dx, double dy);
void
-XrRelCurveTo(XrState *xrs,
+cairo_rel_curve_to(cairo_state *xrs,
double dx1, double dy1,
double dx2, double dy2,
double dx3, double dy3);
void
-XrRectangle (XrState *xrs,
+cairo_rectangle (cairo_state *xrs,
double x, double y,
double width, double height);
void
-XrClosePath(XrState *xrs);
+cairo_close_path(cairo_state *xrs);
/* Painting functions */
void
-XrStroke(XrState *xrs);
+cairo_stroke(cairo_state *xrs);
void
-XrFill(XrState *xrs);
+cairo_fill(cairo_state *xrs);
/* Clipping */
void
-XrClip(XrState *xrs);
+cairo_clip(cairo_state *xrs);
/* Font/Text functions */
-/* XXX: The font support should probably expose an XrFont object with
- several functions, (XrFontTransform, etc.) in a parallel manner as
- XrMatrix and (eventually) XrColor */
+/* XXX: The font support should probably expose an cairo_font object with
+ several functions, (cairo_font_transform, etc.) in a parallel manner as
+ cairo_matrix and (eventually) cairo_color */
void
-XrSelectFont(XrState *xrs, const char *key);
+cairo_select_font(cairo_state *xrs, const char *key);
void
-XrScaleFont(XrState *xrs, double scale);
+cairo_scale_font(cairo_state *xrs, double scale);
-/* XXX: Probably want to use an XrMatrix here, (to fix as part of the
+/* XXX: Probably want to use an cairo_matrix here, (to fix as part of the
big text support rewrite) */
void
-XrTransformFont(XrState *xrs,
+cairo_transform_font(cairo_state *xrs,
double a, double b,
double c, double d);
void
-XrTextExtents(XrState *xrs,
+cairo_text_extents(cairo_state *xrs,
const unsigned char *utf8,
double *x, double *y,
double *width, double *height,
double *dx, double *dy);
void
-XrShowText(XrState *xrs, const unsigned char *utf8);
+cairo_show_text(cairo_state *xrs, const unsigned char *utf8);
/* Image functions */
void
-XrShowSurface (XrState *xrs,
- XrSurface *surface,
+cairo_show_surface (cairo_state *xrs,
+ cairo_surface *surface,
int width,
int height);
/* Query functions */
-XrOperator
-XrGetOperator(XrState *xrs);
+cairo_operator
+cairo_get_operator(cairo_state *xrs);
double
-XrGetTolerance(XrState *xrs);
+cairo_get_tolerance(cairo_state *xrs);
void
-XrGetCurrentPoint(XrState *, double *x, double *y);
+cairo_get_current_point(cairo_state *, double *x, double *y);
-XrFillRule
-XrGetFillRule(XrState *xrs);
+cairo_fill_rule
+cairo_get_fill_rule(cairo_state *xrs);
double
-XrGetLineWidth(XrState *xrs);
+cairo_get_line_width(cairo_state *xrs);
-XrLineCap
-XrGetLineCap(XrState *xrs);
+cairo_line_cap
+cairo_get_line_cap(cairo_state *xrs);
-XrLineJoin
-XrGetLineJoin(XrState *xrs);
+cairo_line_join
+cairo_get_line_join(cairo_state *xrs);
double
-XrGetMiterLimit(XrState *xrs);
+cairo_get_miter_limit(cairo_state *xrs);
-/* XXX: How to do XrGetDash??? Do we want to switch to an XrDash object? */
+/* XXX: How to do cairo_get_dash??? Do we want to switch to an cairo_dash object? */
void
-XrGetMatrix(XrState *xrs,
+cairo_get_matrix(cairo_state *xrs,
double *a, double *b,
double *c, double *d,
double *tx, double *ty);
-XrSurface *
-XrGetTargetSurface (XrState *xrs);
+cairo_surface *
+cairo_get_target_surface (cairo_state *xrs);
/* Error status queries */
-typedef enum _XrStatus {
- XrStatusSuccess = 0,
- XrStatusNoMemory,
- XrStatusInvalidRestore,
- XrStatusInvalidPopGroup,
- XrStatusNoCurrentPoint,
- XrStatusInvalidMatrix
-} XrStatus;
+typedef enum _cairo_status {
+ cairo_status_success = 0,
+ cairo_status_no_memory,
+ cairo_status_invalid_restore,
+ cairo_status_invalid_pop_group,
+ cairo_status_no_current_point,
+ cairo_status_invalid_matrix
+} cairo_status;
-XrStatus
-XrGetStatus(XrState *xrs);
+cairo_status
+cairo_get_status(cairo_state *xrs);
const char *
-XrGetStatusString(XrState *xrs);
+cairo_get_status_string(cairo_state *xrs);
/* Surface mainpulation */
/* XXX: This is a mess from the user's POV. Should the Visual or the
- XrFormat control what render format is used? Maybe I can have
- XrSurfaceCreateForWindow with a visual, and
- XrSurfaceCreateForPixmap with an XrFormat. Would that work?
+ cairo_format control what render format is used? Maybe I can have
+ cairo_surface_create_for_window with a visual, and
+ cairo_surface_create_for_pixmap with an cairo_format. Would that work?
*/
-XrSurface *
-XrSurfaceCreateForDrawable (Display *dpy,
+cairo_surface *
+cairo_surface_create_for_drawable (Display *dpy,
Drawable drawable,
Visual *visual,
- XrFormat format,
+ cairo_format format,
Colormap colormap);
-XrSurface *
-XrSurfaceCreateForImage (char *data,
- XrFormat format,
+cairo_surface *
+cairo_surface_create_for_image (char *data,
+ cairo_format format,
int width,
int height,
int stride);
-XrSurface *
-XrSurfaceCreateNextTo (XrSurface *neighbor,
- XrFormat format,
+cairo_surface *
+cairo_surface_create_next_to (cairo_surface *neighbor,
+ cairo_format format,
int width,
int height);
/* XXX: One problem with having RGB and A here in one function is that
it introduces the question of pre-multiplied vs. non-pre-multiplied
- alpha. Do I want to export an XrColor structure instead? So far, no
+ alpha. Do I want to export an cairo_color structure instead? So far, no
other public functions need it. */
-XrSurface *
-XrSurfaceCreateNextToSolid (XrSurface *neighbor,
- XrFormat format,
+cairo_surface *
+cairo_surface_create_next_to_solid (cairo_surface *neighbor,
+ cairo_format format,
int width,
int height,
double red,
@@ -386,89 +386,89 @@
double alpha);
void
-XrSurfaceDestroy(XrSurface *surface);
+cairo_surface_destroy(cairo_surface *surface);
/* XXX: Should this take an X/Y offset as well? (Probably) */
-XrStatus
-XrSurfacePutImage (XrSurface *surface,
+cairo_status
+cairo_surface_put_image (cairo_surface *surface,
char *data,
int width,
int height,
int stride);
/* XXX: The Xc version of this function isn't quite working yet
-XrStatus
-XrSurfaceSetClipRegion (XrSurface *surface, Region region);
+cairo_status
+cairo_surface_set_clip_region (cairo_surface *surface, Region region);
*/
/* XXX: Note: The current Render/Ic implementations don't do the right
thing with repeat when the surface has a non-identity matrix. */
-XrStatus
-XrSurfaceSetRepeat (XrSurface *surface, int repeat);
+cairo_status
+cairo_surface_set_repeat (cairo_surface *surface, int repeat);
-XrStatus
-XrSurfaceSetMatrix(XrSurface *surface, XrMatrix *matrix);
+cairo_status
+cairo_surface_set_matrix(cairo_surface *surface, cairo_matrix *matrix);
-XrStatus
-XrSurfaceGetMatrix (XrSurface *surface, XrMatrix *matrix);
+cairo_status
+cairo_surface_get_matrix (cairo_surface *surface, cairo_matrix *matrix);
typedef enum {
- XrFilterFast = XcFilterFast,
- XrFilterGood = XcFilterGood,
- XrFilterBest = XcFilterBest,
- XrFilterNearest = XcFilterNearest,
- XrFilterBilinear = XcFilterBilinear
-} XrFilter;
+ cairo_filter_fast = XcFilterFast,
+ cairo_filter_good = XcFilterGood,
+ cairo_filter_best = XcFilterBest,
+ cairo_filter_nearest = XcFilterNearest,
+ cairo_filter_bilinear = XcFilterBilinear
+} cairo_filter;
-XrStatus
-XrSurfaceSetFilter(XrSurface *surface, XrFilter filter);
+cairo_status
+cairo_surface_set_filter(cairo_surface *surface, cairo_filter filter);
/* Matrix functions */
-XrMatrix *
-XrMatrixCreate (void);
+cairo_matrix *
+cairo_matrix_create (void);
void
-XrMatrixDestroy (XrMatrix *matrix);
+cairo_matrix_destroy (cairo_matrix *matrix);
-XrStatus
-XrMatrixCopy(XrMatrix *matrix, const XrMatrix *other);
+cairo_status
+cairo_matrix_copy(cairo_matrix *matrix, const cairo_matrix *other);
-XrStatus
-XrMatrixSetIdentity (XrMatrix *matrix);
+cairo_status
+cairo_matrix_set_identity (cairo_matrix *matrix);
-XrStatus
-XrMatrixSetAffine (XrMatrix *xrs,
+cairo_status
+cairo_matrix_set_affine (cairo_matrix *xrs,
double a, double b,
double c, double d,
double tx, double ty);
-XrStatus
-XrMatrixGetAffine (XrMatrix *matrix,
+cairo_status
+cairo_matrix_get_affine (cairo_matrix *matrix,
double *a, double *b,
double *c, double *d,
double *tx, double *ty);
-XrStatus
-XrMatrixTranslate (XrMatrix *matrix, double tx, double ty);
+cairo_status
+cairo_matrix_translate (cairo_matrix *matrix, double tx, double ty);
-XrStatus
-XrMatrixScale (XrMatrix *matrix, double sx, double sy);
+cairo_status
+cairo_matrix_scale (cairo_matrix *matrix, double sx, double sy);
-XrStatus
-XrMatrixRotate (XrMatrix *matrix, double radians);
+cairo_status
+cairo_matrix_rotate (cairo_matrix *matrix, double radians);
-XrStatus
-XrMatrixInvert(XrMatrix *matrix);
+cairo_status
+cairo_matrix_invert(cairo_matrix *matrix);
-XrStatus
-XrMatrixMultiply (XrMatrix *result, const XrMatrix *a, const XrMatrix *b);
+cairo_status
+cairo_matrix_multiply (cairo_matrix *result, const cairo_matrix *a, const cairo_matrix *b);
-XrStatus
-XrMatrixTransformDistance (XrMatrix *xr, double *dx, double *dy);
+cairo_status
+cairo_matrix_transform_distance (cairo_matrix *xr, double *dx, double *dy);
-XrStatus
-XrMatrixTransformPoint (XrMatrix *xr, double *x, double *y);
+cairo_status
+cairo_matrix_transform_point (cairo_matrix *xr, double *x, double *y);
_XFUNCPROTOEND
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xr_conv.py
Type: text/x-python
Size: 4007 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20030717/b7ec5634/xr_conv.py
More information about the cairo
mailing list