mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 08:00:42 -05:00
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
This commit is contained in:
parent
f3b9fc8159
commit
14bb104ef0
@ -76,6 +76,7 @@ executable('test-interactive',
|
||||
sources: clutter_tests_interactive_sources,
|
||||
include_directories: [
|
||||
clutter_includes,
|
||||
clutter_tests_includepath,
|
||||
clutter_tests_interactive_includepath,
|
||||
],
|
||||
c_args: clutter_tests_interactive_c_args,
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include <glib.h>
|
||||
#include <gmodule.h>
|
||||
|
||||
#include "test-utils.h"
|
||||
|
||||
#define NHANDS 6
|
||||
|
||||
typedef struct SuperOH
|
||||
@ -195,7 +197,7 @@ test_actors_main (int argc, char *argv[])
|
||||
g_signal_connect (oh->timeline, "new-frame", G_CALLBACK (frame_cb), oh);
|
||||
|
||||
file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL);
|
||||
real_hand = clutter_texture_new_from_file (file, &error);
|
||||
real_hand = clutter_test_utils_create_texture_from_file (file, &error);
|
||||
if (real_hand == NULL)
|
||||
g_error ("image load failed: %s", error->message);
|
||||
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include <clutter/x11/clutter-x11.h>
|
||||
#endif
|
||||
|
||||
#include "test-utils.h"
|
||||
|
||||
typedef struct {
|
||||
ClutterActor *stage;
|
||||
|
||||
@ -172,7 +174,7 @@ manager_device_added_cb (ClutterDeviceManager *manager,
|
||||
|
||||
clutter_input_device_set_enabled (device, TRUE);
|
||||
|
||||
hand = clutter_texture_new_from_file (TESTS_DATADIR
|
||||
hand = clutter_test_utils_create_texture_from_file (TESTS_DATADIR
|
||||
G_DIR_SEPARATOR_S
|
||||
"redhand.png",
|
||||
NULL);
|
||||
@ -273,7 +275,7 @@ test_devices_main (int argc, char **argv)
|
||||
|
||||
clutter_input_device_set_enabled (device, TRUE);
|
||||
|
||||
hand = clutter_texture_new_from_file (TESTS_DATADIR
|
||||
hand = clutter_test_utils_create_texture_from_file (TESTS_DATADIR
|
||||
G_DIR_SEPARATOR_S
|
||||
"redhand.png",
|
||||
NULL);
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <cogl/cogl.h>
|
||||
|
||||
#include <clutter/clutter.h>
|
||||
#include "test-utils.h"
|
||||
|
||||
/* layout actor, by Lucas Rocha */
|
||||
|
||||
@ -629,7 +630,7 @@ test_layout_main (int argc, char *argv[])
|
||||
clutter_actor_set_position (box, 20, 20);
|
||||
clutter_actor_set_size (box, 350, -1);
|
||||
|
||||
icon = clutter_texture_new_from_file (TESTS_DATADIR
|
||||
icon = clutter_test_utils_create_texture_from_file (TESTS_DATADIR
|
||||
G_DIR_SEPARATOR_S
|
||||
"redhand.png",
|
||||
&error);
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include "clutter/x11/clutter-x11.h"
|
||||
#endif
|
||||
|
||||
#include "test-utils.h"
|
||||
|
||||
#define NHANDS 6
|
||||
|
||||
typedef struct SuperOH
|
||||
@ -247,7 +249,7 @@ test_paint_wrapper_main (int argc, char *argv[])
|
||||
oh->frame_id =
|
||||
g_signal_connect (oh->timeline, "new-frame", G_CALLBACK (frame_cb), oh);
|
||||
|
||||
real_hand = clutter_texture_new_from_file (TESTS_DATADIR
|
||||
real_hand = clutter_test_utils_create_texture_from_file (TESTS_DATADIR
|
||||
G_DIR_SEPARATOR_S
|
||||
"redhand.png",
|
||||
&error);
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <gmodule.h>
|
||||
|
||||
#include <clutter/clutter.h>
|
||||
#include "test-utils.h"
|
||||
|
||||
int
|
||||
test_shader_effects_main (int argc, char *argv[]);
|
||||
@ -31,7 +32,7 @@ test_shader_effects_main (int argc, char *argv[])
|
||||
|
||||
/* Make a hand */
|
||||
file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL);
|
||||
hand = clutter_texture_new_from_file (file, NULL);
|
||||
hand = clutter_test_utils_create_texture_from_file (file, NULL);
|
||||
if (!hand)
|
||||
g_error("Unable to load '%s'", file);
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <math.h>
|
||||
#include <gmodule.h>
|
||||
#include <clutter/clutter.h>
|
||||
#include "test-utils.h"
|
||||
|
||||
#define STAGE_WIDTH 1024
|
||||
#define STAGE_HEIGHT 768
|
||||
@ -82,7 +83,7 @@ static ClutterActor *new_rect (gint r,
|
||||
|
||||
gchar *file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL);
|
||||
|
||||
hand = clutter_texture_new_from_file (file, &error);
|
||||
hand = clutter_test_utils_create_texture_from_file (file, &error);
|
||||
if (rectangle == NULL)
|
||||
g_error ("image load failed: %s", error->message);
|
||||
g_free (file);
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <clutter/clutter.h>
|
||||
#include <cogl/cogl.h>
|
||||
#include <cogl-pango/cogl-pango.h>
|
||||
#include "test-utils.h"
|
||||
|
||||
#define FONT "Sans 12"
|
||||
|
||||
@ -155,7 +156,7 @@ create_image (const gchar *file, const gchar *color)
|
||||
ClutterActor *texture;
|
||||
ClutterActor *result;
|
||||
|
||||
texture = clutter_texture_new_from_file (file, NULL);
|
||||
texture = clutter_test_utils_create_texture_from_file (file, NULL);
|
||||
g_object_set (G_OBJECT (texture), "keep-aspect-ratio", TRUE, NULL);
|
||||
clutter_actor_show (texture);
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
clutter_tests_includepath = include_directories('.')
|
||||
|
||||
subdir('accessibility')
|
||||
subdir('conform')
|
||||
subdir('interactive')
|
||||
|
@ -24,7 +24,10 @@ foreach test : clutter_tests_performance_tests
|
||||
'@0@.c'.format(test),
|
||||
'test-common.h',
|
||||
],
|
||||
include_directories: clutter_includes,
|
||||
include_directories: [
|
||||
clutter_includes,
|
||||
clutter_tests_includepath,
|
||||
],
|
||||
c_args: clutter_tests_performance_c_args,
|
||||
dependencies: [
|
||||
clutter_deps,
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <gmodule.h>
|
||||
#include <clutter/clutter.h>
|
||||
#include "test-common.h"
|
||||
#include "test-utils.h"
|
||||
|
||||
#define STAGE_WIDTH 800
|
||||
#define STAGE_HEIGHT 600
|
||||
@ -77,7 +78,7 @@ static ClutterActor *new_rect (gint r,
|
||||
|
||||
gchar *file = g_build_filename (TESTS_DATA_DIR, "redhand.png", NULL);
|
||||
|
||||
hand = clutter_texture_new_from_file (file, &error);
|
||||
hand = clutter_test_utils_create_texture_from_file (file, &error);
|
||||
if (rectangle == NULL)
|
||||
g_error ("image load failed: %s", error->message);
|
||||
g_free (file);
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <gmodule.h>
|
||||
#include <clutter/clutter.h>
|
||||
#include "test-common.h"
|
||||
#include "test-utils.h"
|
||||
|
||||
#define STAGE_WIDTH 160
|
||||
#define STAGE_HEIGHT 120
|
||||
@ -44,7 +45,7 @@ static ClutterActor *new_rect (gint r,
|
||||
|
||||
gchar *file = g_build_filename (TESTS_DATA_DIR, "redhand.png", NULL);
|
||||
|
||||
hand = clutter_texture_new_from_file (file, &error);
|
||||
hand = clutter_test_utils_create_texture_from_file (file, &error);
|
||||
if (rectangle == NULL)
|
||||
g_error ("image load failed: %s", error->message);
|
||||
g_free (file);
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <gmodule.h>
|
||||
#include <clutter/clutter.h>
|
||||
#include "test-common.h"
|
||||
#include "test-utils.h"
|
||||
|
||||
static gint times = 16;
|
||||
|
||||
@ -49,7 +50,7 @@ static ClutterActor *new_rect (gint r,
|
||||
|
||||
gchar *file = g_build_filename (TESTS_DATA_DIR, "redhand.png", NULL);
|
||||
|
||||
hand = clutter_texture_new_from_file (file, &error);
|
||||
hand = clutter_test_utils_create_texture_from_file (file, &error);
|
||||
if (rectangle == NULL)
|
||||
g_error ("image load failed: %s", error->message);
|
||||
g_free (file);
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <gmodule.h>
|
||||
#include <clutter/clutter.h>
|
||||
#include "test-common.h"
|
||||
#include "test-utils.h"
|
||||
|
||||
static gint times = 16;
|
||||
|
||||
@ -49,7 +50,7 @@ static ClutterActor *new_rect (gint r,
|
||||
|
||||
gchar *file = g_build_filename (TESTS_DATA_DIR, "redhand.png", NULL);
|
||||
|
||||
hand = clutter_texture_new_from_file (file, &error);
|
||||
hand = clutter_test_utils_create_texture_from_file (file, &error);
|
||||
if (rectangle == NULL)
|
||||
g_error ("image load failed: %s", error->message);
|
||||
g_free (file);
|
||||
|
30
src/tests/clutter/test-utils.h
Normal file
30
src/tests/clutter/test-utils.h
Normal file
@ -0,0 +1,30 @@
|
||||
#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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user