mirror of
https://github.com/brl/mutter.git
synced 2024-11-27 02:20:43 -05:00
863837baec
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.)
115 lines
2.7 KiB
C
115 lines
2.7 KiB
C
#ifdef HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <clutter/clutter.h>
|
|
|
|
guchar*
|
|
make_rgba_data (int width, int height, int bpp, int has_alpha, int *rowstride_p)
|
|
{
|
|
#define CHECK_SIZE 20
|
|
|
|
gint x,y, rowstride, n_channels, i = 0;
|
|
guchar *pixels;
|
|
|
|
g_assert(bpp == 4);
|
|
g_assert(has_alpha == TRUE);
|
|
|
|
rowstride = width * bpp;
|
|
*rowstride_p = rowstride;
|
|
|
|
pixels = g_try_malloc (height * rowstride);
|
|
if (!pixels)
|
|
return NULL;
|
|
|
|
for (y = 0; y < height; y++)
|
|
{
|
|
i = 0;
|
|
for (x = 0; x < width; x++)
|
|
{
|
|
guchar *p;
|
|
|
|
p = pixels + y * rowstride + x * bpp;
|
|
|
|
p[0] = p[1] = p[2] = 0; p[3] = 0xff;
|
|
|
|
if (x && y && y % CHECK_SIZE && x % CHECK_SIZE)
|
|
{
|
|
if (x % CHECK_SIZE == 1)
|
|
{
|
|
if (++i > 3)
|
|
i = 0;
|
|
}
|
|
p[i] = 0xff;
|
|
}
|
|
}
|
|
}
|
|
|
|
return pixels;
|
|
}
|
|
|
|
#define SPIN() while (g_main_context_pending (NULL)) \
|
|
g_main_context_iteration (NULL, FALSE);
|
|
|
|
int
|
|
main (int argc, char *argv[])
|
|
{
|
|
ClutterActor *texture;
|
|
ClutterActor *stage;
|
|
gint i, j;
|
|
|
|
clutter_init (&argc, &argv);
|
|
|
|
stage = clutter_stage_get_default ();
|
|
clutter_actor_show_all (CLUTTER_ACTOR (stage));
|
|
|
|
SPIN();
|
|
|
|
for (i=100; i<=5000; i += 100)
|
|
for (j=0; j<4; 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;
|
|
|
|
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");
|
|
|
|
clutter_container_add (CLUTTER_CONTAINER (stage), texture, NULL);
|
|
clutter_actor_set_size (texture, 400, 400);
|
|
clutter_actor_show (texture);
|
|
|
|
/* Hide & show to unreaise then realise the texture */
|
|
clutter_actor_hide (texture);
|
|
clutter_actor_show (texture);
|
|
|
|
SPIN();
|
|
|
|
clutter_container_remove (CLUTTER_CONTAINER (stage), texture, NULL);
|
|
}
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|