From c1a57e537b07e0036cec491044d92b5becdbc4b8 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 14 Feb 2012 17:14:25 +0000 Subject: [PATCH] Do not check for features inside class initialization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- clutter/clutter-blur-effect.c | 19 +++++++------------ clutter/clutter-colorize-effect.c | 16 ++++++---------- clutter/clutter-desaturate-effect.c | 16 ++++++---------- 3 files changed, 19 insertions(+), 32 deletions(-) diff --git a/clutter/clutter-blur-effect.c b/clutter/clutter-blur-effect.c index a7a7c09f7..bed7360d4 100644 --- a/clutter/clutter-blur-effect.c +++ b/clutter/clutter-blur-effect.c @@ -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 */ diff --git a/clutter/clutter-colorize-effect.c b/clutter/clutter-colorize-effect.c index 2ccd068c3..82b1f47e9 100644 --- a/clutter/clutter-colorize-effect.c +++ b/clutter/clutter-colorize-effect.c @@ -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 */ diff --git a/clutter/clutter-desaturate-effect.c b/clutter/clutter-desaturate-effect.c index 9bdb70ae7..fc3c26346 100644 --- a/clutter/clutter-desaturate-effect.c +++ b/clutter/clutter-desaturate-effect.c @@ -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 */