GdkTrapezoid *trapezoids,
gint n_trapezoids);
+static void gdk_x11_set_cairo_target (GdkDrawable *drawable,
+ cairo_t *cr);
+
static void gdk_x11_set_colormap (GdkDrawable *drawable,
GdkColormap *colormap);
drawable_class->draw_pixbuf = gdk_x11_draw_pixbuf;
drawable_class->draw_trapezoids = gdk_x11_draw_trapezoids;
+ drawable_class->set_cairo_target = gdk_x11_set_cairo_target;
+
drawable_class->set_colormap = gdk_x11_set_colormap;
drawable_class->get_colormap = gdk_x11_get_colormap;
g_free (xtrapezoids);
}
+static cairo_surface_t *
+gdk_x11_drawable_get_cairo_surface (GdkDrawable *drawable)
+{
+ GdkDrawableImplX11 *impl = GDK_DRAWABLE_IMPL_X11 (drawable);
+ GdkColormap *colormap;
+ GdkVisual *visual;
+
+ if (GDK_IS_WINDOW_IMPL_X11 (drawable) &&
+ GDK_WINDOW_DESTROYED (impl->wrapper))
+ return NULL;
+
+ colormap = gdk_drawable_get_colormap (drawable);
+ if (!colormap)
+ {
+ g_warning ("Using Cairo rendering requires the drawable argument to\n"
+ "have a specified colormap. All windows have a colormap,\n"
+ "however, pixmaps only have colormap by default if they\n"
+ "were created with a non-NULL window argument. Otherwise\n"
+ "a colormap must be set on them with gdk_drawable_set_colormap");
+ return NULL;
+ }
+
+ visual = gdk_colormap_get_visual (colormap);
+
+ if (!impl->cairo_surface)
+ {
+ impl->cairo_surface = cairo_xlib_surface_create (GDK_SCREEN_XDISPLAY (impl->screen),
+ impl->xid,
+ GDK_VISUAL_XVISUAL (visual),
+ CAIRO_FORMAT_RGB24,
+ GDK_COLORMAP_XCOLORMAP (colormap));
+ }
+
+ return impl->cairo_surface;
+}
+
+static void
+gdk_x11_set_cairo_target (GdkDrawable *drawable,
+ cairo_t *cr)
+{
+ cairo_surface_t *surface = gdk_x11_drawable_get_cairo_surface (drawable);
+ if (surface)
+ cairo_set_target_surface (cr, surface);
+}
+
/**
* gdk_draw_rectangle_alpha_libgtk_only:
* @drawable: The #GdkDrawable to draw on