Do not check for features inside class initialization

The class initialization function may be called when Clutter hasn't been
fully initialized — for instance, when scanning the source with gtk-doc
or with the introspection scanner.
This commit is contained in:
Emmanuele Bassi 2012-02-14 17:14:25 +00:00
parent 553f446315
commit c1a57e537b
3 changed files with 19 additions and 32 deletions

View File

@ -221,6 +221,7 @@ clutter_blur_effect_class_init (ClutterBlurEffectClass *klass)
ClutterEffectClass *effect_class = CLUTTER_EFFECT_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
ClutterOffscreenEffectClass *offscreen_class;
CoglSnippet *snippet;
gobject_class->dispose = clutter_blur_effect_dispose;
@ -232,18 +233,12 @@ clutter_blur_effect_class_init (ClutterBlurEffectClass *klass)
klass->base_pipeline = cogl_pipeline_new ();
if (clutter_feature_available (CLUTTER_FEATURE_SHADERS_GLSL))
{
CoglSnippet *snippet;
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_TEXTURE_LOOKUP,
box_blur_glsl_declarations,
NULL);
cogl_snippet_set_replace (snippet,
box_blur_glsl_shader);
cogl_pipeline_add_layer_snippet (klass->base_pipeline, 0, snippet);
cogl_object_unref (snippet);
}
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_TEXTURE_LOOKUP,
box_blur_glsl_declarations,
NULL);
cogl_snippet_set_replace (snippet, box_blur_glsl_shader);
cogl_pipeline_add_layer_snippet (klass->base_pipeline, 0, snippet);
cogl_object_unref (snippet);
cogl_pipeline_set_layer_null_texture (klass->base_pipeline,
0, /* layer number */

View File

@ -227,6 +227,7 @@ clutter_colorize_effect_class_init (ClutterColorizeEffectClass *klass)
ClutterEffectClass *effect_class = CLUTTER_EFFECT_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
ClutterOffscreenEffectClass *offscreen_class;
CoglSnippet *snippet;
offscreen_class = CLUTTER_OFFSCREEN_EFFECT_CLASS (klass);
offscreen_class->paint_target = clutter_colorize_effect_paint_target;
@ -258,16 +259,11 @@ clutter_colorize_effect_class_init (ClutterColorizeEffectClass *klass)
klass->base_pipeline = cogl_pipeline_new ();
if (clutter_feature_available (CLUTTER_FEATURE_SHADERS_GLSL))
{
CoglSnippet *snippet;
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT,
colorize_glsl_declarations,
colorize_glsl_source);
cogl_pipeline_add_snippet (klass->base_pipeline, snippet);
cogl_object_unref (snippet);
}
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT,
colorize_glsl_declarations,
colorize_glsl_source);
cogl_pipeline_add_snippet (klass->base_pipeline, snippet);
cogl_object_unref (snippet);
cogl_pipeline_set_layer_null_texture (klass->base_pipeline,
0, /* layer number */

View File

@ -249,6 +249,7 @@ clutter_desaturate_effect_class_init (ClutterDesaturateEffectClass *klass)
ClutterEffectClass *effect_class = CLUTTER_EFFECT_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
ClutterOffscreenEffectClass *offscreen_class;
CoglSnippet *snippet;
offscreen_class = CLUTTER_OFFSCREEN_EFFECT_CLASS (klass);
offscreen_class->paint_target = clutter_desaturate_effect_paint_target;
@ -281,16 +282,11 @@ clutter_desaturate_effect_class_init (ClutterDesaturateEffectClass *klass)
klass->base_pipeline = cogl_pipeline_new ();
if (clutter_feature_available (CLUTTER_FEATURE_SHADERS_GLSL))
{
CoglSnippet *snippet;
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT,
desaturate_glsl_declarations,
desaturate_glsl_source);
cogl_pipeline_add_snippet (klass->base_pipeline, snippet);
cogl_object_unref (snippet);
}
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT,
desaturate_glsl_declarations,
desaturate_glsl_source);
cogl_pipeline_add_snippet (klass->base_pipeline, snippet);
cogl_object_unref (snippet);
cogl_pipeline_set_layer_null_texture (klass->base_pipeline,
0, /* layer number */