diff options
author | Owen Taylor <otaylor@redhat.com> | 2005-02-03 23:29:02 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2005-02-03 23:29:02 +0000 |
commit | 93344f6dfee0d21e5e9aa750b5a91ed10980cd24 (patch) | |
tree | 71978aa4f489edd13c2d71b55344921f0fdaab5b /gdk/x11/gdkdrawable-x11.c | |
parent | 8a5d05e253490a5851b7e142f4090971153c1178 (diff) | |
download | gtk+-93344f6dfee0d21e5e9aa750b5a91ed10980cd24.tar.gz |
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.
Diffstat (limited to 'gdk/x11/gdkdrawable-x11.c')
-rw-r--r-- | gdk/x11/gdkdrawable-x11.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/gdk/x11/gdkdrawable-x11.c b/gdk/x11/gdkdrawable-x11.c index c6f3142072..19c7b9264a 100644 --- a/gdk/x11/gdkdrawable-x11.c +++ b/gdk/x11/gdkdrawable-x11.c @@ -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 |