summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTor Lillqvist <tml@src.gnome.org>1999-03-15 00:03:37 +0000
committerTor Lillqvist <tml@src.gnome.org>1999-03-15 00:03:37 +0000
commitc65508d2723d255a9fcdfa8ac2a5f82b0667a7c6 (patch)
tree57c568358f89e9d1ec3c561bae77f5b76adc6417 /tests
parent044fd2db4700cf34d4a2b06424be0bbe2dce5b78 (diff)
downloadgtk+-c65508d2723d255a9fcdfa8ac2a5f82b0667a7c6.tar.gz
This might seem like a large patch, but it isn't that bad, and nothing
should break on Unix/X11. Win32 merge and general portability stuff: * acconfig.h,configure.in: Check for <sys/time.h>. * gdk/win32: New directory (actually, been there for a while). * gtk/fnmatch.c: Include <glib.h> for G_DIR_SEPARATOR, WIN32 and NATIVE_WIN32, and use these. Always case fold on Win32. No backslashed escapes on native Win32. * gtk/{gtk.def,makefile.msc}: New files. * gtk/Makefile.am: Add above new files. * gtk/{gtkaccelgroup,gtkbindings}.c: Include <string.h> instead of <strings.h>. * gtk/{gtkcalendar,gtkitemfactory,gtkpreview,gtkrc}.c: Include config.h. Protect inclusion of <sys/param.h>, <sys/time.h>, and <unistd.h> appropriately. * gtk/gtkdnd.c: Merge in Win32 version (which doesn't do much). Use ABS() (from <glib.h>) instead of abs(). * gtk/gtkfilesel.c: Moved Win32-specific includes after inclusion of gtk (and thus glib) headers, so that WIN32 will be defined. With MS C, include <direct.h> for mkdir prototype. * gtk/gtkitemfactory.c (gtk_item_factory_callback_marshal): Add some casts, needed by MS C. * gtk/{gtklayout,gtkplug}.c: Merge in Win32 version (which isn't implemented). * gtk/gtkmain.c: Include gdk/gdkx.h for GDK_WINDOWING. Include <X11/Xlocale.h> only on X11 platform, otherwise <locale.h>. Use G_SEARCHPATH_SEPARATOR_S and g_module_build_path. * gtk/gtkmain.h: Mark variables for export/import on Win32. * gtk/gtkrange.c (gtk_range_motion_notify): Set mods also in case the event is not a hint, or its window is not the slider. Needed on Win32, at least. * gtk/gtkrc.c: Include config.h and gdk/gdkx.h. Use <locale.h> unless on X11. Skip \r chars, too. Use G_DIR_SEPARATOR and G_SEARCHPATH_SEPARATOR(_S). Use g_path_is_absolute. On Win32, use a subdirectory of the Windows directory as gtk system configuration directory. * gtk/gtkselection.c: No chunks on Win32. * gtk/gtksocket.c: Not implemented on Win32. * gtk/gtkthemes.c (gtk_theme_engine_get): Use g_module_build_path. * gtk/makeenums.h: Include gdkprivate.h after gdk.h. * gtk/testrgb.c: Use dynamically allocated buffer. Use GTimers.
Diffstat (limited to 'tests')
-rw-r--r--tests/testrgb.c34
1 files changed, 15 insertions, 19 deletions
diff --git a/tests/testrgb.c b/tests/testrgb.c
index 99cd6eba52..c629598bee 100644
--- a/tests/testrgb.c
+++ b/tests/testrgb.c
@@ -17,6 +17,10 @@
* Boston, MA 02111-1307, USA.
*/
+#include "config.h"
+
+#include <glib.h>
+
/*
* Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
@@ -28,10 +32,10 @@
/* Note: these #includes differ slightly from the testrgb.c file included
in the GdkRgb release. */
-/* For gettimeofday */
-#include <sys/time.h>
#include <stdlib.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include <string.h>
#include "gtk.h"
@@ -44,24 +48,12 @@ quit_func (GtkWidget *widget, gpointer dummy)
#define WIDTH 320
#define HEIGHT 200
-
-gdouble
-get_time (void)
-{
- struct timeval tv;
- struct timezone tz;
-
- gettimeofday (&tv, &tz);
-
- return tv.tv_sec + 1e-6 * tv.tv_usec;
-}
-
#define NUM_ITERS 100
static void
testrgb_rgb_test (GtkWidget *drawing_area)
{
- guchar buf[WIDTH * HEIGHT * 6];
+ guchar *buf;
gint i, j;
gint offset;
guchar val;
@@ -69,6 +61,9 @@ testrgb_rgb_test (GtkWidget *drawing_area)
gint x, y;
gboolean dither;
int dith_max;
+ GTimer *timer;
+
+ buf = g_malloc (WIDTH * HEIGHT * 6);
val = 0;
for (j = 0; j < WIDTH * HEIGHT * 6; j++)
@@ -94,9 +89,10 @@ testrgb_rgb_test (GtkWidget *drawing_area)
else
dith_max = 1;
+ timer = g_timer_new ();
for (dither = 0; dither < dith_max; dither++)
{
- start_time = get_time ();
+ start_time = g_timer_elapsed (timer, NULL);
for (i = 0; i < NUM_ITERS; i++)
{
offset = (rand () % (WIDTH * HEIGHT * 3)) & -4;
@@ -107,7 +103,7 @@ testrgb_rgb_test (GtkWidget *drawing_area)
GDK_RGB_DITHER_NONE,
buf + offset, WIDTH * 3);
}
- total_time = get_time () - start_time;
+ 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)" : "",
total_time,
@@ -117,7 +113,7 @@ testrgb_rgb_test (GtkWidget *drawing_area)
for (dither = 0; dither < dith_max; dither++)
{
- start_time = get_time ();
+ start_time = g_timer_elapsed (timer, NULL);
for (i = 0; i < NUM_ITERS; i++)
{
offset = (rand () % (WIDTH * HEIGHT)) & -4;
@@ -128,7 +124,7 @@ testrgb_rgb_test (GtkWidget *drawing_area)
GDK_RGB_DITHER_NONE,
buf + offset, WIDTH);
}
- total_time = get_time () - start_time;
+ 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)" : "",
total_time,