[cairo-commit] cairo-5c .cvsignore, NONE, 1.1 ChangeLog, 1.3,
1.4 Makefile.am, 1.1.1.1, 1.2 cairo-5c.h, 1.1.1.1,
1.2 configure.in, 1.1.1.1, 1.2 draw.c, 1.1.1.1, 1.2 gstate.c,
1.1.1.1, 1.2 gtk.c, NONE, 1.1 init.c, 1.2, 1.3 surface.c,
1.1.1.1, 1.2 text.c, 1.1.1.1, 1.2
Keith Packard
commit at pdx.freedesktop.org
Tue Dec 14 00:34:29 PST 2004
- Previous message: [cairo-commit] pycairo README,1.3,1.4
- Next message: [cairo-commit] cairo-5c/examples animate.5c, 1.1.1.1, 1.2 pie.5c,
1.2, 1.3 rottext.5c, 1.1.1.1, 1.2 sin.5c, 1.1.1.1, 1.2 test.5c,
1.1.1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: keithp
Update of /cvs/cairo/cairo-5c
In directory gabe:/tmp/cvs-serv8842
Modified Files:
ChangeLog Makefile.am cairo-5c.h configure.in draw.c gstate.c
init.c surface.c text.c
Added Files:
.cvsignore gtk.c
Log Message:
2004-12-14 Keith Packard <keithp at keithp.com>
* .cvsignore:
* Makefile.am:
* cairo-5c.h:
* configure.in:
* draw.c: (do_Cairo_fill), (do_Cairo_stroke):
* gtk.c: (configure_event), (expose_event), (cairo_5c_window_new),
(repaint_x), (gtk_repaint_timeout), (gtk_thread_main), (start_x),
(dirty_x):
* init.c: (nickle_init):
* surface.c: (get_cairo_5c), (free_cairo_5c), (dirty_cairo_5c),
(do_Cairo_new):
* text.c: (do_Cairo_show_text):
Replace lame Xlib-based output with more capable gtk+ based output,
including backing storage and resize handling. Input still
isn't hooked up.
* gstate.c: (do_Cairo_current_matrix), (do_Cairo_set_matrix):
Add current_matrix and set_matrix functions; these only do affine
matrices.
* examples/animate.5c:
* examples/pie.5c:
* examples/rottext.5c:
* examples/sin.5c:
* examples/test.5c:
Update examples to use installed library
--- NEW FILE: .cvsignore ---
.deps
.libs
*.lo
*.la
Makefile
Makefile.in
aclocal.m4
autom4te.cache
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
depcomp
install-sh
libtool
ltmain.sh
missing
mkinstalldirs
stamp-h1
Index: ChangeLog
===================================================================
RCS file: /cvs/cairo/cairo-5c/ChangeLog,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ChangeLog 11 Dec 2004 08:28:11 -0000 1.3
+++ ChangeLog 14 Dec 2004 08:34:27 -0000 1.4
@@ -1,3 +1,32 @@
+2004-12-14 Keith Packard <keithp at keithp.com>
+
+ * .cvsignore:
+ * Makefile.am:
+ * cairo-5c.h:
+ * configure.in:
+ * draw.c: (do_Cairo_fill), (do_Cairo_stroke):
+ * gtk.c: (configure_event), (expose_event), (cairo_5c_window_new),
+ (repaint_x), (gtk_repaint_timeout), (gtk_thread_main), (start_x),
+ (dirty_x):
+ * init.c: (nickle_init):
+ * surface.c: (get_cairo_5c), (free_cairo_5c), (dirty_cairo_5c),
+ (do_Cairo_new):
+ * text.c: (do_Cairo_show_text):
+ Replace lame Xlib-based output with more capable gtk+ based output,
+ including backing storage and resize handling. Input still
+ isn't hooked up.
+
+ * gstate.c: (do_Cairo_current_matrix), (do_Cairo_set_matrix):
+ Add current_matrix and set_matrix functions; these only do affine
+ matrices.
+
+ * examples/animate.5c:
+ * examples/pie.5c:
+ * examples/rottext.5c:
+ * examples/sin.5c:
+ * examples/test.5c:
+ Update examples to use installed library
+
2004-12-11 Keith Packard <keithp at keithp.com>
* examples/pie.5c:
Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/cairo-5c/Makefile.am,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- Makefile.am 11 Dec 2004 06:26:52 -0000 1.1.1.1
+++ Makefile.am 14 Dec 2004 08:34:27 -0000 1.2
@@ -1,12 +1,48 @@
+# $Id$
+#
+# Copyright © 2004 Keith Packard
+#
+# This library is free software; you can redistribute it and/or
+# modify it either under the terms of the GNU Lesser General Public
+# License version 2.1 as published by the Free Software Foundation
+# (the "LGPL") or, at your option, under the terms of the Mozilla
+# Public License Version 1.1 (the "MPL"). If you do not alter this
+# notice, a recipient may use your version of this file under either
+# the MPL or the LGPL.
+#
+# You should have received a copy of the LGPL along with this library
+# in the file COPYING-LGPL-2.1; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# You should have received a copy of the MPL along with this library
+# in the file COPYING-MPL-1.1
+#
+# The contents of this file are subject to the Mozilla Public License
+# Version 1.1 (the "License"); you may not use this file except in
+# compliance with the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
+# OF ANY KIND, either express or implied. See the LGPL or the MPL for
+# the specific language governing rights and limitations.
+#
+# The Original Code is the cairo graphics library.
+#
+# The Initial Developer of the Original Code is Keith Packard
+#
+# Contributor(s):
+# Keith Packard <keithp at keithp.com>
+#
+
libcairo_5c_la_SOURCES = \
cairo-5c.h init.c \
draw.c \
gstate.c \
surface.c \
+ gtk.c \
text.c
lib_LTLIBRARIES = libcairo-5c.la
-libcairo_5c_la_LIBADD = $(CAIRO_LIBS)
+libcairo_5c_la_LIBADD = $(CAIRO_5C_LIBS)
-AM_CFLAGS=@WARN_CFLAGS@ $(CAIRO_CFLAGS)
+AM_CFLAGS=$(WARN_CFLAGS) $(CAIRO_5C_CFLAGS)
Index: cairo-5c.h
===================================================================
RCS file: /cvs/cairo/cairo-5c/cairo-5c.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- cairo-5c.h 11 Dec 2004 06:26:52 -0000 1.1.1.1
+++ cairo-5c.h 14 Dec 2004 08:34:27 -0000 1.2
@@ -43,6 +43,13 @@
typedef enum { CAIRO_5C_WINDOW, CAIRO_5C_PNG } cairo_5c_kind_t;
+typedef struct _cairo_5c_x_t {
+ Display *dpy;
+ Pixmap pixmap;
+ int width;
+ int height;
+} cairo_5c_x_t;
+
typedef struct {
cairo_5c_kind_t kind;
cairo_t *cr;
@@ -51,11 +58,11 @@
Bool dirty;
union {
struct {
- Display *dpy;
- Window w;
+ Pixmap pix;
+ cairo_5c_x_t *x;
} window;
struct {
- FILE *file;
+ FILE *file;
} png;
} u;
} cairo_5c_t;
@@ -69,6 +76,9 @@
void
free_cairo_5c (void *v);
+void
+dirty_cairo_5c (cairo_5c_t *c5c);
+
Value
do_Cairo_new (int n, Value *v);
@@ -132,6 +142,12 @@
Value
do_Cairo_rotate (Value cv, Value av);
+Value
+do_Cairo_current_matrix (Value cv);
+
+Value
+do_Cairo_set_matrix (Value cv, Value mv);
+
/* draw.c */
Value
do_Cairo_new_path (Value cv);
@@ -198,4 +214,14 @@
Value
do_Cairo_text_extents (Value cv, Value uv);
+/* gtk+.c */
+cairo_5c_x_t *
+start_x (int width, int height);
+
+void
+repaint_x (cairo_5c_x_t *c5cx, int x, int y, int w, int h);
+
+void
+dirty_x (cairo_5c_x_t *c5cx, int x, int y, int w, int h);
+
#endif /* _CAIRO_5C_H_ */
Index: configure.in
===================================================================
RCS file: /cvs/cairo/cairo-5c/configure.in,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- configure.in 11 Dec 2004 06:26:52 -0000 1.1.1.1
+++ configure.in 14 Dec 2004 08:34:27 -0000 1.2
@@ -33,7 +33,9 @@
fi
AC_SUBST(WARN_CFLAGS)
-PKG_CHECK_MODULES(CAIRO, cairo)
+CAIRO_5C_PC_MODULES="cairo gtk+-2.0 gthread-2.0"
+
+PKG_CHECK_MODULES(CAIRO_5C, $CAIRO_5C_PC_MODULES)
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
Index: draw.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/draw.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- draw.c 11 Dec 2004 06:26:52 -0000 1.1.1.1
+++ draw.c 14 Dec 2004 08:34:27 -0000 1.2
@@ -184,7 +184,7 @@
if (!aborting)
{
cairo_fill (c5c->cr);
- c5c->dirty = True;
+ dirty_cairo_5c (c5c);
}
return Void;
}
@@ -196,7 +196,7 @@
if (!aborting) {
cairo_stroke (c5c->cr);
- c5c->dirty = True;
+ dirty_cairo_5c (c5c);
}
return Void;
}
Index: gstate.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/gstate.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- gstate.c 11 Dec 2004 06:26:52 -0000 1.1.1.1
+++ gstate.c 14 Dec 2004 08:34:27 -0000 1.2
@@ -165,3 +165,69 @@
return Void;
}
+Value
+do_Cairo_current_matrix (Value cv)
+{
+ ENTER ();
+ cairo_5c_t *c5c = get_cairo_5c (cv);
+ cairo_matrix_t *matrix;
+ double a, b, c, d, tx, ty;
+ Value ret;
+ static int dims[2] = { 2, 3 };
+
+ if (aborting)
+ RETURN(Void);
+
+ matrix = cairo_matrix_create ();
+
+ if (!matrix)
+ {
+ RaiseStandardException (exception_invalid_argument,
+ "can't create matrix",
+ 2, cv, Void);
+ RETURN(Void);
+ }
+ cairo_current_matrix (c5c->cr, matrix);
+ cairo_matrix_get_affine (matrix, &a, &b, &c, &d, &tx, &ty);
+ cairo_matrix_destroy (matrix);
+ ret = NewArray (False, False, typePrim[rep_float], 2, dims);
+ ArrayValueSet(&ret->array, 0, NewDoubleFloat (a));
+ ArrayValueSet(&ret->array, 1, NewDoubleFloat (b));
+ ArrayValueSet(&ret->array, 2, NewDoubleFloat (c));
+ ArrayValueSet(&ret->array, 3, NewDoubleFloat (d));
+ ArrayValueSet(&ret->array, 4, NewDoubleFloat (tx));
+ ArrayValueSet(&ret->array, 5, NewDoubleFloat (ty));
+ RETURN (ret);
+}
+
+Value
+do_Cairo_set_matrix (Value cv, Value mv)
+{
+ ENTER ();
+ cairo_5c_t *c5c = get_cairo_5c (cv);
+ cairo_matrix_t *matrix;
+ double a, b, c, d, tx, ty;
+
+ if (aborting)
+ RETURN(Void);
+
+ matrix = cairo_matrix_create ();
+ if (!matrix)
+ {
+ RaiseStandardException (exception_invalid_argument,
+ "can't create matrix",
+ 2, cv, Void);
+ RETURN(Void);
+ }
+ a = DoublePart (ArrayValueGet(&mv->array, 0), "invalid matrix");
+ b = DoublePart (ArrayValueGet(&mv->array, 1), "invalid matrix");
+ c = DoublePart (ArrayValueGet(&mv->array, 2), "invalid matrix");
+ d = DoublePart (ArrayValueGet(&mv->array, 3), "invalid matrix");
+ tx = DoublePart (ArrayValueGet(&mv->array, 4), "invalid matrix");
+ ty = DoublePart (ArrayValueGet(&mv->array, 5), "invalid matrix");
+ cairo_matrix_set_affine (matrix, a, b, c, d, tx, ty);
+ cairo_set_matrix (c5c->cr, matrix);
+ cairo_matrix_destroy (matrix);
+ RETURN (Void);
+}
+
--- NEW FILE: gtk.c ---
(This appears to be a binary file; contents omitted.)
Index: init.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/init.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- init.c 11 Dec 2004 07:45:42 -0000 1.2
+++ init.c 14 Dec 2004 08:34:27 -0000 1.3
@@ -99,6 +99,10 @@
" void stroke (foreign cairo)\n"
"\n"
" Stroke the current path\n" },
+ { do_Cairo_current_matrix, "current_matrix", "A**n", "F", "\n"
+ " real[3,2] current_matrix (foreign cairo)\n"
+ "\n"
+ " Returns the current transformation matrix\n" },
{ 0 }
};
@@ -143,6 +147,10 @@
" text_extents_t text_extents (foreign cr, string text)\n"
"\n"
" Appends text to current path\n" },
+ { do_Cairo_set_matrix, "set_matrix", "v", "FA**n", "\n"
+ " void set_matrix (foreign cr, real[3,2] matrix)\n"
+ "\n"
+ " Sets the transformation matrix\n" },
{ 0 }
};
Index: surface.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/surface.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- surface.c 11 Dec 2004 06:26:52 -0000 1.1.1.1
+++ surface.c 14 Dec 2004 08:34:27 -0000 1.2
@@ -57,19 +57,20 @@
2, NewInt(0), av);
return 0;
}
- return c5c;
-}
-
-static void
-Cairo_block_handler (void *closure)
-{
- cairo_5c_t *c5c = closure;
-
- if (c5c->dirty)
- {
- XFlush (c5c->u.window.dpy);
- c5c->dirty = False;
+ switch (c5c->kind) {
+ case CAIRO_5C_WINDOW:
+ if (c5c->u.window.pix != c5c->u.window.x->pixmap)
+ {
+ c5c->u.window.pix = c5c->u.window.x->pixmap;
+ c5c->width = c5c->u.window.x->width;
+ c5c->height = c5c->u.window.x->height;
+ cairo_set_target_drawable (c5c->cr, c5c->u.window.x->dpy, c5c->u.window.pix);
+ }
+ break;
+ case CAIRO_5C_PNG:
+ break;
}
+ return c5c;
}
void
@@ -82,8 +83,6 @@
cairo_destroy (c5c->cr);
switch (c5c->kind) {
case CAIRO_5C_WINDOW:
- XCloseDisplay (c5c->u.window.dpy);
- ThreadsUnregisterBlockHandler (Cairo_block_handler, c5c);
break;
case CAIRO_5C_PNG:
fflush (c5c->u.png.file);
@@ -93,54 +92,53 @@
}
}
+void
+dirty_cairo_5c (cairo_5c_t *c5c)
+{
+ switch (c5c->kind) {
+ case CAIRO_5C_WINDOW:
+ dirty_x (c5c->u.window.x, 0, 0, 0, 0);
+ break;
+ case CAIRO_5C_PNG:
+ break;
+ }
+}
+
Value
do_Cairo_new (int n, Value *v)
{
ENTER ();
cairo_5c_t *c5c;
- int screen;
Value ret;
- Display *dpy;
+ int width, height;
c5c = malloc (sizeof (cairo_5c_t));
- if (!c5c)
- RETURN (Void);
-
c5c->kind = CAIRO_5C_WINDOW;
- dpy = XOpenDisplay (0);
- c5c->u.window.dpy = dpy;
- if (!dpy)
- {
- RaiseStandardException (exception_open_error,
- "can't open X display",
- 0, Void);
- free (c5c);
+ if (!c5c)
RETURN (Void);
- }
- screen = DefaultScreen(dpy);
-
if (n > 0)
- c5c->width = IntPart (v[0], "invalid width");
+ width = IntPart (v[0], "invalid width");
else
- c5c->width = DisplayWidth (dpy, screen) / 3;
+ width = 0;
if (n > 1)
- c5c->height = IntPart (v[1], "invalid height");
+ height = IntPart (v[1], "invalid height");
else
- c5c->height = DisplayWidth (dpy, screen) / 3;
+ height = 0;
+
if (aborting)
{
- XCloseDisplay (dpy);
free (c5c);
RETURN (Void);
}
- c5c->u.window.w = XCreateSimpleWindow (dpy, RootWindow (dpy, screen),
- 0, 0, c5c->width, c5c->height, 0,
- BlackPixel (dpy, screen),
- WhitePixel (dpy, screen));
+ c5c->u.window.x = start_x (width, height);
+ c5c->width = c5c->u.window.x->width;
+ c5c->height = c5c->u.window.x->height;
+ c5c->u.window.pix = c5c->u.window.x->pixmap;
+
c5c->cr = cairo_create ();
- cairo_set_target_drawable (c5c->cr, dpy, c5c->u.window.w);
+ cairo_set_target_drawable (c5c->cr, c5c->u.window.x->dpy, c5c->u.window.pix);
cairo_save (c5c->cr); {
cairo_identity_matrix (c5c->cr);
@@ -151,13 +149,8 @@
cairo_set_rgb_color (c5c->cr, 0, 0, 0);
- XMapWindow (dpy, c5c->u.window.w);
- XFlush (dpy);
-
ret = NewForeign (CairoId, c5c, free_cairo_5c);
- ThreadsRegisterBlockHandler (Cairo_block_handler, c5c);
-
RETURN (ret);
}
Index: text.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/text.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- text.c 11 Dec 2004 06:26:52 -0000 1.1.1.1
+++ text.c 14 Dec 2004 08:34:27 -0000 1.2
@@ -68,7 +68,7 @@
if (!aborting)
{
cairo_show_text (c5c->cr, utf8);
- c5c->dirty = True;
+ dirty_cairo_5c (c5c);
}
return Void;
}
- Previous message: [cairo-commit] pycairo README,1.3,1.4
- Next message: [cairo-commit] cairo-5c/examples animate.5c, 1.1.1.1, 1.2 pie.5c,
1.2, 1.3 rottext.5c, 1.1.1.1, 1.2 sin.5c, 1.1.1.1, 1.2 test.5c,
1.1.1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the cairo-commit
mailing list