[cairo-commit] gtkcairo/gtkcairo gdkcairo.c, 1.14, 1.15 gtkcairo.c,
1.18, 1.19
Oeyvind Kolaas
commit at pdx.freedesktop.org
Sun Aug 7 15:57:11 PDT 2005
Committed by: pippin
Update of /cvs/cairo/gtkcairo/gtkcairo
In directory gabe:/tmp/cvs-serv29509/gtkcairo
Modified Files:
gdkcairo.c gtkcairo.c
Log Message:
Sync up with cairo api
Index: gdkcairo.c
===================================================================
RCS file: /cvs/cairo/gtkcairo/gtkcairo/gdkcairo.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- gdkcairo.c 30 Mar 2005 12:54:35 -0000 1.14
+++ gdkcairo.c 7 Aug 2005 22:57:09 -0000 1.15
@@ -29,13 +29,16 @@
#include <cairo-xlib.h>
#endif
+#ifdef CAIRO_HAS_GLITZ_SURFACE
+#include <cairo-glitz.h>
+#endif
+
static void
gdkcairo_init (gdkcairo_t *self,
GtkWidget *widget)
{
self->widget = widget;
- self->cr = cairo_create ();
-
+ self->cr = NULL;
self->backend = GDKCAIRO_BACKEND_IMAGE;
#ifdef CAIRO_HAS_XLIB_SURFACE
@@ -110,11 +113,22 @@
void
gdkcairo_destroy (gdkcairo_t *self)
{
- if (self->cr)
+ GtkWidget *widget = self->widget;
+
+ if (self->cr != NULL)
{
cairo_destroy (self->cr);
self->cr = NULL;
}
+#ifdef USE_GL
+ if (self->glitz_surface != NULL)
+ {
+ glitz_surface_destroy (self->glitz_surface);
+ self->glitz_surface = NULL;
+ }
+#endif
+ /* FIXME: gtk_style_detach (self->widget->style) is missing */
+ /* FIXME: how is self freed? */
}
void
@@ -199,6 +213,7 @@
glitz_drawable_t *drawable;
glitz_format_t *format;
XID xid;
+ cairo_surface_t *cr_surface;
vinfo = glitz_glx_get_visual_info_from_format (dpy, screen,
dformat);
@@ -237,7 +252,9 @@
glitz_drawable_destroy (drawable);
- cairo_set_target_glitz (self->cr, self->glitz_surface);
+ cr_surface = cairo_glitz_surface_create (self->glitz_surface);
+ self->cr = cairo_create (cr_surface);
+ cairo_surface_destroy (cr_surface);
}
else
{
@@ -281,11 +298,15 @@
glitz_format_t *format;
glitz_drawable_t *drawable;
glitz_drawable_format_t *dformat;
+ cairo_surface_t *cr_surface;
format = glitz_surface_get_format (self->glitz_surface);
drawable = glitz_surface_get_drawable (self->glitz_surface);
+ glitz_drawable_reference (drawable);
dformat = glitz_drawable_get_format (drawable);
+ cairo_destroy (self->cr);
+
glitz_surface_destroy (self->glitz_surface);
glitz_drawable_update_size (drawable, width, height);
@@ -293,6 +314,7 @@
self->glitz_surface =
glitz_surface_create (drawable, format, width, height,
0, NULL);
+ glitz_drawable_destroy(drawable);
glitz_surface_attach (self->glitz_surface,
drawable,
@@ -300,7 +322,9 @@
GLITZ_DRAWABLE_BUFFER_BACK_COLOR :
GLITZ_DRAWABLE_BUFFER_FRONT_COLOR, 0, 0);
- cairo_set_target_glitz (self->cr, self->glitz_surface);
+ cr_surface = cairo_glitz_surface_create (self->glitz_surface);
+ self->cr = cairo_create (cr_surface);
+ cairo_surface_destroy (cr_surface);
}
break;
@@ -337,7 +361,11 @@
cairo_fill (self->cr);
cairo_restore (self->cr);
+ cairo_save (self->cr);
g_signal_emit_by_name (self->widget, "paint", self->cr);
+ cairo_restore (self->cr);
+
+ /* FIXME: flush cairo first. */
drawable = glitz_surface_get_drawable (self->glitz_surface);
dformat = glitz_drawable_get_format (drawable);
@@ -356,28 +384,28 @@
{
GdkDrawable *gdkdrawable;
gint x_off, y_off;
+ gint width, height;
+ cairo_surface_t *x11_surface;
+ /* find drawable, offset and size */
gdk_window_get_internal_paint_info (widget->window,
&gdkdrawable, &x_off, &y_off);
+ gdk_drawable_get_size (gdkdrawable, &width, &height);
- cairo_set_target_drawable (self->cr,
- gdk_x11_drawable_get_xdisplay
- (gdkdrawable),
- gdk_x11_drawable_get_xid (gdkdrawable));
+ x11_surface = cairo_xlib_surface_create
+ (gdk_x11_drawable_get_xdisplay (gdkdrawable),
+ gdk_x11_drawable_get_xid (gdkdrawable),
+ gdk_x11_visual_get_xvisual (gdk_drawable_get_visual (gdkdrawable)),
+ width, height);
+ cairo_surface_set_device_offset (x11_surface, -x_off, -y_off);
- /* counter offset of expose */
- if (x_off || y_off)
- {
- cairo_save (self->cr);
- cairo_translate (self->cr, -x_off, -y_off);
- }
+ self->cr = cairo_create (x11_surface);
+ cairo_surface_destroy (x11_surface);
g_signal_emit_by_name (self->widget, "paint", self->cr);
- if (x_off || y_off)
- {
- cairo_restore (self->cr);
- }
+ cairo_destroy (self->cr);
+ self->cr = NULL;
}
break;
#endif
Index: gtkcairo.c
===================================================================
RCS file: /cvs/cairo/gtkcairo/gtkcairo/gtkcairo.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- gtkcairo.c 11 Dec 2004 16:04:42 -0000 1.18
+++ gtkcairo.c 7 Aug 2005 22:57:09 -0000 1.19
@@ -177,9 +177,7 @@
gtkcairo = GTK_CAIRO (widget);
- cairo_save (gtk_cairo_get_cairo (gtkcairo));
gdkcairo_expose (gtkcairo->gdkcairo, event);
- cairo_restore (gtk_cairo_get_cairo (gtkcairo));
return FALSE;
}
@@ -201,7 +199,7 @@
green = color->green / 65535.0;
blue = color->blue / 65535.0;
- cairo_set_rgb_color (cr, red, green, blue);
+ cairo_set_source_rgb (cr, red, green, blue);
}
int
More information about the cairo-commit
mailing list