[cairo-commit] cairo-5c ChangeLog, 1.25, 1.26 cairo-5c.h, 1.15, 1.16 cairo.c, 1.6, 1.7 gtk.c, 1.10, 1.11 surface.c, 1.12, 1.13

Keith Packard commit at pdx.freedesktop.org
Sat Jul 9 16:40:57 PDT 2005


Committed by: keithp

Update of /cvs/cairo/cairo-5c
In directory gabe:/tmp/cvs-serv5059

Modified Files:
	ChangeLog cairo-5c.h cairo.c gtk.c surface.c 
Log Message:
2005-07-09  Keith Packard  <keithp at keithp.com>

* cairo-5c.h:
* cairo.c: (cairo_5c_get):
* examples/animate.5c:
* gtk.c: (configure_event), (expose_event), (delete_drawing_area),
(gtk_repaint), (gtk_tool_free), (cairo_5c_tool_create),
(cairo_5c_tool_destroy):
* surface.c: (create_cairo_window):
Pass GtkPixmap objects around as they are reference counted.
Use proposed new cairo_xlib_surface_set_drawable API to
deal with window back-buffer resize issue.

Index: ChangeLog
===================================================================
RCS file: /cvs/cairo/cairo-5c/ChangeLog,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- ChangeLog	7 Jul 2005 08:09:21 -0000	1.25
+++ ChangeLog	9 Jul 2005 23:40:55 -0000	1.26
@@ -1,3 +1,16 @@
+2005-07-09  Keith Packard  <keithp at keithp.com>
+
+	* cairo-5c.h:
+	* cairo.c: (cairo_5c_get):
+	* examples/animate.5c:
+	* gtk.c: (configure_event), (expose_event), (delete_drawing_area),
+	(gtk_repaint), (gtk_tool_free), (cairo_5c_tool_create),
+	(cairo_5c_tool_destroy):
+	* surface.c: (create_cairo_window):
+	Pass GtkPixmap objects around as they're reference counted.
+	Use proposed new cairo_xlib_surface_set_drawable API to
+	deal with window back-buffer resize issue.
+
 2005-07-07  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.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- cairo-5c.h	7 Jul 2005 08:09:21 -0000	1.15
+++ cairo-5c.h	9 Jul 2005 23:40:55 -0000	1.16
@@ -47,14 +47,17 @@
 #include <stdio.h>
 #include <unistd.h>
 #undef Atom
+#define GTK_DISABLE_DEPRECATED
+#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
 
 typedef enum { CAIRO_5C_WINDOW, CAIRO_5C_IMAGE, CAIRO_5C_PDF, CAIRO_5C_SCRATCH } cairo_5c_kind_t;
 
 typedef struct _cairo_5c_tool	cairo_5c_tool_t;
 
 typedef struct _cairo_5c_window_t {
-    Pixmap	    pixmap;
-    Pixmap	    curpix;
+    GdkPixmap	    *pixmap;
+    GdkPixmap	    *curpix;
     cairo_5c_tool_t *tool;
     FILE	    *send_events;
 } cairo_5c_window_t;

Index: cairo.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/cairo.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- cairo.c	7 Jul 2005 08:09:21 -0000	1.6
+++ cairo.c	9 Jul 2005 23:40:55 -0000	1.7
@@ -63,10 +63,6 @@
 	c5s = cairo_5c_surface_get (c5c->surface);
 	if (!c5s)
 	    return 0;
-#if 0
-	if (c5s->surface != cairo_current_target_surface (c5c->cr))
-	    cairo_set_target_surface (c5c->cr, c5s->surface);
-#endif
     }
     return c5c;
 }

Index: gtk.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/gtk.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- gtk.c	7 Jul 2005 08:09:21 -0000	1.10
+++ gtk.c	9 Jul 2005 23:40:55 -0000	1.11
@@ -33,10 +33,7 @@
  *      Keith Packard <keithp at keithp.com>
  */
 
-#define GTK_DISABLE_DEPRECATED
 #include "cairo-5c.h"
-#include <gtk/gtk.h>
-#include <gdk/gdkx.h>
 #include <pthread.h>
 
 typedef struct _gtk_global {
@@ -52,7 +49,6 @@
     int			disable;
     GtkWidget		*window;
     GtkWidget		*drawing_area;
-    GdkPixmap		*pixmap;
 };
 
 static gtk_global_t *gtk_global;
@@ -67,7 +63,6 @@
 {
     GdkPixmap		*pixmap;
     cairo_5c_surface_t	*c5s = GTK_DRAWING_AREA (widget)->draw_data;
-    cairo_5c_tool_t	*tool = c5s->u.window.tool;
 
     c5s->width = widget->allocation.width;
     c5s->height = widget->allocation.height;
@@ -81,16 +76,15 @@
 			0, 0,
 			widget->allocation.width,
 			widget->allocation.height);
-    if (tool->pixmap)
+    if (c5s->u.window.pixmap)
     {
 	gdk_draw_drawable (pixmap, widget->style->white_gc,
-			   tool->pixmap, 0, 0, 0, 0, 
+			   c5s->u.window.pixmap, 0, 0, 0, 0, 
 			   widget->allocation.width,
 			   widget->allocation.height);
-	gdk_drawable_unref (tool->pixmap);
+	gdk_drawable_unref (c5s->u.window.pixmap);
     }
