pixman: Branch 'master'

Søren Sandmann Pedersen sandmann at kemper.freedesktop.org
Sun Jun 17 15:59:44 PDT 2007


 pixman/Makefile.am      |    3 +-
 pixman/pixman-pict.c    |    9 +++++--
 pixman/pixman-private.h |   46 +++++++++++++++++++++++++++++++++++++
 pixman/pixman-timer.c   |   59 ++++++++++++++++++++++++++++++++++++++++++++++++
 test/gradient-test.c    |    1 
 5 files changed, 115 insertions(+), 3 deletions(-)

New commits:
diff-tree 647852d714ddfe6e1d71af1f4aea0e272c459fc6 (from ad80d4d2bc8c4e37a8266b98a2241c0ebd7f0e43)
Author: Søren Sandmann <sandmann at redhat.com>
Date:   Sun Jun 17 18:55:37 2007 -0400

    Add timer macros

diff --git a/pixman/Makefile.am b/pixman/Makefile.am
index a444fe7..90c6436 100644
--- a/pixman/Makefile.am
+++ b/pixman/Makefile.am
@@ -11,7 +11,8 @@ libpixman_la_SOURCES =		\
 	pixman-edge.c		\
 	pixman-edge-imp.h	\
 	pixman-trap.c		\
-	pixman-compute-region.c
+	pixman-compute-region.c \
+	pixman-timer.c
 
 libpixmanincludedir = $(includedir)/pixman
 libpixmaninclude_HEADERS = pixman.h
diff --git a/pixman/pixman-pict.c b/pixman/pixman-pict.c
index afe44cc..3777515 100644
--- a/pixman/pixman-pict.c
+++ b/pixman/pixman-pict.c
@@ -1089,6 +1089,8 @@ pixman_image_composite_rect  (pixman_op_
     return_if_fail (src != NULL);
     return_if_fail (dest != NULL);
     
+    TIMER_BEGIN (pixman_image_composite);
+    
     if (width > SCANLINE_BUFFER_LENGTH)
     {
 	scanline_buffer = (uint32_t *)malloc (width * 3 * sizeof (uint32_t));
@@ -1114,7 +1116,10 @@ pixman_image_composite_rect  (pixman_op_
 
     if (scanline_buffer != _scanline_buffer)
 	free (scanline_buffer);
-}
+
+    TIMER_END (pixman_image_composite);
+}    
+
 
 void
 pixman_image_composite (pixman_op_t      op,
@@ -1138,7 +1143,7 @@ pixman_image_composite (pixman_op_t     
     pixman_bool_t	maskAlphaMap = FALSE;
     pixman_bool_t	dstAlphaMap = pDst->common.alpha_map != NULL;
     CompositeFunc   func = NULL;
-    
+
 #ifdef USE_MMX
     static pixman_bool_t mmx_setup = FALSE;
     if (!mmx_setup)
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index e29ef6d..af41d70 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -6,6 +6,7 @@
 #define PIXMAN_PRIVATE_H
 
 #include "pixman.h"
+#include <time.h>
 
 #ifndef FALSE
 #define FALSE 0
@@ -768,4 +769,49 @@ pixman_rasterize_edges_accessors (pixman
 				  pixman_fixed_t	t,
 				  pixman_fixed_t	b);
 
+
+/* Timing */
+static inline uint64_t
+oil_profile_stamp_rdtsc (void)
+{
+    uint64_t ts;
+    __asm__ __volatile__("rdtsc\n" : "=A" (ts));
+    return ts;
+}
+#define OIL_STAMP oil_profile_stamp_rdtsc
+
+typedef struct PixmanTimer PixmanTimer;
+
+struct PixmanTimer
+{
+    int initialized;
+    const char *name;
+    uint64_t n_times;
+    uint64_t total;
+    PixmanTimer *next;
+};
+
+extern int timer_defined;
+void pixman_timer_register (PixmanTimer *timer);
+
+#define TIMER_BEGIN(tname)						\
+    {									\
+	static PixmanTimer	timer##tname;				\
+	uint64_t		begin##tname;				\
+									\
+	if (!timer##tname.initialized)					\
+	{								\
+	    timer##tname.initialized = 1;				\
+	    timer##tname.name = #tname;					\
+	    pixman_timer_register (&timer##tname);			\
+	}								\
+									\
+	timer##tname.n_times++;						\
+	begin##tname = OIL_STAMP();
+	
+#define TIMER_END(tname)						\
+        timer##tname.total += OIL_STAMP() - begin##tname;		\
+    }
+
+
 #endif /* PIXMAN_PRIVATE_H */
diff --git a/pixman/pixman-timer.c b/pixman/pixman-timer.c
new file mode 100644
index 0000000..c762644
--- /dev/null
+++ b/pixman/pixman-timer.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright © 2007 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Red Hat not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  Red Hat makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <config.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "pixman-private.h"
+
+static PixmanTimer *timers;
+
+static void
+dump_timers (void)
+{
+    PixmanTimer *timer;
+
+    for (timer = timers; timer != NULL; timer = timer->next)
+    {
+	printf ("%s:   total: %llu     n: %llu      avg: %f\n",
+		timer->name,
+		timer->total,
+		timer->n_times,
+		timer->total / (double)timer->n_times);
+    }
+}
+
+void
+pixman_timer_register (PixmanTimer *timer)
+{
+    static int initialized;
+
+    int atexit(void (*function)(void));
+
+    if (!initialized)
+    {
+	atexit (dump_timers);
+	initialized = 1;
+    }
+    
+    timer->next = timers;
+    timers = timer;
+}
diff --git a/test/gradient-test.c b/test/gradient-test.c
index f6e3ca3..8a99ff0 100644
--- a/test/gradient-test.c
+++ b/test/gradient-test.c
@@ -59,6 +59,7 @@ show_window (uint32_t *bits, int w, int 
     pixbuf = pixbuf_from_argb32 (bits, w, h, stride);
     
     g_signal_connect (window, "expose_event", G_CALLBACK (on_expose), pixbuf);
+    g_signal_connect (window, "delete_event", G_CALLBACK (gtk_main_quit), NULL);
     
     gtk_widget_show (window);
     


More information about the xorg-commit mailing list