7 small miscellaneous fixes

Bug#959 - Multiple minor improvements

	* configure.ac: pick up GDKPIXBUF_PREFIX from gdk-pixbuf-2.0
	module, not pango

	* clutter/clutter-keysyms-table.h: cosmetic fix for ifdef guard
	name in the comment (leftover from earlier commit)

	* tests/test-textures.c: don't depend on GdkPixbuf as we're not
	using any actual features from it, just plain pixel buffer
	manipulation

	* clutter/clutter-timeline.c
	* clutter/clutter-timeline.h (clutter_timeline_list_markers): Use
	gsize* to return number of items, not guint*
	* tests/test-paint-wrapper.c: use correct type (guint*) in call
	to clutter_actor_get_size()

	* tests/test-depth.c (janus_group): properly take height2 into
	account when calculating needed height for the rectangle

	* tests/test-cogl-tex-getset.c: use rowstride, not width*4, when
	calculating pixel offsets

	* tests/test-cogl-tex-getset.c: Don't assume/force RGBA format,
	also support ARGB format (needed with quartz imageloader.)
This commit is contained in:
Tommi Komulainen 2008-06-10 06:37:46 +00:00
parent 45ff3cb00c
commit 863837baec
9 changed files with 93 additions and 56 deletions

View File

@ -1,3 +1,32 @@
2008-06-10 Tommi Komulainen <tommi.komulainen@iki.fi>
Bug#959 - Multiple minor improvements
* configure.ac: pick up GDKPIXBUF_PREFIX from gdk-pixbuf-2.0
module, not pango
* clutter/clutter-keysyms-table.h: cosmetic fix for ifdef guard
name in the comment (leftover from earlier commit)
* tests/test-textures.c: don't depend on GdkPixbuf as we're not
using any actual features from it, just plain pixel buffer
manipulation
* clutter/clutter-timeline.c
* clutter/clutter-timeline.h (clutter_timeline_list_markers): Use
gsize* to return number of items, not guint*
* tests/test-paint-wrapper.c: use correct type (guint*) in call
to clutter_actor_get_size()
* tests/test-depth.c (janus_group): properly take height2 into
account when calculating needed height for the rectangle
* tests/test-cogl-tex-getset.c: use rowstride, not width*4, when
calculating pixel offsets
* tests/test-cogl-tex-getset.c: Don't assume/force RGBA format,
also support ARGB format (needed with quartz imageloader.)
2008-06-09 Tommi Komulainen <tommi.komulainen@iki.fi>
* clutter/osx/clutter-backend-osx.c (clutter_backend_osx_post_parse):

View File

@ -824,4 +824,4 @@ struct {
/* End numeric keypad */
};
#endif /* __CLUTTER_KEYSYMS_H__ */
#endif /* __CLUTTER_KEYSYMS_TABLE_H__ */

View File

@ -1563,11 +1563,11 @@ clutter_timeline_add_marker_at_time (ClutterTimeline *timeline,
gchar **
clutter_timeline_list_markers (ClutterTimeline *timeline,
gint frame_num,
guint *n_markers)
gsize *n_markers)
{
ClutterTimelinePrivate *priv;
gchar **retval = NULL;
gint i;
gsize i;
g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), NULL);

View File

