[cairo-commit] cairo-5c ChangeLog, 1.16, 1.17 cairo-5c.h, 1.10,
1.11 cairo.5c, 1.8, 1.9 cairo.c, 1.2, 1.3 draw.c, 1.5,
1.6 event.c, 1.2, 1.3 gstate.c, 1.6, 1.7 gtk.c, 1.6,
1.7 init.c, 1.11, 1.12 matrix.c, 1.1, 1.2 surface.c, 1.9, 1.10
Keith Packard
commit at pdx.freedesktop.org
Fri Feb 11 13:15:48 PST 2005
Committed by: keithp
Update of /cvs/cairo/cairo-5c
In directory gabe:/tmp/cvs-serv32754
Modified Files:
ChangeLog cairo-5c.h cairo.5c cairo.c draw.c event.c gstate.c
gtk.c init.c matrix.c surface.c
Log Message:
2005-01-02 Keith Packard <keithp at keithp.com>
* cairo-5c.h:
Add do_Cairo_copy_page and do_Cairo_show_page.
Track whether copy_page/show_page have ever been called so
that they can be when the surface is destroyed.
* cairo.c: (cairo_5c_free), (cairo_5c_dirty):
* draw.c: (do_Cairo_arc), (do_Cairo_arc_negative),
(do_Cairo_copy_page), (do_Cairo_show_page):
Fix arc arguments
* event.c: (do_Cairo_Surface_open_event):
* gtk.c: (cairo_5c_tool_destroy):
* init.c: (nickle_init):
* surface.c: (cairo_5c_surface_mark), (cairo_5c_surface_destroy),
(cairo_5c_surface_free), (do_Cairo_Surface_create_window),
(do_Cairo_Surface_create_png), (do_Cairo_Surface_create_ps),
(do_Cairo_Surface_create_similar), (do_Cairo_Surface_destroy):
dunno
Index: ChangeLog
===================================================================
RCS file: /cvs/cairo/cairo-5c/ChangeLog,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- ChangeLog 24 Dec 2004 09:00:10 -0000 1.16
+++ ChangeLog 11 Feb 2005 21:15:46 -0000 1.17
@@ -1,3 +1,24 @@
+2005-01-02 Keith Packard <keithp at keithp.com>
+
+ * cairo-5c.h:
+ Add do_Cairo_copy_page and do_Cairo_show_page.
+ Track whether copy_page/show_page have ever been called so
+ that they can be when the surface is destroyed.
+
+ * cairo.c: (cairo_5c_free), (cairo_5c_dirty):
+ * draw.c: (do_Cairo_arc), (do_Cairo_arc_negative),
+ (do_Cairo_copy_page), (do_Cairo_show_page):
+ Fix arc arguments
+
+ * event.c: (do_Cairo_Surface_open_event):
+ * gtk.c: (cairo_5c_tool_destroy):
+ * init.c: (nickle_init):
+ * surface.c: (cairo_5c_surface_mark), (cairo_5c_surface_destroy),
+ (cairo_5c_surface_free), (do_Cairo_Surface_create_window),
+ (do_Cairo_Surface_create_png), (do_Cairo_Surface_create_ps),
+ (do_Cairo_Surface_create_similar), (do_Cairo_Surface_destroy):
+ dunno
+
2004-12-24 Keith Packard <keithp at keithp.com>
* cairo-5c.h:
Index: cairo-5c.h
===================================================================
RCS file: /cvs/cairo/cairo-5c/cairo-5c.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- cairo-5c.h 24 Dec 2004 09:00:10 -0000 1.10
+++ cairo-5c.h 11 Feb 2005 21:15:46 -0000 1.11
@@ -76,6 +76,7 @@
int height;
Bool dirty;
Value recv_events;
+ Bool copied;
union {
cairo_5c_window_t window;
cairo_5c_png_t png;
@@ -347,6 +348,12 @@
do_Cairo_stroke (Value cv);
Value
+do_Cairo_copy_page (Value cv);
+
+Value
+do_Cairo_show_page (Value cv);
+
+Value
do_Cairo_in_stroke (Value cv, Value xv, Value yv);
Value
Index: cairo.5c
===================================================================
RCS file: /cvs/cairo/cairo-5c/cairo.5c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- cairo.5c 24 Dec 2004 09:00:10 -0000 1.8
+++ cairo.5c 11 Feb 2005 21:15:46 -0000 1.9
@@ -67,35 +67,50 @@
static surface_or_none_t surface = surface_or_none_t.none;
static mutex m = Mutex::new();
+ cairo_t cr = create ();
+
/*
* A local function to make sure the 'default' surface
* exists
*/
void ensure_surface ()
{
- Mutex::acquire (m);
- union switch (surface) {
- case none:
- string name = (dim (argv) > 0) ? argv[0] : "nickle";
- surface.surface = Surface::create_window (name, w, h);
- break;
- case surface:
- break;
+ twixt (Mutex::acquire (m); Mutex::release (m))
+ {
+ union switch (surface) {
+ case none:
+ string name = (dim (argv) > 0) ? argv[0] : "nickle";
+ surface.surface = Surface::create_window (name, w, h);
+ set_target_surface (cr, surface.surface);
+ set_rgb_color (cr, 1, 1, 1);
+ rectangle (cr, 0, 0, Cairo::width (cr), Cairo::height (cr));
+ fill (cr);
+ break;
+ case surface:
+ set_target_surface (cr, surface.surface);
+ break;
+ }
}
- Mutex::release (m);
}
- cairo_t cr = create ();
-
try
{
ensure_surface ();
- set_target_surface (cr, surface.surface);
} catch invalid_argument (string reason, int i, poly arg) {
surface = surface_or_none_t.none;
ensure_surface ();
- set_target_surface (cr, surface.surface);
}
+ set_rgb_color (cr, 0, 0, 0);
+ return cr;
+ }
+
+ public cairo_t new_window (string name, int args...) {
+ int w = dim(args) > 0 ? args[0] : 0;
+ int h = dim(args) > 1 ? args[1] : 0;
+ surface_t surface = Surface::create_window (name, w, h);
+ cairo_t cr = create ();
+
+ set_target_surface (cr, surface);
set_rgb_color (cr, 1, 1, 1);
rectangle (cr, 0, 0, Cairo::width (cr), Cairo::height (cr));
fill (cr);
@@ -108,11 +123,12 @@
surface_t surface = Surface::create_png (filename, width, height);
cairo_t cr = create ();
set_target_surface (cr, surface);
- set_target_surface (cr, surface);
set_rgb_color (cr, 0, 0, 0);
set_alpha (cr, 0);
+ set_operator (cr, operator_t.SRC);
rectangle (cr, 0, 0, Cairo::width (cr), Cairo::height (cr));
fill (cr);
+ set_operator (cr, operator_t.OVER);
set_rgb_color (cr, 0, 0, 0);
set_alpha (cr, 1);
return cr;
@@ -126,7 +142,6 @@
xppi, yppi);
cairo_t cr = create ();
set_target_surface (cr, surface);
- set_target_surface (cr, surface);
set_rgb_color (cr, 1, 1, 1);
rectangle (cr, 0, 0, Cairo::width (cr), Cairo::height (cr));
fill (cr);
Index: cairo.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/cairo.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- cairo.c 24 Dec 2004 09:00:10 -0000 1.2
+++ cairo.c 11 Feb 2005 21:15:46 -0000 1.3
@@ -86,11 +86,12 @@
{
cairo_5c_t *c5c = v;
- if (c5c)
+ if (c5c->cr)
{
cairo_destroy (c5c->cr);
- c5c->surface = Void;
+ c5c->cr = NULL;
}
+ c5c->surface = Void;
return 1;
}
@@ -147,7 +148,7 @@
if (c5c->surface != Void)
{
cairo_5c_surface_t *c5s = cairo_5c_surface_get (c5c->surface);
-
+
if (c5s)
{
switch (c5s->kind) {
Index: draw.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/draw.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- draw.c 23 Dec 2004 22:39:40 -0000 1.5
+++ draw.c 11 Feb 2005 21:15:46 -0000 1.6
@@ -89,37 +89,35 @@
Value
do_Cairo_arc (Value cv,
- Value x1v, Value y1v,
- Value x2v, Value y2v,
- Value rv)
+ Value xcv, Value ycv, Value rv,
+ Value a1v, Value a2v)
{
cairo_5c_t *c5c = cairo_5c_get (cv);
- double x1 = DoublePart (x1v, "invalid X1 value");
- double y1 = DoublePart (y1v, "invalid Y1 value");
- double x2 = DoublePart (x2v, "invalid X2 value");
- double y2 = DoublePart (y2v, "invalid Y2 value");
+ double xc = DoublePart (xcv, "invalid xc value");
+ double yc = DoublePart (ycv, "invalid yc value");
double r = DoublePart (rv, "invalid radius");
+ double a1 = DoublePart (a1v, "invalid angle1 value");
+ double a2 = DoublePart (a2v, "invalid angle2 value");
if (!aborting)
- cairo_arc (c5c->cr, x1, y1, x2, y2, r);
+ cairo_arc (c5c->cr, xc, yc, r, a1, a2);
return Void;
}
Value
do_Cairo_arc_negative (Value cv,
- Value x1v, Value y1v,
- Value x2v, Value y2v,
- Value rv)
+ Value xcv, Value ycv, Value rv,
+ Value a1v, Value a2v)
{
cairo_5c_t *c5c = cairo_5c_get (cv);
- double x1 = DoublePart (x1v, "invalid X1 value");
- double y1 = DoublePart (y1v, "invalid Y1 value");
- double x2 = DoublePart (x2v, "invalid X2 value");
- double y2 = DoublePart (y2v, "invalid Y2 value");
+ double xc = DoublePart (xcv, "invalid xc value");
+ double yc = DoublePart (ycv, "invalid yc value");
double r = DoublePart (rv, "invalid radius");
+ double a1 = DoublePart (a1v, "invalid angle1 value");
+ double a2 = DoublePart (a2v, "invalid angle2 value");
if (!aborting)
- cairo_arc_negative (c5c->cr, x1, y1, x2, y2, r);
+ cairo_arc_negative (c5c->cr, xc, yc, r, a1, a2);
return Void;
}
@@ -216,6 +214,42 @@
}
Value
+do_Cairo_copy_page (Value cv)
+{
+ cairo_5c_t *c5c = cairo_5c_get (cv);
+
+ if (aborting)
+ return Void;
+ if (c5c->surface != Void)
+ {
+ cairo_5c_surface_t *c5s = cairo_5c_surface_get (c5c->surface);
+ if (!c5s)
+ return 0;
+ c5s->copied = True;
+ cairo_copy_page (c5c->cr);
+ }
+ return Void;
+}
+
+Value
+do_Cairo_show_page (Value cv)
+{
+ cairo_5c_t *c5c = cairo_5c_get (cv);
+
+ if (aborting)
+ return Void;
+ if (c5c->surface != Void)
+ {
+ cairo_5c_surface_t *c5s = cairo_5c_surface_get (c5c->surface);
+ if (!c5s)
+ return 0;
+ c5s->copied = True;
+ cairo_show_page (c5c->cr);
+ }
+ return Void;
+}
+
+Value
do_Cairo_in_stroke (Value cv, Value xv, Value yv)
{
cairo_5c_t *c5c = cairo_5c_get (cv);
Index: event.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/event.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- event.c 23 Dec 2004 22:39:40 -0000 1.2
+++ event.c 11 Feb 2005 21:15:46 -0000 1.3
@@ -41,7 +41,7 @@
{
ENTER ();
cairo_5c_surface_t *c5s = cairo_5c_surface_get (sv);
- Value read;
+ Value read = Void;
int fd[2];
FILE *write;
int err;
Index: gstate.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/gstate.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- gstate.c 23 Dec 2004 22:39:40 -0000 1.6
+++ gstate.c 11 Feb 2005 21:15:46 -0000 1.7
@@ -157,7 +157,7 @@
RETURN (Void);
for (i = 0; i < ndash; i++)
{
- d[i] = DoublePart (ArrayValueGet(&dv->array, i), "invalid dash length");
+ d[i] = DoublePart (ArrayValue(&dv->array, i), "invalid dash length");
if (aborting)
RETURN (Void);
}
Index: gtk.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/gtk.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- gtk.c 24 Dec 2004 09:00:10 -0000 1.6
+++ gtk.c 11 Feb 2005 21:15:46 -0000 1.7
@@ -404,6 +404,11 @@
Bool
cairo_5c_tool_destroy (cairo_5c_surface_t *c5s)
{
+ cairo_5c_tool_t *tool = c5s->u.window.tool;
+
+ gdk_threads_enter ();
+ gtk_widget_hide (tool->window);
+ gdk_threads_leave ();
/* let nickle allocator free it */
return True;
}
Index: init.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/init.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- init.c 24 Dec 2004 09:00:10 -0000 1.11
+++ init.c 11 Feb 2005 21:15:46 -0000 1.12
@@ -515,6 +515,16 @@
"\n"
" Stroke the current path\n" },
+ { do_Cairo_copy_page, "copy_page", "v", CAIRO_S, "\n"
+ " void copy_page (cairo_t cairo)\n"
+ "\n"
+ " Write out the current page, leaving it intact.\n" },
+
+ { do_Cairo_show_page, "show_page", "v", CAIRO_S, "\n"
+ " void show_page (cairo_t cairo)\n"
+ "\n"
+ " Write out the current page, and erase it.\n" },
+
{ do_Cairo_current_path_flat_list, "current_path_flat_list", PATH_S, CAIRO_S, "\n"
" void current_path_flat (cairo_t cr)\n"
"\n"
@@ -783,13 +793,13 @@
static const struct fbuiltin_6 funcs_6[] = {
{ do_Cairo_arc, "arc", "v", CAIRO_S "nnnnn", "\n"
- " void arc (cairo_t cr, real x1, real y1, real x2, real y2, real radius)\n"
+ " void arc (cairo_t cr, real xc, real yc, real r, real angle1, real angle2)\n"
"\n"
- " Draw a clockwise arc from x1,y1 to x2,y2 with the given radius\n" },
+ " Draw a clockwise arc centered at xc,yc from angle1 to angle2 with the given radius\n" },
{ do_Cairo_arc_negative, "arc_negative", "v", CAIRO_S "nnnnn", "\n"
- " void arc (cairo_t cr, real x1, real y1, real x2, real y2, real radius)\n"
+ " void arc (cairo_t cr, real xc, real yc, real r, real angle1, real angle2)\n"
"\n"
- " Draw a counter-clockwise arc from x1,y1 to x2,y2 with the given radius\n" },
+ " Draw a counter-clockwise arc centered at xc,yc from angle1 to angle2 with the given radius\n" },
{ 0 }
};
Index: matrix.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/matrix.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- matrix.c 18 Dec 2004 01:09:40 -0000 1.1
+++ matrix.c 11 Feb 2005 21:15:46 -0000 1.2
@@ -38,12 +38,12 @@
cairo_matrix_t *
cairo_matrix_part (Value mv, char *err)
{
- double a = DoublePart (ArrayValueGet(&mv->array, 0), "invalid matrix");
- double b = DoublePart (ArrayValueGet(&mv->array, 1), "invalid matrix");
- double c = DoublePart (ArrayValueGet(&mv->array, 2), "invalid matrix");
- double d = DoublePart (ArrayValueGet(&mv->array, 3), "invalid matrix");
- double tx = DoublePart (ArrayValueGet(&mv->array, 4), "invalid matrix");
- double ty = DoublePart (ArrayValueGet(&mv->array, 5), "invalid matrix");
+ double a = DoublePart (ArrayValue(&mv->array, 0), "invalid matrix");
+ double b = DoublePart (ArrayValue(&mv->array, 1), "invalid matrix");
+ double c = DoublePart (ArrayValue(&mv->array, 2), "invalid matrix");
+ double d = DoublePart (ArrayValue(&mv->array, 3), "invalid matrix");
+ double tx = DoublePart (ArrayValue(&mv->array, 4), "invalid matrix");
+ double ty = DoublePart (ArrayValue(&mv->array, 5), "invalid matrix");
cairo_matrix_t *matrix;
if (aborting)
Index: surface.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/surface.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- surface.c 24 Dec 2004 09:00:10 -0000 1.9
+++ surface.c 11 Feb 2005 21:15:46 -0000 1.10
@@ -109,6 +109,7 @@
cairo_5c_surface_mark (void *object)
{
cairo_5c_surface_t *c5s = object;
+
MemReference (c5s->recv_events);
switch (c5s->kind) {
case CAIRO_5C_WINDOW:
@@ -121,21 +122,58 @@
}
}
-static int
-cairo_5c_surface_free (void *object)
+static void
+cairo_5c_surface_destroy (cairo_5c_surface_t *c5s)
{
- cairo_5c_surface_t *c5s = object;
+
+ if (!c5s->surface)
+ return;
+
+ switch (c5s->kind) {
+ case CAIRO_5C_PNG:
+ case CAIRO_5C_PS:
+ FilePrintf (FileStdout, "Copied %d\n", c5s->copied);
+ if (!c5s->copied)
+ {
+ cairo_t *cr = cairo_create ();
+ if (cr)
+ {
+ cairo_set_target_surface (cr, c5s->surface);
+ cairo_copy_page (cr);
+ cairo_destroy (cr);
+ }
+ }
+ break;
+ default:
+ break;
+ }
cairo_surface_destroy (c5s->surface);
+ c5s->surface = 0;
+
switch (c5s->kind) {
case CAIRO_5C_WINDOW:
cairo_5c_tool_destroy (c5s);
break;
case CAIRO_5C_PNG:
+ fclose (c5s->u.png.file);
+ c5s->u.png.file = NULL;
+ break;
case CAIRO_5C_PS:
+ fclose (c5s->u.ps.file);
+ c5s->u.ps.file = NULL;
+ break;
case CAIRO_5C_SCRATCH:
break;
}
+}
+
+static int
+cairo_5c_surface_free (void *object)
+{
+ cairo_5c_surface_t *c5s = object;
+
+ cairo_5c_surface_destroy (c5s);
return 1;
}
@@ -182,6 +220,7 @@
c5s->width = width;
c5s->height = height;
c5s->dirty = False;
+ c5s->copied = False;
c5s->recv_events = Void;
if (!cairo_5c_tool_create (c5s, name, width, height))
@@ -220,6 +259,7 @@
c5s->height = height;
c5s->dirty = False;
c5s->recv_events = Void;
+ c5s->copied = False;
c5s->u.png.file = fopen (filename, "w");
@@ -263,6 +303,7 @@
c5s->width = width * xppi;
c5s->height = height * yppi;
c5s->dirty = False;
+ c5s->copied = False;
c5s->recv_events = Void;
c5s->u.ps.file = fopen (filename, "w");
@@ -302,6 +343,7 @@
c5s->width = width;
c5s->height = height;
c5s->dirty = False;
+ c5s->copied = False;
c5s->recv_events = Void;
c5s->surface = cairo_surface_create_similar (c5os->surface,
@@ -322,8 +364,7 @@
if (aborting)
RETURN (Void);
- cairo_surface_destroy (c5s->surface);
- c5s->surface = 0;
+ cairo_5c_surface_destroy (c5s);
RETURN(Void);
}
More information about the cairo-commit
mailing list