more benchmark fodder



Here are some more patches as benchmarking input.
These are about the shared memory area which gdk allocates
for image transport to the X server.

The first patch just turns off the shared memory, but still allocates
the same amount of scratch GdkImages.

The second patch does away with the scratch images altogether
and just allocates and frees a suitable GdkImage whenever one
is needed.

Matthias
Index: gdk/gdkimage.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkimage.c,v
retrieving revision 1.38
diff -u -r1.38 gdkimage.c
--- gdk/gdkimage.c	12 Jan 2006 13:50:51 -0000	1.38
+++ gdk/gdkimage.c	7 Jul 2006 23:32:02 -0000
@@ -252,6 +252,7 @@
   GSList *tmp_list;
   GdkScratchImageInfo *image_info;
   gint i;
+  gboolean allocated = FALSE;
 
   tmp_list = scratch_image_infos;
   while (tmp_list)
@@ -272,18 +273,21 @@
                     G_CALLBACK (scratch_image_info_display_closed),
                     image_info);
 
+#if 0
   /* Try to allocate as few possible shared images */
   for (i=0; i < G_N_ELEMENTS (possible_n_images); i++)
     {
       if (allocate_scratch_images (image_info, possible_n_images[i], TRUE))
 	{
 	  image_info->n_images = possible_n_images[i];
+          allocated = TRUE;
 	  break;
 	}
     }
+#endif
 
   /* If that fails, just allocate N_REGIONS normal images */
-  if (i == G_N_ELEMENTS (possible_n_images))
+  if (!allocated)
     {
       allocate_scratch_images (image_info, N_REGIONS, FALSE);
       image_info->n_images = N_REGIONS;
? gdk/.gdkdraw.c.swp
Index: gdk/gdkdraw.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkdraw.c,v
retrieving revision 1.65
diff -u -r1.65 gdkdraw.c
--- gdk/gdkdraw.c	14 May 2006 03:58:05 -0000	1.65
+++ gdk/gdkdraw.c	8 Jul 2006 00:01:06 -0000
@@ -1561,6 +1561,9 @@
        */
       if (composite_func && !(dither == GDK_RGB_DITHER_MAX && visual->depth != 24))
 	{
+
+#if 0
+
 	  gint x0, y0;
 	  for (y0 = 0; y0 < height; y0 += GDK_SCRATCH_IMAGE_HEIGHT)
 	    {
@@ -1591,7 +1594,30 @@
 				  width1, height1);
 		}
 	    }
-	  
+
+#else
+
+  	  GdkImage *image;
+
+          image = _gdk_image_new_for_depth (gdk_drawable_get_screen (drawable),
+                                            GDK_IMAGE_NORMAL,
+                                            NULL, 
+                                            width, height,
+                                            gdk_drawable_get_depth (drawable));
+          gdk_drawable_copy_to_image (drawable, image, dest_x, dest_y,
+                                      0, 0, width, height);
+          (*composite_func) (pixbuf->pixels + src_y * pixbuf->rowstride + src_x * 4,
+                             pixbuf->rowstride,
+                             (guchar*)image->mem,
+                             image->bpl,
+                             visual->byte_order,
+                             width, height);
+          gdk_draw_image (drawable, gc, image, 0, 0,	
+                          dest_x, dest_y, width, height);
+          
+          g_object_unref (image);
+
+#endif	  
 	  goto out;
 	}
       else
Index: gdk/gdkimage.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkimage.c,v
retrieving revision 1.38
diff -u -r1.38 gdkimage.c
--- gdk/gdkimage.c	12 Jan 2006 13:50:51 -0000	1.38
+++ gdk/gdkimage.c	8 Jul 2006 00:01:07 -0000
@@ -252,6 +252,7 @@
   GSList *tmp_list;
   GdkScratchImageInfo *image_info;
   gint i;
+  gboolean allocated = FALSE;
 
   tmp_list = scratch_image_infos;
   while (tmp_list)
@@ -272,18 +273,21 @@
                     G_CALLBACK (scratch_image_info_display_closed),
                     image_info);
 
+#if 0
   /* Try to allocate as few possible shared images */
   for (i=0; i < G_N_ELEMENTS (possible_n_images); i++)
     {
       if (allocate_scratch_images (image_info, possible_n_images[i], TRUE))
 	{
 	  image_info->n_images = possible_n_images[i];
+          allocated = TRUE;
 	  break;
 	}
     }
+#endif
 
   /* If that fails, just allocate N_REGIONS normal images */
-  if (i == G_N_ELEMENTS (possible_n_images))
+  if (!allocated)
     {
       allocate_scratch_images (image_info, N_REGIONS, FALSE);
       image_info->n_images = N_REGIONS;
Index: gdk/x11/gdkdrawable-x11.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkdrawable-x11.c,v
retrieving revision 1.61
diff -u -r1.61 gdkdrawable-x11.c
--- gdk/x11/gdkdrawable-x11.c	14 May 2006 03:58:06 -0000	1.61
+++ gdk/x11/gdkdrawable-x11.c	8 Jul 2006 00:01:08 -0000
@@ -1222,6 +1222,8 @@
   
   pix_gc = _gdk_drawable_get_scratch_gc (pix, FALSE);
 
+#if 0
+
   for (y0 = 0; y0 < height; y0 += GDK_SCRATCH_IMAGE_HEIGHT)
     {
       gint height1 = MIN (height - y0, GDK_SCRATCH_IMAGE_HEIGHT);
@@ -1242,6 +1244,25 @@
 			  image, xs0, ys0, x0, y0, width1, height1);
 	}
     }
+
+#else
+
+  image = _gdk_image_new_for_depth (screen,
+                                    GDK_IMAGE_NORMAL,
+                                    NULL,
+                                    width, height, 
+                                    32);
+  
+  _gdk_x11_convert_to_format (src_rgb, src_rowstride,
+                              (guchar *)image->mem, image->bpl,
+                              format_type, image->byte_order,
+                              width, height);
+
+  gdk_draw_image (pix, pix_gc, image, 0, 0, 0, 0, width, height);
+
+  g_object_unref (image);
+
+#endif
   
   XRenderComposite (xdisplay, PictOpOver, pict, mask, dest_pict, 
 		    0, 0, 0, 0, dest_x, dest_y, width, height);
@@ -1332,6 +1353,8 @@
 
   dest_pict = gdk_x11_drawable_get_picture (drawable);
   
+#if 0
+
   for (y0 = 0; y0 < height; y0 += GDK_SCRATCH_IMAGE_HEIGHT)
     {
       gint height1 = MIN (height - y0, GDK_SCRATCH_IMAGE_HEIGHT);
@@ -1356,6 +1379,27 @@
 			    width1, height1);
 	}
     }
+
+#else
+
+  image = _gdk_image_new_for_depth (GDK_DRAWABLE_IMPL_X11 (drawable)->screen,
+                                    GDK_IMAGE_NORMAL,
+                                    NULL, 
+                                    width, height, 32);
+  if (!get_shm_pixmap_for_image (xdisplay, image, format, mask_format, &pix, &pict, &mask))
+    return FALSE;
+
+  _gdk_x11_convert_to_format (src_rgb, src_rowstride,
+                              (guchar *)image->mem, image->bpl,
+                              format_type, image->byte_order,
+                              width, height);
+
+  XRenderComposite (xdisplay, PictOpOver, pict, mask, dest_pict,
+                    0, 0, 0, 0, dest_x, dest_y, width, height);
+
+  g_object_unref (image); 
+
+#endif
 
   return TRUE;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]