@ -153,7 +153,7 @@ void clutter_timeline_remove_marker (ClutterTimeline *timeli
const gchar *marker_name);
gchar ** clutter_timeline_list_markers (ClutterTimeline *timeline,
gint frame_num,
guint *n_markers) G_GNUC_MALLOC;
gsize *n_markers) G_GNUC_MALLOC;
gboolean clutter_timeline_has_marker (ClutterTimeline *timeline,
const gchar *marker_name);
void clutter_timeline_advance_to_marker (ClutterTimeline *timeline,

View File

@ -507,7 +507,7 @@ AC_SUBST(CLUTTER_REQUIRES)
# prefixes for fixing gtk-doc references
GLIB_PREFIX="`$PKG_CONFIG --variable=prefix glib-2.0`"
PANGO_PREFIX="`$PKG_CONFIG --variable=prefix pango`"
GDKPIXBUF_PREFIX="`$PKG_CONFIG --variable=prefix pango`"
GDKPIXBUF_PREFIX="`$PKG_CONFIG --variable=prefix gdk-pixbuf-2.0`"
AC_SUBST(GLIB_PREFIX)
AC_SUBST(PANGO_PREFIX)
AC_SUBST(GDKPIXBUF_PREFIX)

View File

@ -131,6 +131,7 @@ test_coglbox_init (TestCoglbox *self)
TestCoglboxPrivate *priv;
guint width;
guint height;
guint rowstride;
CoglPixelFormat format;
gint size;
guchar *data;
@ -155,7 +156,10 @@ test_coglbox_init (TestCoglbox *self)
/* Obtain pixel data */
format = COGL_PIXEL_FORMAT_RGBA_8888;
format = cogl_texture_get_format (priv->cogl_tex_id[0]);
g_assert(format == COGL_PIXEL_FORMAT_RGBA_8888 ||
format == COGL_PIXEL_FORMAT_ARGB_8888);
width = cogl_texture_get_width (priv->cogl_tex_id[0]);
height = cogl_texture_get_height (priv->cogl_tex_id[0]);
size = cogl_texture_get_data (priv->cogl_tex_id[0],
@ -169,13 +173,14 @@ test_coglbox_init (TestCoglbox *self)
cogl_texture_get_data (priv->cogl_tex_id[0],
format, 0, data);
rowstride = cogl_texture_get_rowstride (priv->cogl_tex_id[0]);
/* Create new texture from modified data */
priv->cogl_tex_id[1] =
cogl_texture_new_from_data (width, height, 0, FALSE,
format, format,
0, data);
rowstride, data);
if (priv->cogl_tex_id[1] == COGL_INVALID_HANDLE)
{
@ -191,10 +196,19 @@ test_coglbox_init (TestCoglbox *self)
{
for (x=0; x<width; ++x)
{
pixel = data + y * width * 4 + x * 4;
t = pixel[0];
pixel[0] = pixel[1];
pixel[1] = t;
pixel = data + y * rowstride + x * 4;
if (format == COGL_PIXEL_FORMAT_RGBA_8888)
{
t = pixel[0];
pixel[0] = pixel[1];
pixel[1] = t;
}
else
{
t = pixel[1];
pixel[1] = pixel[2];
pixel[2] = t;
}
}
}

View File

@ -92,7 +92,7 @@ janus_group (const gchar *front_text,
if (width2 > width)
width = width2;
if (height> height)
if (height2 > height)
height = height2;
clutter_actor_set_size (rectangle, width, height);

View File

@ -124,7 +124,7 @@ hand_pre_paint (ClutterActor *actor,
gpointer user_data)
{
ClutterColor red = { 255, 0, 0, 128 };
gint w, h;
guint w, h;
g_assert (hand_pre_paint_guard == FALSE);
@ -141,7 +141,7 @@ hand_post_paint (ClutterActor *actor,
gpointer user_data)
{
ClutterColor green = { 0, 255, 0, 128 };
gint w, h;
guint w, h;
g_assert (hand_pre_paint_guard == TRUE);

View File

@ -6,26 +6,23 @@
#include <clutter/clutter.h>
#ifdef USE_GDKPIXBUF
GdkPixbuf*
make_pixbuf (int width, int height, int bpp, int has_alpha)
guchar*
make_rgba_data (int width, int height, int bpp, int has_alpha, int *rowstride_p)
{
#define CHECK_SIZE 20
GdkPixbuf *px;
gint x,y, rowstride, n_channels, i = 0;
guchar *pixels;
px = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
has_alpha,
8,
width,
height);
g_assert(bpp == 4);
g_assert(has_alpha == TRUE);
if (!px) return NULL;
rowstride = width * bpp;
*rowstride_p = rowstride;
rowstride = gdk_pixbuf_get_rowstride (px);
n_channels = gdk_pixbuf_get_n_channels (px);
pixels = g_try_malloc (height * rowstride);
if (!pixels)
return NULL;
for (y = 0; y < height; y++)
{
@ -34,7 +31,7 @@ make_pixbuf (int width, int height, int bpp, int has_alpha)
{
guchar *p;
p = gdk_pixbuf_get_pixels (px) + y * rowstride + x * n_channels;
p = pixels + y * rowstride + x * bpp;
p[0] = p[1] = p[2] = 0; p[3] = 0xff;
@ -50,21 +47,17 @@ make_pixbuf (int width, int height, int bpp, int has_alpha)
}
}
return px;
return pixels;
}
#define SPIN() while (g_main_context_pending (NULL)) \
g_main_context_iteration (NULL, FALSE);
#endif /* USE_GDKPIXBUF */
int
main (int argc, char *argv[])
{
#ifdef USE_GDKPIXBUF
ClutterActor *texture;
ClutterActor *stage;
GdkPixbuf *pixbuf;
gint i, j;
clutter_init (&argc, &argv);
@ -74,31 +67,33 @@ main (int argc, char *argv[])
SPIN();
for (i=100; i<5000; i += 100)
for (i=100; i<=5000; i += 100)
for (j=0; j<4; j++)
{
pixbuf = make_pixbuf (i+j, i+j, 4, TRUE);
if (!pixbuf)
g_error("%ix%i pixbuf creation failed", i+j, i+j);
printf("o %ix%i pixbuf... ", i+j, i+j);
const int width = i+j;
const int height = i+j;
const gboolean has_alpha = TRUE;
const int bpp = has_alpha ? 4 : 3;
int rowstride;
guchar *pixels;
texture = clutter_texture_new ();
clutter_texture_set_from_rgb_data (CLUTTER_TEXTURE (texture),
gdk_pixbuf_get_pixels (pixbuf),
gdk_pixbuf_get_has_alpha (pixbuf),
gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf),
gdk_pixbuf_get_rowstride (pixbuf),
gdk_pixbuf_get_has_alpha (pixbuf)
? 4 : 3,
0, NULL);
g_object_unref (pixbuf);
if (!texture)
g_error("Pixbuf creation failed");
pixels = make_rgba_data (width, height, bpp, has_alpha, &rowstride);
if (!pixels)
g_error("No memory for %ix%i RGBA data failed", width, height);
printf("o %ix%i texture... ", width, height);
texture = clutter_texture_new ();
if (!clutter_texture_set_from_rgb_data (CLUTTER_TEXTURE (texture),
pixels,
has_alpha,
width,
height,
rowstride,
bpp,
0, NULL))
g_error("texture creation failed");
g_free(pixels);
printf("uploaded to texture...\n");
@ -114,7 +109,6 @@ main (int argc, char *argv[])
clutter_container_remove (CLUTTER_CONTAINER (stage), texture, NULL);
}
#endif /* USE_GDKPIXBUF */
return EXIT_SUCCESS;
}