From 863837baec9747d1bd92de180f312bd891786b06 Mon Sep 17 00:00:00 2001 From: Tommi Komulainen Date: Tue, 10 Jun 2008 06:37:46 +0000 Subject: [PATCH] 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.) --- ChangeLog | 29 ++++++++++++ clutter/clutter-keysyms-table.h | 2 +- clutter/clutter-timeline.c | 4 +- clutter/clutter-timeline.h | 2 +- configure.ac | 2 +- tests/test-cogl-tex-getset.c | 26 ++++++++--- tests/test-depth.c | 2 +- tests/test-paint-wrapper.c | 4 +- tests/test-textures.c | 78 +++++++++++++++------------------ 9 files changed, 93 insertions(+), 56 deletions(-) diff --git a/ChangeLog b/ChangeLog index b7cfdb2a8..f6836719c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,32 @@ +2008-06-10 Tommi Komulainen + + 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 * clutter/osx/clutter-backend-osx.c (clutter_backend_osx_post_parse): diff --git a/clutter/clutter-keysyms-table.h b/clutter/clutter-keysyms-table.h index 79f0c8f19..113f55453 100644 --- a/clutter/clutter-keysyms-table.h +++ b/clutter/clutter-keysyms-table.h @@ -824,4 +824,4 @@ struct { /* End numeric keypad */ }; -#endif /* __CLUTTER_KEYSYMS_H__ */ +#endif /* __CLUTTER_KEYSYMS_TABLE_H__ */ diff --git a/clutter/clutter-timeline.c b/clutter/clutter-timeline.c index 20a4a9d8c..da6b020c3 100644 --- a/clutter/clutter-timeline.c +++ b/clutter/clutter-timeline.c @@ -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); diff --git a/clutter/clutter-timeline.h b/clutter/clutter-timeline.h index 980224984..07014d571 100644 --- a/clutter/clutter-timeline.h +++ b/clutter/clutter-timeline.h @@ -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, diff --git a/configure.ac b/configure.ac index 56ae83ae1..4348a4be8 100644 --- a/configure.ac +++ b/configure.ac @@ -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) diff --git a/tests/test-cogl-tex-getset.c b/tests/test-cogl-tex-getset.c index ce5d1ba6f..c8ecf38fe 100644 --- a/tests/test-cogl-tex-getset.c +++ b/tests/test-cogl-tex-getset.c @@ -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) width = width2; - if (height> height) + if (height2 > height) height = height2; clutter_actor_set_size (rectangle, width, height); diff --git a/tests/test-paint-wrapper.c b/tests/test-paint-wrapper.c index bf3692525..2527df53e 100644 --- a/tests/test-paint-wrapper.c +++ b/tests/test-paint-wrapper.c @@ -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); diff --git a/tests/test-textures.c b/tests/test-textures.c index 6d213a0d0..2a770003a 100644 --- a/tests/test-textures.c +++ b/tests/test-textures.c @@ -6,26 +6,23 @@ #include -#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; }