Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gtk
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Oblomov
gtk
Commits
1fe35dda
Commit
1fe35dda
authored
Sep 01, 1998
by
Raph Levien
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor improvements to gdkrgb, added testrgb to the gtk directory.
parent
4bb5d92a
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
589 additions
and
13 deletions
+589
-13
ChangeLog
ChangeLog
+13
-0
ChangeLog.pre-2-0
ChangeLog.pre-2-0
+13
-0
ChangeLog.pre-2-10
ChangeLog.pre-2-10
+13
-0
ChangeLog.pre-2-2
ChangeLog.pre-2-2
+13
-0
ChangeLog.pre-2-4
ChangeLog.pre-2-4
+13
-0
ChangeLog.pre-2-6
ChangeLog.pre-2-6
+13
-0
ChangeLog.pre-2-8
ChangeLog.pre-2-8
+13
-0
gdk/gdkrgb.c
gdk/gdkrgb.c
+24
-13
gtk/testrgb.c
gtk/testrgb.c
+237
-0
tests/testrgb.c
tests/testrgb.c
+237
-0
No files found.
ChangeLog
View file @
1fe35dda
Mon Aug 31 21:36:31 1998 Raph Levien <raph@gimp.org>
* gdk/gdkrgb.c (gdk_rgb_select_conv): Improved the 24bpp
conversion selection logic, so Suns and other big-endian
machines should get faster conv routines. This is also the
point where 4bpp gray and 1bpp are checked in, although I
wouldn't be surprised if 1bpp is a little buggy. This is
synchronized with the 0.0.7 release of GdkRgb.
* gtk/Makefile.am:
* gtk/testrgb.c: Checked in testrgb.c to CVS, and made the
appropriate change to the Makefile.am
Mon Aug 31 15:18:19 1998 Raph Levien <raph@gimp.org>
* gdk/gdkrgb.[ch]: Added a gdk_draw_rgb_image_dithalign function,
...
...
ChangeLog.pre-2-0
View file @
1fe35dda
Mon Aug 31 21:36:31 1998 Raph Levien <raph@gimp.org>
* gdk/gdkrgb.c (gdk_rgb_select_conv): Improved the 24bpp
conversion selection logic, so Suns and other big-endian
machines should get faster conv routines. This is also the
point where 4bpp gray and 1bpp are checked in, although I
wouldn't be surprised if 1bpp is a little buggy. This is
synchronized with the 0.0.7 release of GdkRgb.
* gtk/Makefile.am:
* gtk/testrgb.c: Checked in testrgb.c to CVS, and made the
appropriate change to the Makefile.am
Mon Aug 31 15:18:19 1998 Raph Levien <raph@gimp.org>
* gdk/gdkrgb.[ch]: Added a gdk_draw_rgb_image_dithalign function,
...
...
ChangeLog.pre-2-10
View file @
1fe35dda
Mon Aug 31 21:36:31 1998 Raph Levien <raph@gimp.org>
* gdk/gdkrgb.c (gdk_rgb_select_conv): Improved the 24bpp
conversion selection logic, so Suns and other big-endian
machines should get faster conv routines. This is also the
point where 4bpp gray and 1bpp are checked in, although I
wouldn't be surprised if 1bpp is a little buggy. This is
synchronized with the 0.0.7 release of GdkRgb.
* gtk/Makefile.am:
* gtk/testrgb.c: Checked in testrgb.c to CVS, and made the
appropriate change to the Makefile.am
Mon Aug 31 15:18:19 1998 Raph Levien <raph@gimp.org>
* gdk/gdkrgb.[ch]: Added a gdk_draw_rgb_image_dithalign function,
...
...
ChangeLog.pre-2-2
View file @
1fe35dda
Mon Aug 31 21:36:31 1998 Raph Levien <raph@gimp.org>
* gdk/gdkrgb.c (gdk_rgb_select_conv): Improved the 24bpp
conversion selection logic, so Suns and other big-endian
machines should get faster conv routines. This is also the
point where 4bpp gray and 1bpp are checked in, although I
wouldn't be surprised if 1bpp is a little buggy. This is
synchronized with the 0.0.7 release of GdkRgb.
* gtk/Makefile.am:
* gtk/testrgb.c: Checked in testrgb.c to CVS, and made the
appropriate change to the Makefile.am
Mon Aug 31 15:18:19 1998 Raph Levien <raph@gimp.org>
* gdk/gdkrgb.[ch]: Added a gdk_draw_rgb_image_dithalign function,
...
...
ChangeLog.pre-2-4
View file @
1fe35dda
Mon Aug 31 21:36:31 1998 Raph Levien <raph@gimp.org>
* gdk/gdkrgb.c (gdk_rgb_select_conv): Improved the 24bpp
conversion selection logic, so Suns and other big-endian
machines should get faster conv routines. This is also the
point where 4bpp gray and 1bpp are checked in, although I
wouldn't be surprised if 1bpp is a little buggy. This is
synchronized with the 0.0.7 release of GdkRgb.
* gtk/Makefile.am:
* gtk/testrgb.c: Checked in testrgb.c to CVS, and made the
appropriate change to the Makefile.am
Mon Aug 31 15:18:19 1998 Raph Levien <raph@gimp.org>
* gdk/gdkrgb.[ch]: Added a gdk_draw_rgb_image_dithalign function,
...
...
ChangeLog.pre-2-6
View file @
1fe35dda
Mon Aug 31 21:36:31 1998 Raph Levien <raph@gimp.org>
* gdk/gdkrgb.c (gdk_rgb_select_conv): Improved the 24bpp
conversion selection logic, so Suns and other big-endian
machines should get faster conv routines. This is also the
point where 4bpp gray and 1bpp are checked in, although I
wouldn't be surprised if 1bpp is a little buggy. This is
synchronized with the 0.0.7 release of GdkRgb.
* gtk/Makefile.am:
* gtk/testrgb.c: Checked in testrgb.c to CVS, and made the
appropriate change to the Makefile.am
Mon Aug 31 15:18:19 1998 Raph Levien <raph@gimp.org>
* gdk/gdkrgb.[ch]: Added a gdk_draw_rgb_image_dithalign function,
...
...
ChangeLog.pre-2-8
View file @
1fe35dda
Mon Aug 31 21:36:31 1998 Raph Levien <raph@gimp.org>
* gdk/gdkrgb.c (gdk_rgb_select_conv): Improved the 24bpp
conversion selection logic, so Suns and other big-endian
machines should get faster conv routines. This is also the
point where 4bpp gray and 1bpp are checked in, although I
wouldn't be surprised if 1bpp is a little buggy. This is
synchronized with the 0.0.7 release of GdkRgb.
* gtk/Makefile.am:
* gtk/testrgb.c: Checked in testrgb.c to CVS, and made the
appropriate change to the Makefile.am
Mon Aug 31 15:18:19 1998 Raph Levien <raph@gimp.org>
* gdk/gdkrgb.[ch]: Added a gdk_draw_rgb_image_dithalign function,
...
...
gdk/gdkrgb.c
View file @
1fe35dda
...
...
@@ -2500,6 +2500,7 @@ gdk_rgb_select_conv (GdkImage *image)
GdkRgbConvFunc
conv_32
,
conv_32_d
;
GdkRgbConvFunc
conv_gray
,
conv_gray_d
;
GdkRgbConvFunc
conv_indexed
,
conv_indexed_d
;
gboolean
lsb_24
,
msb_24
;
depth
=
image_info
->
visual
->
depth
;
bpp
=
image
->
bpp
;
...
...
@@ -2524,6 +2525,17 @@ gdk_rgb_select_conv (GdkImage *image)
green_mask
=
image_info
->
visual
->
green_mask
;
blue_mask
=
image_info
->
visual
->
blue_mask
;
lsb_24
=
(
byte_order
==
GDK_LSB_FIRST
&&
red_mask
==
0xff0000
&&
green_mask
==
0xff00
&&
blue_mask
==
0xff
)
||
(
byte_order
==
GDK_MSB_FIRST
&&
red_mask
==
0xff
&&
green_mask
==
0xff00
&&
blue_mask
==
0xff0000
);
msb_24
=
(
byte_order
==
GDK_MSB_FIRST
&&
red_mask
==
0xff0000
&&
green_mask
==
0xff00
&&
blue_mask
==
0xff
)
||
(
byte_order
==
GDK_LSB_FIRST
&&
red_mask
==
0xff
&&
green_mask
==
0xff00
&&
blue_mask
==
0xff0000
);
conv
=
NULL
;
conv_d
=
NULL
;
...
...
@@ -2563,23 +2575,22 @@ gdk_rgb_select_conv (GdkImage *image)
red_mask
==
0x7c00
&&
green_mask
==
0x3e0
&&
blue_mask
==
0x1f
)
conv
=
gdk_rgb_convert_555_br
;
/* I'm not 100% sure about the 24bpp tests */
else
if
(
bpp
==
3
&&
depth
==
24
&&
vtype
==
GDK_VISUAL_TRUE_COLOR
&&
byte_order
==
GDK_LSB_FIRST
&&
red_mask
==
0xff0000
&&
green_mask
==
0xff00
&&
blue_mask
==
0xff
)
/* I'm not 100% sure about the 24bpp tests - but testing will show*/
else
if
(
bpp
==
3
&&
depth
==
24
&&
vtype
==
GDK_VISUAL_TRUE_COLOR
&&
lsb_24
)
conv
=
gdk_rgb_convert_888_lsb
;
else
if
(
bpp
==
3
&&
depth
==
24
&&
vtype
==
GDK_VISUAL_TRUE_COLOR
&&
byte_order
==
GDK_MSB_FIRST
&&
red_mask
==
0xff0000
&&
green_mask
==
0xff00
&&
blue_mask
==
0xff
)
else
if
(
bpp
==
3
&&
depth
==
24
&&
vtype
==
GDK_VISUAL_TRUE_COLOR
&&
msb_24
)
conv
=
gdk_rgb_convert_888_msb
;
else
if
(
bpp
==
4
&&
depth
==
24
&&
vtype
==
GDK_VISUAL_TRUE_COLOR
&&
!
byterev
&&
red_mask
==
0xff0000
&&
green_mask
==
0xff00
&&
blue_mask
==
0xff
)
#ifdef WORDS_BIGENDIAN
else
if
(
bpp
==
4
&&
depth
==
24
&&
vtype
==
GDK_VISUAL_TRUE_COLOR
&&
lsb_24
)
conv
=
gdk_rgb_convert_0888_br
;
else
if
(
bpp
==
4
&&
depth
==
24
&&
vtype
==
GDK_VISUAL_TRUE_COLOR
&&
msb_24
)
conv
=
gdk_rgb_convert_0888
;
else
if
(
bpp
==
4
&&
depth
==
24
&&
vtype
==
GDK_VISUAL_TRUE_COLOR
&&
byterev
&&
red_mask
==
0xff0000
&&
green_mask
==
0xff00
&&
blue_mask
==
0xff
)
#else
else
if
(
bpp
==
4
&&
depth
==
24
&&
vtype
==
GDK_VISUAL_TRUE_COLOR
&&
lsb_24
)
conv
=
gdk_rgb_convert_0888
;
else
if
(
bpp
==
4
&&
depth
==
24
&&
vtype
==
GDK_VISUAL_TRUE_COLOR
&&
msb_24
)
conv
=
gdk_rgb_convert_0888_br
;
#endif
else
if
(
vtype
==
GDK_VISUAL_TRUE_COLOR
&&
byte_order
==
GDK_LSB_FIRST
)
{
...
...
gtk/testrgb.c
0 → 100644
View file @
1fe35dda
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/* Note: these #includes differ slightly from the testrgb.c file included
in the GdkRgb release. */
/* For gettimeofday */
#include <sys/time.h>
#include <unistd.h>
#include "gtk.h"
static
void
quit_func
(
GtkWidget
*
widget
,
gpointer
dummy
)
{
gtk_main_quit
();
}
#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
];
gint
i
,
j
;
gint
offset
;
guchar
val
;
gdouble
start_time
,
total_time
;
gint
x
,
y
;
gboolean
dither
;
int
dith_max
;
val
=
0
;
for
(
j
=
0
;
j
<
WIDTH
*
HEIGHT
*
6
;
j
++
)
{
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
;
for
(
dither
=
0
;
dither
<
dith_max
;
dither
++
)
{
start_time
=
get_time
();
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
);
}
total_time
=
get_time
()
-
start_time
;
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
++
)
{
start_time
=
get_time
();
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
);
}
total_time
=
get_time
()
-
start_time
;
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
);
}
#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
;
}
for
(
y
=
1
;
y
<
(
HEIGHT
*
3
)
/
4
;
y
++
)
{
memcpy
(
buf
+
y
*
WIDTH
*
3
,
buf
,
WIDTH
*
3
);
}
for
(;
y
<
(
HEIGHT
*
13
)
/
16
;
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
]
=
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
;
window
=
gtk_widget_new
(
gtk_window_get_type
(),
"GtkObject::user_data"
,
NULL
,
"GtkWindow::type"
,
GTK_WINDOW_TOPLEVEL
,
"GtkWindow::title"
,
"testrgb"
,
"GtkWindow::allow_shrink"
,
FALSE
,
NULL
);
gtk_signal_connect
(
GTK_OBJECT
(
window
),
"destroy"
,
(
GtkSignalFunc
)
quit_func
,
NULL
);
vbox
=
gtk_vbox_new
(
FALSE
,
0
);
drawing_area
=
gtk_drawing_area_new
();
gtk_widget_set_usize
(
drawing_area
,
WIDTH
,
HEIGHT
);
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
);
gtk_signal_connect_object
(
GTK_OBJECT
(
button
),
"clicked"
,
(
GtkSignalFunc
)
gtk_widget_destroy
,
GTK_OBJECT
(
window
));
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
);
gdk_rgb_init
();
gtk_widget_set_default_colormap
(
gdk_rgb_get_cmap
());
gtk_widget_set_default_visual
(
gdk_rgb_get_visual
());
new_testrgb_window
();
gtk_main
();
return
0
;
}
tests/testrgb.c
0 → 100644
View file @
1fe35dda
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/* Note: these #includes differ slightly from the testrgb.c file included
in the GdkRgb release. */
/* For gettimeofday */
#include <sys/time.h>
#include <unistd.h>
#include "gtk.h"
static
void
quit_func
(
GtkWidget
*
widget
,
gpointer
dummy
)
{
gtk_main_quit
();
}
#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
];
gint
i
,
j
;
gint
offset
;
guchar
val
;
gdouble
start_time
,
total_time
;
gint
x
,
y
;
gboolean
dither
;
int
dith_max
;
val
=
0
;
for
(
j
=
0
;
j
<
WIDTH
*
HEIGHT
*
6
;
j
++
)
{
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
;
for
(
dither
=
0
;
dither
<
dith_max
;
dither
++
)
{
start_time
=
get_time
();
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
);
}
total_time
=
get_time
()
-
start_time
;
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
++
)
{
start_time
=
get_time
();
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
);
}
total_time
=
get_time
()
-
start_time
;
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
);
}
#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
;
}
for
(
y
=
1
;
y
<
(
HEIGHT
*
3
)
/
4
;
y
++
)
{
memcpy
(
buf
+
y
*
WIDTH
*
3
,
buf
,
WIDTH
*
3
);
}
for
(;
y
<
(
HEIGHT
*
13
)
/
16
;
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
]
=
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
;
window
=
gtk_widget_new
(
gtk_window_get_type
(),
"GtkObject::user_data"
,
NULL
,
"GtkWindow::type"
,
GTK_WINDOW_TOPLEVEL
,
"GtkWindow::title"
,
"testrgb"
,
"GtkWindow::allow_shrink"
,
FALSE
,
NULL
);
gtk_signal_connect
(
GTK_OBJECT
(
window
),
"destroy"
,
(
GtkSignalFunc
)
quit_func
,
NULL
);
vbox
=
gtk_vbox_new
(
FALSE
,
0
);
drawing_area
=
gtk_drawing_area_new
();
gtk_widget_set_usize
(
drawing_area
,
WIDTH
,
HEIGHT
);
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
);
gtk_signal_connect_object
(
GTK_OBJECT
(
button
),
"clicked"
,
(
GtkSignalFunc
)
gtk_widget_destroy
,
GTK_OBJECT
(
window
));
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
);
gdk_rgb_init
();
gtk_widget_set_default_colormap
(
gdk_rgb_get_cmap
());