2008-07-01 22:57:50 +00:00
|
|
|
/* GTK - The GIMP Toolkit
|
1998-09-01 05:29:45 +00:00
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 11:33:08 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1998-09-01 05:29:45 +00:00
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2000-07-26 11:33:08 +00:00
|
|
|
* Lesser General Public License for more details.
|
1998-09-01 05:29:45 +00:00
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1998-09-01 05:29:45 +00:00
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
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.
1999-03-15 00:03:37 +00:00
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
1999-02-24 07:37:18 +00:00
|
|
|
/*
|
2000-07-26 11:33:08 +00:00
|
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
1999-02-24 07:37:18 +00:00
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
* files for a list of changes. These files are distributed with
|
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
1998-09-01 05:29:45 +00:00
|
|
|
/* Note: these #includes differ slightly from the testrgb.c file included
|
|
|
|
in the GdkRgb release. */
|
|
|
|
|
1998-09-06 19:36:56 +00:00
|
|
|
#include <stdlib.h>
|
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.
1999-03-15 00:03:37 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
1998-09-01 05:29:45 +00:00
|
|
|
#include <unistd.h>
|
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.
1999-03-15 00:03:37 +00:00
|
|
|
#endif
|
1998-12-10 06:18:32 +00:00
|
|
|
#include <string.h>
|
1998-09-01 05:29:45 +00:00
|
|
|
|
2001-04-03 18:48:46 +00:00
|
|
|
#include "gtk/gtk.h"
|
1998-09-01 05:29:45 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
quit_func (GtkWidget *widget, gpointer dummy)
|
|
|
|
{
|
|
|
|
gtk_main_quit ();
|
|
|
|
}
|
|
|
|
|
Add gdk_rgb_find_color() to get a pixel value using GdkRGB functionality
Sun Jul 2 12:45:50 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdkrgb.[ch]: Add gdk_rgb_find_color() to get a pixel
value using GdkRGB functionality given GdkColormap and GdkColor.
(name not final, waiting for inspiration.)
* gdk/gdkgc.[ch] (gdk_gc_set_rgb_fg/bg_color): New functions to
set the foreground/background of a GC using the GC's colormap
and GdkRGB. (name not final, waiting for inspiration.)
* gdk/gdkcompat.h gdk/gdkrgb.c (gdk_rgb_get_colormap): Rename from
gdk_rgb_get_cmap(), put #define in gdkcompat.h.
* gtk/gtkwidget.[ch] gtkcompat.h: Make visuals for
gtk_widget_get_visual(), gtk_widget_get_default_visual, etc,
purely a function of the corresponding colormap. Make
gtk_widget_set_visual(), etc, noop macros in gtkcompat.h.
* gdk/gdkpixmap.c gdk/x11/gdkpixmap-c11.c: Rewrite
gdk_pixbuf_*create_from_xpm_* in terms of
gdk_pixbuf_new_from_xpm_data(), move into platform independent
code.
* gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable): Take
advantage of the new draw_rgb_32_image_dithalign.
* gdk/gdkrgb.c (gdk_draw_rgb_32_image_dithalign): Added.
* gtk/gtkgc.c (gtk_gc_new): Set the appropriate colormap
on each created GC.
* gdk/gdkgc.[ch]: Add gdk_gc_get/set_colormap.
* gdk/gdkgc.[ch]: Add a colormap field to the GdkGC structure
which we initialize from the drawable when the GC is created,
if the drawable has a colormap.
* gdk/x11/gdkgc-x11.c: include string.h for memset.
* gdk/x11/gdkinput-x11.c: include string.h for strlen, etc.
* gtk/gtklayout.[ch]: Remove unsed configure serial member.
2000-07-02 17:03:21 +00:00
|
|
|
#define WIDTH 640
|
|
|
|
#define HEIGHT 400
|
2002-01-04 05:58:01 +00:00
|
|
|
#define NUM_ITERS 50
|
1998-09-01 05:29:45 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
testrgb_rgb_test (GtkWidget *drawing_area)
|
|
|
|
{
|
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.
1999-03-15 00:03:37 +00:00
|
|
|
guchar *buf;
|
1998-09-01 05:29:45 +00:00
|
|
|
gint i, j;
|
|
|
|
gint offset;
|
|
|
|
guchar val;
|
|
|
|
gdouble start_time, total_time;
|
|
|
|
gint x, y;
|
|
|
|
gboolean dither;
|
|
|
|
int dith_max;
|
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.
1999-03-15 00:03:37 +00:00
|
|
|
GTimer *timer;
|
2002-01-04 05:58:01 +00:00
|
|
|
GdkPixbuf *pixbuf;
|
|
|
|
gboolean to_pixmap;
|
|
|
|
|
|
|
|
buf = g_malloc (WIDTH * HEIGHT * 8);
|
1998-09-01 05:29:45 +00:00
|
|
|
|
|
|
|
val = 0;
|
2002-01-04 05:58:01 +00:00
|
|
|
for (j = 0; j < WIDTH * HEIGHT * 8; j++)
|
1998-09-01 05:29:45 +00:00
|
|
|
{
|
|
|
|
val = (val + ((val + (rand () & 0xff)) >> 1)) >> 1;
|
|
|
|
buf[j] = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Let's warm up the cache, and also wait for the window manager
|
|
|
|
to settle. */
|
|
|
|
for (i = 0; i < NUM_ITERS; i++)
|
|
|
|
{
|
|
|
|
offset = (rand () % (WIDTH * HEIGHT * 3)) & -4;
|
|
|
|
gdk_draw_rgb_image (drawing_area->window,
|
|
|
|
drawing_area->style->white_gc,
|
|
|
|
0, 0, WIDTH, HEIGHT,
|
|
|
|
GDK_RGB_DITHER_NONE,
|
|
|
|
buf + offset, WIDTH * 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gdk_rgb_ditherable ())
|
|
|
|
dith_max = 2;
|
|
|
|
else
|
|
|
|
dith_max = 1;
|
|
|
|
|
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.
1999-03-15 00:03:37 +00:00
|
|
|
timer = g_timer_new ();
|
1998-09-01 05:29:45 +00:00
|
|
|
for (dither = 0; dither < dith_max; dither++)
|
|
|
|
{
|
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.
1999-03-15 00:03:37 +00:00
|
|
|
start_time = g_timer_elapsed (timer, NULL);
|
1998-09-01 05:29:45 +00:00
|
|
|
for (i = 0; i < NUM_ITERS; i++)
|
|
|
|
{
|
|
|
|
offset = (rand () % (WIDTH * HEIGHT * 3)) & -4;
|
|
|
|
gdk_draw_rgb_image (drawing_area->window,
|
|
|
|
drawing_area->style->white_gc,
|
|
|
|
0, 0, WIDTH, HEIGHT,
|
|
|
|
dither ? GDK_RGB_DITHER_MAX :
|
|
|
|
GDK_RGB_DITHER_NONE,
|
|
|
|
buf + offset, WIDTH * 3);
|
|
|
|
}
|
2002-01-04 05:58:01 +00:00
|
|
|
gdk_flush ();
|
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.
1999-03-15 00:03:37 +00:00
|
|
|
total_time = g_timer_elapsed (timer, NULL) - start_time;
|
1998-09-01 05:29:45 +00:00
|
|
|
g_print ("Color test%s time elapsed: %.2fs, %.1f fps, %.2f megapixels/s\n",
|
|
|
|
dither ? " (dithered)" : "",
|
|
|
|
total_time,
|
|
|
|
NUM_ITERS / total_time,
|
|
|
|
NUM_ITERS * (WIDTH * HEIGHT * 1e-6) / total_time);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (dither = 0; dither < dith_max; dither++)
|
|
|
|
{
|
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.
1999-03-15 00:03:37 +00:00
|
|
|
start_time = g_timer_elapsed (timer, NULL);
|
1998-09-01 05:29:45 +00:00
|
|
|
for (i = 0; i < NUM_ITERS; i++)
|
|
|
|
{
|
|
|
|
offset = (rand () % (WIDTH * HEIGHT)) & -4;
|
|
|
|
gdk_draw_gray_image (drawing_area->window,
|
|
|
|
drawing_area->style->white_gc,
|
|
|
|
0, 0, WIDTH, HEIGHT,
|
|
|
|
dither ? GDK_RGB_DITHER_MAX :
|
|
|
|
GDK_RGB_DITHER_NONE,
|
|
|
|
buf + offset, WIDTH);
|
|
|
|
}
|
2002-01-04 05:58:01 +00:00
|
|
|
gdk_flush ();
|
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.
1999-03-15 00:03:37 +00:00
|
|
|
total_time = g_timer_elapsed (timer, NULL) - start_time;
|
1998-09-01 05:29:45 +00:00
|
|
|
g_print ("Grayscale test%s time elapsed: %.2fs, %.1f fps, %.2f megapixels/s\n",
|
|
|
|
dither ? " (dithered)" : "",
|
|
|
|
total_time,
|
|
|
|
NUM_ITERS / total_time,
|
|
|
|
NUM_ITERS * (WIDTH * HEIGHT * 1e-6) / total_time);
|
|
|
|
}
|
|
|
|
|
2002-01-04 05:58:01 +00:00
|
|
|
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++)
|
|
|
|
{
|
2010-07-12 13:45:12 +00:00
|
|
|
cairo_t *cr;
|
|
|
|
|
2002-01-04 05:58:01 +00:00
|
|
|
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);
|
2010-07-12 13:45:12 +00:00
|
|
|
cr = gdk_cairo_create (drawing_area->window);
|
|
|
|
gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
|
|
|
|
cairo_rectangle (cr, 0, 0, WIDTH, HEIGHT);
|
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_destroy (cr);
|
2002-10-13 23:22:33 +00:00
|
|
|
g_object_unref (pixbuf);
|
2002-01-04 05:58:01 +00:00
|
|
|
}
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
1998-10-05 22:30:08 +00:00
|
|
|
g_print ("Please submit these results to http://www.levien.com/gdkrgb/survey.html\n");
|
|
|
|
|
1998-09-01 05:29:45 +00:00
|
|
|
#if 1
|
|
|
|
for (x = 0; x < WIDTH; x++)
|
|
|
|
{
|
|
|
|
int cindex;
|
|
|
|
|
|
|
|
cindex = (x * 8) / WIDTH;
|
|
|
|
buf[x * 3] = cindex & 4 ? 0 : 255;
|
|
|
|
buf[x * 3 + 1] = cindex & 2 ? 0 : 255;
|
|
|
|
buf[x * 3 + 2] = cindex & 1 ? 0 : 255;
|
|
|
|
}
|
1998-09-11 00:11:05 +00:00
|
|
|
for (y = 1; y < (HEIGHT * 19) / 32; y++)
|
1998-09-01 05:29:45 +00:00
|
|
|
{
|
|
|
|
memcpy (buf + y * WIDTH * 3, buf, WIDTH * 3);
|
|
|
|
}
|
1998-09-11 00:11:05 +00:00
|
|
|
for (; y < (HEIGHT * 20) / 32; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < WIDTH; x++)
|
|
|
|
{
|
|
|
|
guchar gray;
|
|
|
|
|
|
|
|
gray = (x * 255) / (WIDTH - 1);
|
|
|
|
buf[y * WIDTH * 3 + x * 3] = gray;
|
|
|
|
buf[y * WIDTH * 3 + x * 3 + 1] = 0;
|
|
|
|
buf[y * WIDTH * 3 + x * 3 + 2] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (; y < (HEIGHT * 21) / 32; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < WIDTH; x++)
|
|
|
|
{
|
|
|
|
guchar gray;
|
|
|
|
|
|
|
|
gray = (x * 255) / (WIDTH - 1);
|
|
|
|
buf[y * WIDTH * 3 + x * 3] = 0;
|
|
|
|
buf[y * WIDTH * 3 + x * 3 + 1] = gray;
|
|
|
|
buf[y * WIDTH * 3 + x * 3 + 2] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (; y < (HEIGHT * 22) / 32; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < WIDTH; x++)
|
|
|
|
{
|
|
|
|
guchar gray;
|
|
|
|
|
|
|
|
gray = (x * 255) / (WIDTH - 1);
|
|
|
|
buf[y * WIDTH * 3 + x * 3] = 0;
|
|
|
|
buf[y * WIDTH * 3 + x * 3 + 1] = 0;
|
|
|
|
buf[y * WIDTH * 3 + x * 3 + 2] = gray;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (; y < (HEIGHT * 24) / 32; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < WIDTH; x++)
|
|
|
|
{
|
|
|
|
guchar gray;
|
|
|
|
|
|
|
|
gray = 112 + (x * 31) / (WIDTH - 1);
|
|
|
|
buf[y * WIDTH * 3 + x * 3] = gray;
|
|
|
|
buf[y * WIDTH * 3 + x * 3 + 1] = gray;
|
|
|
|
buf[y * WIDTH * 3 + x * 3 + 2] = gray;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (; y < (HEIGHT * 26) / 32; y++)
|
1998-09-01 05:29:45 +00:00
|
|
|
{
|
|
|
|
for (x = 0; x < WIDTH; x++)
|
|
|
|
{
|
|
|
|
guchar gray;
|
|
|
|
|
|
|
|
gray = (x * 255) / (WIDTH - 1);
|
|
|
|
buf[y * WIDTH * 3 + x * 3] = gray;
|
|
|
|
buf[y * WIDTH * 3 + x * 3 + 1] = gray;
|
|
|
|
buf[y * WIDTH * 3 + x * 3 + 2] = gray;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (; y < HEIGHT; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < WIDTH; x++)
|
|
|
|
{
|
|
|
|
int cindex;
|
|
|
|
guchar gray;
|
|
|
|
|
|
|
|
cindex = (x * 16) / WIDTH;
|
|
|
|
gray = cindex < 3 ? 0 :
|
|
|
|
cindex < 5 ? 255 :
|
|
|
|
cindex < 7 ? 128 :
|
|
|
|
0;
|
|
|
|
buf[y * WIDTH * 3 + x * 3] = gray;
|
|
|
|
buf[y * WIDTH * 3 + x * 3 + 1] = gray;
|
|
|
|
buf[y * WIDTH * 3 + x * 3 + 2] = gray;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gdk_draw_rgb_image (drawing_area->window,
|
|
|
|
drawing_area->style->white_gc,
|
|
|
|
0, 0, WIDTH, HEIGHT, GDK_RGB_DITHER_MAX,
|
|
|
|
buf, WIDTH * 3);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
new_testrgb_window (void)
|
|
|
|
{
|
|
|
|
GtkWidget *window;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *drawing_area;
|
|
|
|
|
Use g_object_new instead of gtk_widget_new
2008-06-19 Johan Dahlin <jdahlin@async.com.br>
* demos/testpixbuf.c (new_testrgb_window):
* gtk/gtkctree.c (gtk_ctree_new_with_titles):
* gtk/gtkitemfactory.c (gtk_item_factory_construct),
(gtk_item_factory_create_item):
* gtk/gtkmenu.c (gtk_menu_set_tearoff_state):
* gtk/gtkprogressbar.c (gtk_progress_bar_new),
(gtk_progress_bar_new_with_adjustment):
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_new):
* gtk/gtktext.c (gtk_text_new):
* gtk/gtkviewport.c (gtk_viewport_new):
* tests/simple.c (main):
* tests/testgtk.c (create_statusbar), (create_get_image),
(create_saved_position), (create_tooltips), (create_cursors),
(create_display_screen), (create_progress_bar), (create_idle_test):
* tests/testmultidisplay.c (make_selection_dialog), (main):
* tests/testmultiscreen.c (main):
* tests/testrgb.c (new_testrgb_window):
Use g_object_new instead of gtk_widget_new
svn path=/trunk/; revision=20462
2008-06-19 12:25:19 +00:00
|
|
|
window = g_object_new (gtk_window_get_type (),
|
1998-09-01 05:29:45 +00:00
|
|
|
"GtkObject::user_data", NULL,
|
|
|
|
"GtkWindow::type", GTK_WINDOW_TOPLEVEL,
|
|
|
|
"GtkWindow::title", "testrgb",
|
|
|
|
NULL);
|
2002-10-13 23:22:33 +00:00
|
|
|
g_signal_connect (window, "destroy",
|
|
|
|
G_CALLBACK (quit_func), NULL);
|
1998-09-01 05:29:45 +00:00
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
|
|
|
|
|
|
|
drawing_area = gtk_drawing_area_new ();
|
|
|
|
|
2002-10-13 23:22:33 +00:00
|
|
|
gtk_widget_set_size_request (drawing_area, WIDTH, HEIGHT);
|
1998-09-01 05:29:45 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), drawing_area, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (drawing_area);
|
|
|
|
|
|
|
|
button = gtk_button_new_with_label ("Quit");
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
2002-10-13 23:22:33 +00:00
|
|
|
g_signal_connect_swapped (button, "clicked",
|
|
|
|
G_CALLBACK (gtk_widget_destroy), window);
|
1998-09-01 05:29:45 +00:00
|
|
|
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (window), vbox);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
|
|
|
gtk_widget_show (window);
|
|
|
|
|
|
|
|
testrgb_rgb_test (drawing_area);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
gtk_init (&argc, &argv);
|
|
|
|
|
|
|
|
gdk_rgb_set_verbose (TRUE);
|
|
|
|
|
2002-10-13 23:22:33 +00:00
|
|
|
gtk_widget_set_default_colormap (gdk_rgb_get_colormap ());
|
1998-09-01 05:29:45 +00:00
|
|
|
new_testrgb_window ();
|
|
|
|
|
|
|
|
gtk_main ();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|