1
0
Fork 0

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> 2008-06-09 Tommi Komulainen <tommi.komulainen@iki.fi>
* clutter/osx/clutter-backend-osx.c (clutter_backend_osx_post_parse): * clutter/osx/clutter-backend-osx.c (clutter_backend_osx_post_parse):

View file

@ -824,4 +824,4 @@ struct {
/* End numeric keypad */ /* 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 ** gchar **
clutter_timeline_list_markers (ClutterTimeline *timeline, clutter_timeline_list_markers (ClutterTimeline *timeline,
gint frame_num, gint frame_num,
guint *n_markers) gsize *n_markers)
{ {
ClutterTimelinePrivate *priv; ClutterTimelinePrivate *priv;
gchar **retval = NULL; gchar **retval = NULL;
gint i; gsize i;
g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), NULL); 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); const gchar *marker_name);
gchar ** clutter_timeline_list_markers (ClutterTimeline *timeline, gchar ** clutter_timeline_list_markers (ClutterTimeline *timeline,
gint frame_num, gint frame_num,
guint *n_markers) G_GNUC_MALLOC; gsize *n_markers) G_GNUC_MALLOC;
gboolean clutter_timeline_has_marker (ClutterTimeline *timeline, gboolean clutter_timeline_has_marker (ClutterTimeline *timeline,
const gchar *marker_name); const gchar *marker_name);
void clutter_timeline_advance_to_marker (ClutterTimeline *timeline, void clutter_timeline_advance_to_marker (ClutterTimeline *timeline,

View file

@ -507,7 +507,7 @@ AC_SUBST(CLUTTER_REQUIRES)
# prefixes for fixing gtk-doc references # prefixes for fixing gtk-doc references
GLIB_PREFIX="`$PKG_CONFIG --variable=prefix glib-2.0`" GLIB_PREFIX="`$PKG_CONFIG --variable=prefix glib-2.0`"
PANGO_PREFIX="`$PKG_CONFIG --variable=prefix pango`" 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(GLIB_PREFIX)
AC_SUBST(PANGO_PREFIX) AC_SUBST(PANGO_PREFIX)
AC_SUBST(GDKPIXBUF_PREFIX) AC_SUBST(GDKPIXBUF_PREFIX)

View file

@ -131,6 +131,7 @@ test_coglbox_init (TestCoglbox *self)
TestCoglboxPrivate *priv; TestCoglboxPrivate *priv;
guint width; guint width;
guint height; guint height;
guint rowstride;
CoglPixelFormat format; CoglPixelFormat format;
gint size; gint size;
guchar *data; guchar *data;
@ -155,7 +156,10 @@ test_coglbox_init (TestCoglbox *self)
/* Obtain pixel data */ /* 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]); width = cogl_texture_get_width (priv->cogl_tex_id[0]);
height = cogl_texture_get_height (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], 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], cogl_texture_get_data (priv->cogl_tex_id[0],
format, 0, data); format, 0, data);
rowstride = cogl_texture_get_rowstride (priv->cogl_tex_id[0]);
/* Create new texture from modified data */ /* Create new texture from modified data */
priv->cogl_tex_id[1] = priv->cogl_tex_id[1] =
cogl_texture_new_from_data (width, height, 0, FALSE, cogl_texture_new_from_data (width, height, 0, FALSE,
format, format, format, format,
0, data); rowstride, data);
if (priv->cogl_tex_id[1] == COGL_INVALID_HANDLE) if (priv->cogl_tex_id[1] == COGL_INVALID_HANDLE)
{ {
@ -191,11 +196,20 @@ test_coglbox_init (TestCoglbox *self)
{ {
for (x=0; x<width; ++x) for (x=0; x<width; ++x)
{ {
pixel = data + y * width * 4 + x * 4; pixel = data + y * rowstride + x * 4;
if (format == COGL_PIXEL_FORMAT_RGBA_8888)
{
t = pixel[0]; t = pixel[0];
pixel[0] = pixel[1]; pixel[0] = pixel[1];
pixel[1] = t; 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) if (width2 > width)
width = width2; width = width2;
if (height> height) if (height2 > height)
height = height2; height = height2;
clutter_actor_set_size (rectangle, width, height); clutter_actor_set_size (rectangle, width, height);

View file

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

View file

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