From 08087c965bf312513f98a53bf3220e92c372d131 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Sat, 27 Nov 2010 16:26:20 +0000 Subject: [PATCH] ClutterShaderEffect: Don't throw away the program for a new actor Previously when the shader effect is used with a new actor it would end up throwing away the old program. I don't think this is neccessary and it means if you use an effect to temporarily bind to an actor then it will recompile the shader whenever it is applied. http://bugzilla.clutter-project.org/show_bug.cgi?id=2454 --- clutter/clutter-shader-effect.c | 42 +++++++++++++++------------------ 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/clutter/clutter-shader-effect.c b/clutter/clutter-shader-effect.c index 727431045..3ef18eac9 100644 --- a/clutter/clutter-shader-effect.c +++ b/clutter/clutter-shader-effect.c @@ -297,9 +297,6 @@ clutter_shader_effect_set_actor (ClutterActorMeta *meta, return; } - clutter_shader_effect_clear (self, FALSE); - clutter_shader_effect_reset_uniforms (self); - parent = CLUTTER_ACTOR_META_CLASS (clutter_shader_effect_parent_class); parent->set_actor (meta, actor); @@ -310,25 +307,6 @@ clutter_shader_effect_set_actor (ClutterActorMeta *meta, CLUTTER_NOTE (SHADER, "Preparing shader effect of type '%s'", G_OBJECT_TYPE_NAME (meta)); - - priv->program = cogl_create_program (); - - switch (priv->shader_type) - { - case CLUTTER_FRAGMENT_SHADER: - priv->shader = cogl_create_shader (COGL_SHADER_TYPE_FRAGMENT); - break; - - case CLUTTER_VERTEX_SHADER: - priv->shader = cogl_create_shader (COGL_SHADER_TYPE_VERTEX); - break; - - default: - priv->shader = COGL_INVALID_HANDLE; - break; - } - - g_assert (priv->shader != COGL_INVALID_HANDLE); } static void @@ -844,8 +822,26 @@ clutter_shader_effect_set_shader_source (ClutterShaderEffect *effect, if (priv->source_set) return TRUE; + if (priv->program == COGL_INVALID_HANDLE) + priv->program = cogl_create_program (); + if (priv->shader == COGL_INVALID_HANDLE) - return FALSE; + switch (priv->shader_type) + { + case CLUTTER_FRAGMENT_SHADER: + priv->shader = cogl_create_shader (COGL_SHADER_TYPE_FRAGMENT); + break; + + case CLUTTER_VERTEX_SHADER: + priv->shader = cogl_create_shader (COGL_SHADER_TYPE_VERTEX); + break; + + default: + priv->shader = COGL_INVALID_HANDLE; + break; + } + + g_assert (priv->shader != COGL_INVALID_HANDLE); cogl_shader_source (priv->shader, source);