mutter/src/tests/clutter/test-utils.h
Jonas Ådahl 14bb104ef0 tests/clutter: Replace ClutterTexture from image with custom helper
ClutterTexture is deprecated, lets remove the trivial usage with a
simple gdk-pixbuf using constructor putting pixel contents into a
ClutterImage then putting said image in a plain ClutterActor.

Tested partially, as the interactive tests cannot be properly run at the
moment.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/932
2019-11-13 13:56:08 +00:00

31 lines
1.1 KiB
C

#include <clutter/clutter.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
static inline ClutterActor *
clutter_test_utils_create_texture_from_file (const char *filename,
GError **error)
{
g_autoptr (ClutterContent) image = NULL;
g_autoptr (GdkPixbuf) pixbuf = NULL;
pixbuf = gdk_pixbuf_new_from_file (filename, error);
if (!pixbuf)
return NULL;
image = clutter_image_new ();
if (!clutter_image_set_data (CLUTTER_IMAGE (image),
gdk_pixbuf_get_pixels (pixbuf),
gdk_pixbuf_get_has_alpha (pixbuf)
? COGL_PIXEL_FORMAT_RGBA_8888
: COGL_PIXEL_FORMAT_RGB_888,
gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf),
gdk_pixbuf_get_rowstride (pixbuf),
error))
return NULL;
return g_object_new (CLUTTER_TYPE_ACTOR,
"content", image,
NULL);
}