From d12c9702a4428cdf83e6d0dc37b0b9e69fb19f80 Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Fri, 4 Jan 2002 05:58:01 +0000 Subject: Private function to tell if we have RENDER extension. Thu Jan 3 22:18:15 2002 Owen Taylor * gdk/x11/gdkdrawable-x11.c gdk/x11/gdkprivate-x11.h (_gdk_x11_have_render): Private function to tell if we have RENDER extension. * gdk/x11/gdkgc-x11.c (_gdk_x11_gc_get_fg_picture): Return None if we don't have RENDER extension. * gdk/x11/gdkpango-x11.c (gdk_pango_context_get): Don't use Xft unless we have render extension. * gdk/x11/gdkdrawable-x11.c (gdk_x11_drawable_get_picture): Handle missing render extension. * gdk/gdkdraw.c gdk/gdkdrawable.h gdk/gdkpixmap.c gdk/gdkwindow.c gdk/gdkinternals.h: Add a private copy_to_image() virtual function to the GdkDrawable vtable that extends get_image() to allow copying onto existing images. Make the default implementation of get_image() use this so that backends don't have to implement both. Add private wrapper _gdk_drawable_copy_to_image(). * gdk/x11/gdkimage-x11.c gdk/x11/gdkprivate-x11.c gdk/x11/gdkdrawable-x11.c (_gdk_x11_copy_to_image): Implement copy_to_image() semantics, speed up by using ShmPixmaps and XCopyArea when possible, XFlush() after ungrabbing the server, generally redo the logic once again. * gdk/gdkinternals.h gdk/x11/gdkimage-x11.c _gdk_windowing_bits_per_depth(): Function to convert from depth to bits-per-pixel. (We assume only one bpp per depth - X requires this.) * gdk/gdkinternals.h gdk/gdkrgb.c gdk/gdkimage.c: Move the GdkRGB scratch image code into a generic _gdk_image_get_scratch() chunk of code that we can use other places we need scratch images. * gdk/gdkimage.c gdk/x11/gdkimage.c gdk/gdkinternals.h: Add _gdk_image_new_for_depth() as the backend to _gdk_image_new() to allowing creating images with a depth and no visual. * gdk/gdkpixbuf-drawable.c: Fix so that getting parts of images not at 0,0 actually works. * gdk/gdkdrawable.h gdk/gdkinternals.h gdk/gdkdraw.c gdk/gdkwindow.c gdk/gdkpixmap.c gdk/gdkpixbuf-render.c: - Add a new GdkDrawableClass vfunc _draw_pixbuf, and _gdk_draw_pixbuf() [ will be made public later ], to allow backends to accelerate drawing pixbufs. - Move the implementation of gdk_pixbuf_render_to_drawable_alpha() to be the default implementation. - Update docs for gdk_pixbuf_render_to_drawable_alpha(). - Optimize the default implementation by using _gdk_image_copy_to_pixmap() and scratch shared images, and special casing the compositing. * gdk/x11/gdkdrawable-x11.c: Accelerate _gdk_draw_pixbuf() with alpha using the RENDER extension. * gdk/gdkpixbuf-drawable.c (gdk_pixbuf_get_from_drawable): Optimize by _gdk_image_copy_to_pixmap() and scratch images. * tests/testrgb.c: Add test for speed of alpha composition, reduce the number of iterations since alpha composition can be a bit slow. * gdk/x11/gdkimage-x11.c gdk/gdkprivate-x11.h (_gdk_x11_image_get_shm_pixmap): Private function to get a ShmPixmap for an image, if possible. --- gdk/gdkpixmap.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 56 insertions(+), 13 deletions(-) (limited to 'gdk/gdkpixmap.c') diff --git a/gdk/gdkpixmap.c b/gdk/gdkpixmap.c index 088e181a5..5e757246f 100644 --- a/gdk/gdkpixmap.c +++ b/gdk/gdkpixmap.c @@ -102,16 +102,32 @@ static void gdk_pixmap_draw_image (GdkDrawable *drawable, gint ydest, gint width, gint height); +static void gdk_pixmap_draw_pixbuf (GdkDrawable *drawable, + GdkGC *gc, + GdkPixbuf *pixbuf, + gint src_x, + gint src_y, + gint dest_x, + gint dest_y, + gint width, + gint height, + GdkRgbDither dither, + gint x_dither, + gint y_dither); + static void gdk_pixmap_real_get_size (GdkDrawable *drawable, gint *width, gint *height); -static GdkImage* gdk_pixmap_get_image (GdkDrawable *drawable, - gint x, - gint y, - gint width, - gint height); +static GdkImage* gdk_pixmap_copy_to_image (GdkDrawable *drawable, + GdkImage *image, + gint src_x, + gint src_y, + gint dest_x, + gint dest_y, + gint width, + gint height); static GdkVisual* gdk_pixmap_real_get_visual (GdkDrawable *drawable); static gint gdk_pixmap_real_get_depth (GdkDrawable *drawable); @@ -182,12 +198,13 @@ gdk_pixmap_class_init (GdkPixmapObjectClass *klass) drawable_class->draw_lines = gdk_pixmap_draw_lines; drawable_class->draw_glyphs = gdk_pixmap_draw_glyphs; drawable_class->draw_image = gdk_pixmap_draw_image; + drawable_class->_draw_pixbuf = gdk_pixmap_draw_pixbuf; drawable_class->get_depth = gdk_pixmap_real_get_depth; drawable_class->get_size = gdk_pixmap_real_get_size; drawable_class->set_colormap = gdk_pixmap_real_set_colormap; drawable_class->get_colormap = gdk_pixmap_real_get_colormap; drawable_class->get_visual = gdk_pixmap_real_get_visual; - drawable_class->get_image = gdk_pixmap_get_image; + drawable_class->_copy_to_image = gdk_pixmap_copy_to_image; } static void @@ -366,6 +383,27 @@ gdk_pixmap_draw_image (GdkDrawable *drawable, width, height); } +static void +gdk_pixmap_draw_pixbuf (GdkDrawable *drawable, + GdkGC *gc, + GdkPixbuf *pixbuf, + gint src_x, + gint src_y, + gint dest_x, + gint dest_y, + gint width, + gint height, + GdkRgbDither dither, + gint x_dither, + gint y_dither) +{ + GdkPixmapObject *private = (GdkPixmapObject *)drawable; + + _gdk_draw_pixbuf (private->impl, gc, pixbuf, + src_x, src_y, dest_x, dest_y, width, height, + dither, x_dither, y_dither); +} + static void gdk_pixmap_real_get_size (GdkDrawable *drawable, gint *width, @@ -418,16 +456,21 @@ gdk_pixmap_real_get_colormap (GdkDrawable *drawable) } static GdkImage* -gdk_pixmap_get_image (GdkDrawable *drawable, - gint x, - gint y, - gint width, - gint height) +gdk_pixmap_copy_to_image (GdkDrawable *drawable, + GdkImage *image, + gint src_x, + gint src_y, + gint dest_x, + gint dest_y, + gint width, + gint height) { g_return_val_if_fail (GDK_IS_PIXMAP (drawable), NULL); - return gdk_drawable_get_image (((GdkPixmapObject*)drawable)->impl, - x, y, width, height); + return _gdk_drawable_copy_to_image (((GdkPixmapObject*)drawable)->impl, + image, + src_x, src_y, dest_x, dest_y, + width, height); } static GdkBitmap * -- cgit v1.2.1