st: Use template material for transitions

To avoid compiling a new shader each time a transition is started,
use a copy of a static template material.

See http://bugzilla.clutter-project.org/show_bug.cgi?id=2280#c5.

https://bugzilla.gnome.org/show_bug.cgi?id=629384
This commit is contained in:
Florian Müllner 2010-09-12 00:18:52 +02:00
parent 7c65643eed
commit 862f1ea18c

View File

@ -55,6 +55,9 @@ struct _StThemeNodeTransitionPrivate {
static guint signals[LAST_SIGNAL] = { 0 }; static guint signals[LAST_SIGNAL] = { 0 };
/* template material to avoid unnecessary shader compilation */
static CoglHandle global_material = COGL_INVALID_HANDLE;
G_DEFINE_TYPE (StThemeNodeTransition, st_theme_node_transition, G_TYPE_OBJECT); G_DEFINE_TYPE (StThemeNodeTransition, st_theme_node_transition, G_TYPE_OBJECT);
@ -244,21 +247,27 @@ setup_framebuffers (StThemeNodeTransition *transition,
g_return_val_if_fail (priv->old_offscreen != COGL_INVALID_HANDLE, FALSE); g_return_val_if_fail (priv->old_offscreen != COGL_INVALID_HANDLE, FALSE);
g_return_val_if_fail (priv->new_offscreen != COGL_INVALID_HANDLE, FALSE); g_return_val_if_fail (priv->new_offscreen != COGL_INVALID_HANDLE, FALSE);
if (priv->material) if (priv->material == NULL)
cogl_handle_unref (priv->material); {
priv->material = cogl_material_new (); if (G_UNLIKELY (global_material == COGL_INVALID_HANDLE))
{
global_material = cogl_material_new ();
cogl_material_set_layer_combine (priv->material, 0, cogl_material_set_layer_combine (global_material, 0,
"RGBA = REPLACE (TEXTURE)", "RGBA = REPLACE (TEXTURE)",
NULL); NULL);
cogl_material_set_layer_combine (priv->material, 1, cogl_material_set_layer_combine (global_material, 1,
"RGBA = INTERPOLATE (PREVIOUS, " "RGBA = INTERPOLATE (PREVIOUS, "
"TEXTURE, " "TEXTURE, "
"CONSTANT[A])", "CONSTANT[A])",
NULL); NULL);
cogl_material_set_layer_combine (priv->material, 2, cogl_material_set_layer_combine (global_material, 2,
"RGBA = MODULATE (PREVIOUS, PRIMARY)", "RGBA = MODULATE (PREVIOUS, "
"PRIMARY)",
NULL); NULL);
}
priv->material = cogl_material_copy (global_material);
}
cogl_material_set_layer (priv->material, 0, priv->new_texture); cogl_material_set_layer (priv->material, 0, priv->new_texture);
cogl_material_set_layer (priv->material, 1, priv->old_texture); cogl_material_set_layer (priv->material, 1, priv->old_texture);