Remove last uses of cogl_program_uniform*

Following the commits:

  c03544da - clutter-shader: use cogl_program_set_uniform_xyz API
  a26119b5 - tests: Remove use of cogl_program_use

Remove the users of cogl_program_uniform_* and cogl_program_use() in the
shader-based effects.
This commit is contained in:
Emmanuele Bassi 2010-08-12 17:06:29 +01:00
parent e016a62ab0
commit daf6e73936
4 changed files with 34 additions and 31 deletions

View File

@ -221,18 +221,18 @@ clutter_blur_effect_paint_target (ClutterOffscreenEffect *effect)
if (self->program == COGL_INVALID_HANDLE) if (self->program == COGL_INVALID_HANDLE)
goto out; goto out;
cogl_program_use (self->program);
if (self->tex_uniform > -1) if (self->tex_uniform > -1)
cogl_program_uniform_1i (self->tex_uniform, 0); cogl_program_set_uniform_1i (self->program, self->tex_uniform, 0);
if (self->x_step_uniform > -1) if (self->x_step_uniform > -1)
cogl_program_uniform_1f (self->x_step_uniform, self->x_step); cogl_program_set_uniform_1f (self->program,
self->x_step_uniform,
self->x_step);
if (self->y_step_uniform > -1) if (self->y_step_uniform > -1)
cogl_program_uniform_1f (self->y_step_uniform, self->y_step); cogl_program_set_uniform_1f (self->program,
self->y_step_uniform,
cogl_program_use (COGL_INVALID_HANDLE); self->y_step);
material = clutter_offscreen_effect_get_target (effect); material = clutter_offscreen_effect_get_target (effect);
cogl_material_set_user_program (material, self->program); cogl_material_set_user_program (material, self->program);

View File

@ -200,10 +200,8 @@ clutter_colorize_effect_paint_target (ClutterOffscreenEffect *effect)
if (self->program == COGL_INVALID_HANDLE) if (self->program == COGL_INVALID_HANDLE)
goto out; goto out;
cogl_program_use (self->program);
if (self->tex_uniform > -1) if (self->tex_uniform > -1)
cogl_program_uniform_1i (self->tex_uniform, 0); cogl_program_set_uniform_1i (self->program, self->tex_uniform, 0);
if (self->tint_uniform > -1) if (self->tint_uniform > -1)
{ {
@ -213,11 +211,11 @@ clutter_colorize_effect_paint_target (ClutterOffscreenEffect *effect)
self->tint.blue / 255.0 self->tint.blue / 255.0
}; };
cogl_program_uniform_float (self->tint_uniform, 3, 1, tint); cogl_program_set_uniform_float (self->program, self->tint_uniform,
3, 1,
tint);
} }
cogl_program_use (COGL_INVALID_HANDLE);
material = clutter_offscreen_effect_get_target (effect); material = clutter_offscreen_effect_get_target (effect);
cogl_material_set_user_program (material, self->program); cogl_material_set_user_program (material, self->program);

View File

@ -209,15 +209,13 @@ clutter_desaturate_effect_paint_target (ClutterOffscreenEffect *effect)
if (self->program == COGL_INVALID_HANDLE) if (self->program == COGL_INVALID_HANDLE)
goto out; goto out;
cogl_program_use (self->program);
if (self->tex_uniform > -1) if (self->tex_uniform > -1)
cogl_program_uniform_1i (self->tex_uniform, 0); cogl_program_set_uniform_1i (self->program, self->tex_uniform, 0);
if (self->factor_uniform > -1) if (self->factor_uniform > -1)
cogl_program_uniform_1f (self->factor_uniform, self->factor); cogl_program_set_uniform_1f (self->program,
self->factor_uniform,
cogl_program_use (COGL_INVALID_HANDLE); self->factor);
material = clutter_offscreen_effect_get_target (effect); material = clutter_offscreen_effect_get_target (effect);
cogl_material_set_user_program (material, self->program); cogl_material_set_user_program (material, self->program);

View File

@ -211,13 +211,11 @@ clutter_shader_effect_update_uniforms (ClutterShaderEffect *effect)
gpointer key, value; gpointer key, value;
gsize size; gsize size;
if (priv->uniforms == NULL) if (priv->program == COGL_INVALID_HANDLE)
return; return;
/* XXX - we need to do this dance here because the cogl_program_uniform* if (priv->uniforms == NULL)
* family of functions do not take the program as a parameter return;
*/
cogl_program_use (priv->program);
key = value = NULL; key = value = NULL;
g_hash_table_iter_init (&iter, priv->uniforms); g_hash_table_iter_init (&iter, priv->uniforms);
@ -234,41 +232,50 @@ clutter_shader_effect_update_uniforms (ClutterShaderEffect *effect)
const GLfloat *floats; const GLfloat *floats;
floats = clutter_value_get_shader_float (&uniform->value, &size); floats = clutter_value_get_shader_float (&uniform->value, &size);
cogl_program_uniform_float (uniform->location, size, 1, floats); cogl_program_set_uniform_float (priv->program, uniform->location,
size, 1,
floats);
} }
else if (CLUTTER_VALUE_HOLDS_SHADER_INT (&uniform->value)) else if (CLUTTER_VALUE_HOLDS_SHADER_INT (&uniform->value))
{ {
const GLint *ints; const GLint *ints;
ints = clutter_value_get_shader_int (&uniform->value, &size); ints = clutter_value_get_shader_int (&uniform->value, &size);
cogl_program_uniform_int (uniform->location, size, 1, ints); cogl_program_set_uniform_int (priv->program, uniform->location,
size, 1,
ints);
} }
else if (CLUTTER_VALUE_HOLDS_SHADER_MATRIX (&uniform->value)) else if (CLUTTER_VALUE_HOLDS_SHADER_MATRIX (&uniform->value))
{ {
const GLfloat *matrix; const GLfloat *matrix;
matrix = clutter_value_get_shader_matrix (&uniform->value, &size); matrix = clutter_value_get_shader_matrix (&uniform->value, &size);
cogl_program_uniform_matrix (uniform->location, size, 1, FALSE, matrix); cogl_program_set_uniform_matrix (priv->program, uniform->location,
size, 1,
FALSE,
matrix);
} }
else if (G_VALUE_HOLDS_FLOAT (&uniform->value)) else if (G_VALUE_HOLDS_FLOAT (&uniform->value))
{ {
const GLfloat float_val = g_value_get_float (&uniform->value); const GLfloat float_val = g_value_get_float (&uniform->value);
cogl_program_uniform_float (uniform->location, 1, 1, &float_val); cogl_program_set_uniform_float (priv->program, uniform->location,
1, 1,
&float_val);
} }
else if (G_VALUE_HOLDS_INT (&uniform->value)) else if (G_VALUE_HOLDS_INT (&uniform->value))
{ {
const GLint int_val = g_value_get_int (&uniform->value); const GLint int_val = g_value_get_int (&uniform->value);
cogl_program_uniform_int (uniform->location, 1, 1, &int_val); cogl_program_set_uniform_int (priv->program, uniform->location,
1, 1,
&int_val);
} }
else else
g_warning ("Invalid uniform of type '%s' for name '%s'", g_warning ("Invalid uniform of type '%s' for name '%s'",
g_type_name (G_VALUE_TYPE (&uniform->value)), g_type_name (G_VALUE_TYPE (&uniform->value)),
uniform->name); uniform->name);
} }
cogl_program_use (COGL_INVALID_HANDLE);
} }
static void static void