Add gdk_drawable_set_cairo_target().
2005-02-03 Owen Taylor <otaylor@redhat.com> * gdk/gdkdrawable.[ch] gdkpixmap.c gdkwindow.c: Add gdk_drawable_set_cairo_target(). * tests/testtreeflow.c (enum): Use grand not rand as a variable name because one of the cairo headers is pulling in stdlib.h. * tests/testcairo.c tests/Makefile.am: Add a simple cairo based example. * configure.in: Bump release to 2.7.0, gtk_binary_version to 2.7.0. * Require libpangocairo for all backends.
This commit is contained in:
@ -147,6 +147,9 @@ static void gdk_x11_draw_trapezoids (GdkDrawable *drawable,
|
||||
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);
|
||||
|
||||
@ -215,6 +218,8 @@ gdk_drawable_impl_x11_class_init (GdkDrawableImplX11Class *klass)
|
||||
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;
|
||||
|
||||
@ -1558,6 +1563,51 @@ gdk_x11_draw_trapezoids (GdkDrawable *drawable,
|
||||
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
|
||||
|
||||
@ -71,6 +71,7 @@ struct _GdkDrawableImplX11
|
||||
GdkScreen *screen;
|
||||
|
||||
XftDraw *xft_draw;
|
||||
cairo_surface_t *cairo_surface;
|
||||
};
|
||||
|
||||
struct _GdkDrawableImplX11Class
|
||||
|
||||
@ -135,6 +135,12 @@ gdk_pixmap_impl_x11_finalize (GObject *object)
|
||||
if (draw_impl->xft_draw)
|
||||
XftDrawDestroy (draw_impl->xft_draw);
|
||||
|
||||
if (draw_impl->cairo_surface)
|
||||
{
|
||||
cairo_surface_destroy (draw_impl->cairo_surface);
|
||||
draw_impl->cairo_surface = NULL;
|
||||
}
|
||||
|
||||
if (!impl->is_foreign)
|
||||
XFreePixmap (GDK_DISPLAY_XDISPLAY (display), GDK_PIXMAP_XID (wrapper));
|
||||
}
|
||||
|
||||
@ -1144,7 +1144,16 @@ _gdk_windowing_window_destroy (GdkWindow *window,
|
||||
draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl);
|
||||
|
||||
if (draw_impl->xft_draw)
|
||||
XftDrawDestroy (draw_impl->xft_draw);
|
||||
{
|
||||
XftDrawDestroy (draw_impl->xft_draw);
|
||||
draw_impl->xft_draw = NULL;
|
||||
}
|
||||
|
||||
if (draw_impl->cairo_surface)
|
||||
{
|
||||
cairo_surface_destroy (draw_impl->cairo_surface);
|
||||
draw_impl->cairo_surface = NULL;
|
||||
}
|
||||
|
||||
if (!recursing && !foreign_destroy)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user