tests/interactive: Replace cogl_texture_new_from_file

The interactive tests are the last users use this deprecated API, so
port them to the appropriate alternatives - either CoglTexture2D or
CoglTexture2DSliced.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2355>
This commit is contained in:
Georges Basile Stavracas Neto 2022-03-31 12:32:07 -03:00
parent ca0e467a3b
commit 8f6469f6cb
5 changed files with 23 additions and 41 deletions

View File

@ -124,6 +124,7 @@ test_cogl_multitexture_main (int argc, char *argv[])
0, 0, 1, 1,
0, 0, 1, 1
};
CoglContext *ctx;
clutter_test_init (&argc, &argv);
@ -150,35 +151,20 @@ test_cogl_multitexture_main (int argc, char *argv[])
files[2] = g_build_filename (TESTS_DATADIR, "light0.png", NULL);
files[3] = NULL;
state->alpha_tex =
cogl_texture_new_from_file (files[0],
COGL_TEXTURE_NO_SLICING,
COGL_PIXEL_FORMAT_ANY,
&error);
ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ());
state->alpha_tex = cogl_texture_2d_new_from_file (ctx, files[0], &error);
if (!state->alpha_tex)
g_critical ("Failed to load redhand_alpha.png: %s", error->message);
state->redhand_tex =
cogl_texture_new_from_file (files[1],
COGL_TEXTURE_NO_SLICING,
COGL_PIXEL_FORMAT_ANY,
&error);
state->redhand_tex = cogl_texture_2d_new_from_file (ctx, files[1], &error);
if (!state->redhand_tex)
g_critical ("Failed to load redhand.png: %s", error->message);
state->light_tex0 =
cogl_texture_new_from_file (files[2],
COGL_TEXTURE_NO_SLICING,
COGL_PIXEL_FORMAT_ANY,
&error);
state->light_tex0 = cogl_texture_2d_new_from_file (ctx, files[2], &error);
if (!state->light_tex0)
g_critical ("Failed to load light0.png: %s", error->message);
state->light_tex1 =
cogl_texture_new_from_file (files[2],
COGL_TEXTURE_NO_SLICING,
COGL_PIXEL_FORMAT_ANY,
&error);
state->light_tex1 = cogl_texture_2d_new_from_file (ctx, files[2], &error);
if (!state->light_tex1)
g_critical ("Failed to load light0.png: %s", error->message);

View File

@ -226,16 +226,16 @@ test_coglbox_map (ClutterActor *actor)
static void
test_coglbox_init (TestCoglbox *self)
{
g_autoptr (GError) error = NULL;
CoglContext *ctx =
clutter_backend_get_cogl_context (clutter_get_default_backend ());
gchar *file;
printf ("Loading redhand.png\n");
file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL);
self->texhand_id = cogl_texture_new_from_file (file,
COGL_TEXTURE_NONE,
COGL_PIXEL_FORMAT_ANY,
NULL);
self->texhand_id = cogl_texture_2d_new_from_file (ctx, file, &error);
if (error)
g_warning ("Error loading redhand.png: %s", error->message);
g_free (file);
printf ("Creating texture with size\n");

View File

@ -323,10 +323,7 @@ test_cogl_shader_glsl_main (int argc, char *argv[])
file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL);
error = NULL;
redhand = cogl_texture_new_from_file (file,
COGL_TEXTURE_NO_ATLAS,
COGL_PIXEL_FORMAT_ANY,
&error);
redhand = cogl_texture_2d_new_from_file (ctx, file, &error);
if (redhand == NULL)
g_error ("image load failed: %s", error->message);

View File

@ -227,6 +227,8 @@ test_coglbox_dispose (GObject *object)
static void
test_coglbox_init (TestCoglbox *self)
{
CoglContext *ctx =
clutter_backend_get_cogl_context (clutter_get_default_backend ());
GError *error = NULL;
gchar *file;
@ -235,10 +237,9 @@ test_coglbox_init (TestCoglbox *self)
file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL);
self->sliced_tex =
cogl_texture_new_from_file (file,
COGL_TEXTURE_NONE,
COGL_PIXEL_FORMAT_ANY,
&error);
cogl_texture_2d_sliced_new_from_file (ctx, file,
COGL_TEXTURE_MAX_WASTE,
&error);
if (self->sliced_tex == NULL)
{
if (error)
@ -251,11 +252,7 @@ test_coglbox_init (TestCoglbox *self)
g_warning ("Texture loading failed: <unknown>");
}
self->not_sliced_tex =
cogl_texture_new_from_file (file,
COGL_TEXTURE_NO_SLICING,
COGL_PIXEL_FORMAT_ANY,
&error);
self->not_sliced_tex = cogl_texture_2d_new_from_file (ctx, file, &error);
if (self->not_sliced_tex == NULL)
{
if (error)

View File

@ -100,13 +100,15 @@ test_coglbox_dispose (GObject *object)
static void
test_coglbox_init (TestCoglbox *self)
{
g_autoptr (GError) error = NULL;
CoglContext *ctx =
clutter_backend_get_cogl_context (clutter_get_default_backend ());
gchar *file;
file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL);
self->cogl_tex_id = cogl_texture_new_from_file (file,
COGL_TEXTURE_NONE,
COGL_PIXEL_FORMAT_ANY,
NULL);
self->cogl_tex_id = cogl_texture_2d_new_from_file (ctx, file, &error);
if (error)
g_warning ("Error loading redhand.png: %s", error->message);
g_free (file);
}