-    tool->pixmap = pixmap;
-    c5s->u.window.pixmap = GDK_PIXMAP_XID (GDK_DRAWABLE(tool->pixmap));
+    c5s->u.window.pixmap = pixmap;
     return TRUE;
 }
 
@@ -101,11 +95,11 @@
 expose_event( GtkWidget *widget, GdkEventExpose *event )
 {
     cairo_5c_surface_t	*c5s = GTK_DRAWING_AREA (widget)->draw_data;
-    cairo_5c_tool_t	*tool = c5s->u.window.tool;
+
     
     gdk_draw_pixmap(widget->window,
 		    widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
-		    tool->pixmap,
+		    c5s->u.window.pixmap,
 		    event->area.x, event->area.y,
 		    event->area.x, event->area.y,
 		    event->area.width, event->area.height);
@@ -130,10 +124,10 @@
     }
     tool->drawing_area = NULL;
     tool->window = NULL;
-    if (tool->pixmap)
+    if (c5s->u.window.pixmap)
     {
-	gdk_drawable_unref (tool->pixmap);
-	tool->pixmap = NULL;
+	gdk_drawable_unref (c5s->u.window.pixmap);
+	c5s->u.window.pixmap = NULL;
     }
     c5s->u.window.pixmap = None;
 }
@@ -214,7 +208,7 @@
 {
     cairo_5c_tool_t *tool = c5s->u.window.tool;
     GtkWidget	    *widget = tool->drawing_area;
-    GdkPixmap	    *pixmap = tool->pixmap;
+    GdkPixmap	    *pixmap = c5s->u.window.pixmap;
     
     if (widget && pixmap)
     {
@@ -353,11 +347,6 @@
 	tool->window = NULL;
 	tool->drawing_area = NULL;
     }
-    if (tool->pixmap)
-    {
-	gdk_drawable_unref (tool->pixmap);
-	tool->pixmap = NULL;
-    }
     gdk_threads_leave ();
     return 1;
 }
@@ -389,10 +378,12 @@
     tool->global = gg;
     tool->dirty = 0;
     tool->disable = 0;
-    tool->pixmap = 0;
     
     c5s->dirty = False;
     c5s->recv_events = Void;
+
+    c5s->u.window.curpix = 0;
+    c5s->u.window.pixmap = 0;
     c5s->u.window.send_events = 0;
     c5s->u.window.tool = tool;
     
@@ -439,9 +430,6 @@
     /* create the pixmap */
     configure_event (tool->drawing_area, 0);
     
-    /* fill in the c5s window structure */
-     
-    c5s->u.window.pixmap = GDK_PIXMAP_XID (GDK_DRAWABLE(tool->pixmap));
     gdk_threads_leave ();
     EXIT ();
     return True;
@@ -457,6 +445,11 @@
     
     gdk_threads_enter ();
     gtk_widget_hide (tool->window);
+    if (c5s->u.window.pixmap)
+    {
+	gdk_drawable_unref (c5s->u.window.pixmap);
+	c5s->u.window.pixmap = NULL;
+    }
     gdk_threads_leave ();
     /* let nickle allocator free it */
     return True;

Index: surface.c
===================================================================
RCS file: /cvs/cairo/cairo-5c/surface.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- surface.c	18 May 2005 06:21:15 -0000	1.12
+++ surface.c	9 Jul 2005 23:40:55 -0000	1.13
@@ -41,9 +41,8 @@
 create_cairo_window (cairo_5c_surface_t *c5s)
 {
     Display	*dpy = cairo_5c_tool_display (c5s);
+    Pixmap	pixmap;
     
-    if (c5s->surface)
-	cairo_surface_destroy (c5s->surface);
     if (!c5s->u.window.pixmap)
     {
 	RaiseStandardException (exception_invalid_argument,
@@ -51,12 +50,25 @@
 				2, NewInt (0), NewInt (0));
 	return False;
     }
-    c5s->surface = cairo_xlib_surface_create (dpy,
-					      c5s->u.window.pixmap,
-					      DefaultVisual (dpy, DefaultScreen (dpy)),
-					      0,
-					      DefaultColormap (dpy, DefaultScreen (dpy)));
+
+    gdk_threads_enter ();
+    gdk_drawable_ref (c5s->u.window.pixmap);
+    if (c5s->u.window.curpix)
+	gdk_drawable_unref (c5s->u.window.curpix);
     c5s->u.window.curpix = c5s->u.window.pixmap;
+    pixmap = GDK_PIXMAP_XID (GDK_DRAWABLE(c5s->u.window.curpix));
+    gdk_threads_leave ();
+    
+    if (c5s->surface)
+	cairo_xlib_surface_set_drawable (c5s->surface, pixmap,
+					 c5s->width,
+					 c5s->height);
+    else
+	c5s->surface = cairo_xlib_surface_create (dpy,
+						  pixmap,
+						  DefaultVisual (dpy, DefaultScreen (dpy)),
+						  c5s->width,
+						  c5s->height);
     return True;
 }
 




More information about the cairo-commit mailing list