clutter: Stop using cogl_offscreen_new_to_texture()

It's deprecated, drops errors silently, so change to the proper
function.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1496
This commit is contained in:
Jonas Ådahl 2020-10-13 09:31:28 +02:00 committed by Georges Basile Stavracas Neto
parent e7ac3e2715
commit b947dced40
2 changed files with 18 additions and 6 deletions

View File

@ -173,6 +173,8 @@ update_fbo (ClutterEffect *effect,
ClutterOffscreenEffect *self = CLUTTER_OFFSCREEN_EFFECT (effect);
ClutterOffscreenEffectPrivate *priv = self->priv;
ClutterActor *stage_actor;
CoglOffscreen *offscreen;
g_autoptr (GError) error = NULL;
stage_actor = clutter_actor_get_stage (priv->actor);
if (stage_actor != priv->stage)
@ -231,11 +233,13 @@ update_fbo (ClutterEffect *effect,
priv->target_width = target_width;
priv->target_height = target_height;
priv->offscreen = cogl_offscreen_new_to_texture (priv->texture);
if (priv->offscreen == NULL)
offscreen = cogl_offscreen_new_with_texture (priv->texture);
if (!cogl_framebuffer_allocate (COGL_FRAMEBUFFER (offscreen), &error))
{
g_warning ("%s: Unable to create an Offscreen buffer", G_STRLOC);
g_warning ("Failed to create offscreen effect framebuffer: %s",
error->message);
cogl_object_unref (offscreen);
cogl_object_unref (priv->pipeline);
priv->pipeline = NULL;
@ -245,6 +249,8 @@ update_fbo (ClutterEffect *effect,
return FALSE;
}
priv->offscreen = offscreen;
return TRUE;
}

View File

@ -1415,6 +1415,8 @@ clutter_layer_node_new (const graphene_matrix_t *projection,
CoglTexture2D *tex_2d;
CoglTexture *texture;
CoglColor color;
CoglOffscreen *offscreen;
g_autoptr (GError) error = NULL;
res = _clutter_paint_node_create (CLUTTER_TYPE_LAYER_NODE);
@ -1433,13 +1435,17 @@ clutter_layer_node_new (const graphene_matrix_t *projection,
texture = COGL_TEXTURE (tex_2d);
cogl_texture_set_premultiplied (texture, TRUE);
res->offscreen = COGL_FRAMEBUFFER (cogl_offscreen_new_to_texture (texture));
if (res->offscreen == NULL)
offscreen = cogl_offscreen_new_with_texture (texture);
if (!cogl_framebuffer_allocate (COGL_FRAMEBUFFER (offscreen), &error))
{
g_critical ("%s: Unable to create an offscreen buffer", G_STRLOC);
g_warning ("Unable to create an allocate paint node offscreen: %s",
error->message);
cogl_object_unref (offscreen);
goto out;
}
res->offscreen = COGL_FRAMEBUFFER (offscreen);
cogl_color_init_from_4ub (&color, opacity, opacity, opacity, opacity);
/* the pipeline used to paint the texture; we use nearest