clutter-offscreen-effect: Don't recreate the material when FBO changes
Previously whenever the size of the FBO changes it would create a new material and attach the texture to it. This is not good for Cogl because it throws away any cached state for the material. In test-rotate the size of the FBO changes constantly so it effectively uses a new material every paint. For shader effects this also ends up relinking the shader every paint because the linked programs are part of the material state.
This commit is contained in:
parent
1b2a748d6c
commit
6ddb839711
@ -152,13 +152,8 @@ update_fbo (ClutterEffect *effect, int fbo_width, int fbo_height)
|
|||||||
priv->target_height == fbo_height)
|
priv->target_height == fbo_height)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
if (priv->target != COGL_INVALID_HANDLE)
|
if (priv->target == COGL_INVALID_HANDLE)
|
||||||
{
|
priv->target = cogl_material_new ();
|
||||||
cogl_handle_unref (priv->target);
|
|
||||||
cogl_handle_unref (priv->offscreen);
|
|
||||||
}
|
|
||||||
|
|
||||||
priv->target = cogl_material_new ();
|
|
||||||
|
|
||||||
texture =
|
texture =
|
||||||
clutter_offscreen_effect_create_texture (self, fbo_width, fbo_height);
|
clutter_offscreen_effect_create_texture (self, fbo_width, fbo_height);
|
||||||
@ -175,6 +170,9 @@ update_fbo (ClutterEffect *effect, int fbo_width, int fbo_height)
|
|||||||
priv->target_width = cogl_texture_get_width (texture);
|
priv->target_width = cogl_texture_get_width (texture);
|
||||||
priv->target_height = cogl_texture_get_height (texture);
|
priv->target_height = cogl_texture_get_height (texture);
|
||||||
|
|
||||||
|
if (priv->offscreen != COGL_INVALID_HANDLE)
|
||||||
|
cogl_handle_unref (priv->offscreen);
|
||||||
|
|
||||||
priv->offscreen = cogl_offscreen_new_to_texture (texture);
|
priv->offscreen = cogl_offscreen_new_to_texture (texture);
|
||||||
if (priv->offscreen == COGL_INVALID_HANDLE)
|
if (priv->offscreen == COGL_INVALID_HANDLE)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user