diff options
author | Owen Taylor <otaylor@redhat.com> | 2002-01-04 05:58:01 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2002-01-04 05:58:01 +0000 |
commit | d12c9702a4428cdf83e6d0dc37b0b9e69fb19f80 (patch) | |
tree | f9d643f1b7ec3efb015346a76f4b412a9e1cd70c /tests | |
parent | a755adc58d6bc5ebb1a9c0ffa4825f44307420cf (diff) | |
download | gdk-pixbuf-d12c9702a4428cdf83e6d0dc37b0b9e69fb19f80.tar.gz |
Private function to tell if we have RENDER extension.
Thu Jan 3 22:18:15 2002 Owen Taylor <otaylor@redhat.com>
* 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.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/testrgb.c | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/tests/testrgb.c b/tests/testrgb.c index 12f088f60..9a61f92f8 100644 --- a/tests/testrgb.c +++ b/tests/testrgb.c @@ -48,7 +48,7 @@ quit_func (GtkWidget *widget, gpointer dummy) #define WIDTH 640 #define HEIGHT 400 -#define NUM_ITERS 100 +#define NUM_ITERS 50 static void testrgb_rgb_test (GtkWidget *drawing_area) @@ -62,11 +62,13 @@ testrgb_rgb_test (GtkWidget *drawing_area) gboolean dither; int dith_max; GTimer *timer; - - buf = g_malloc (WIDTH * HEIGHT * 6); + GdkPixbuf *pixbuf; + gboolean to_pixmap; + + buf = g_malloc (WIDTH * HEIGHT * 8); val = 0; - for (j = 0; j < WIDTH * HEIGHT * 6; j++) + for (j = 0; j < WIDTH * HEIGHT * 8; j++) { val = (val + ((val + (rand () & 0xff)) >> 1)) >> 1; buf[j] = val; @@ -103,6 +105,7 @@ testrgb_rgb_test (GtkWidget *drawing_area) GDK_RGB_DITHER_NONE, buf + offset, WIDTH * 3); } + gdk_flush (); total_time = g_timer_elapsed (timer, NULL) - start_time; g_print ("Color test%s time elapsed: %.2fs, %.1f fps, %.2f megapixels/s\n", dither ? " (dithered)" : "", @@ -124,6 +127,7 @@ testrgb_rgb_test (GtkWidget *drawing_area) GDK_RGB_DITHER_NONE, buf + offset, WIDTH); } + gdk_flush (); total_time = g_timer_elapsed (timer, NULL) - start_time; g_print ("Grayscale test%s time elapsed: %.2fs, %.1f fps, %.2f megapixels/s\n", dither ? " (dithered)" : "", @@ -132,6 +136,42 @@ testrgb_rgb_test (GtkWidget *drawing_area) NUM_ITERS * (WIDTH * HEIGHT * 1e-6) / total_time); } + for (to_pixmap = FALSE; to_pixmap <= TRUE; to_pixmap++) + { + if (to_pixmap) + { + GdkRectangle rect = { 0, 0, WIDTH, HEIGHT }; + gdk_window_begin_paint_rect (drawing_area->window, &rect); + } + + start_time = g_timer_elapsed (timer, NULL); + for (i = 0; i < NUM_ITERS; i++) + { + offset = (rand () % (WIDTH * HEIGHT * 4)) & -4; + pixbuf = gdk_pixbuf_new_from_data (buf + offset, GDK_COLORSPACE_RGB, TRUE, + 8, WIDTH, HEIGHT, WIDTH * 4, + NULL, NULL); + gdk_pixbuf_render_to_drawable_alpha (pixbuf, drawing_area->window, + 0, 0, 0, 0, WIDTH, HEIGHT, + GDK_PIXBUF_ALPHA_FULL, /* ignored */ + 0x80, /* ignored */ + GDK_RGB_DITHER_NORMAL, + 0, 0); + gdk_pixbuf_unref (pixbuf); + } + gdk_flush (); + total_time = g_timer_elapsed (timer, NULL) - start_time; + + if (to_pixmap) + gdk_window_end_paint (drawing_area->window); + + g_print ("Alpha test%s time elapsed: %.2fs, %.1f fps, %.2f megapixels/s\n", + to_pixmap ? " (to pixmap)" : "", + total_time, + NUM_ITERS / total_time, + NUM_ITERS * (WIDTH * HEIGHT * 1e-6) / total_time); + } + g_print ("Please submit these results to http://www.levien.com/gdkrgb/survey.html\n"); #if 1 |