effects: Delay the creation of the base pipeline
Unconditionally creating CoglPipeline and CoglSnippets inside the class initialization functions does not seem to be enough when dealing with headless builds. Our last resort is to lazily create the base pipeline the first time we try to copy it, during the instance initialization.
This commit is contained in:
@ -227,7 +227,6 @@ 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;
|
||||
@ -252,22 +251,7 @@ clutter_colorize_effect_class_init (ClutterColorizeEffectClass *klass)
|
||||
&default_tint,
|
||||
CLUTTER_PARAM_READWRITE);
|
||||
|
||||
g_object_class_install_properties (gobject_class,
|
||||
PROP_LAST,
|
||||
obj_props);
|
||||
|
||||
|
||||
klass->base_pipeline = cogl_pipeline_new ();
|
||||
|
||||
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 */
|
||||
COGL_TEXTURE_TYPE_2D);
|
||||
g_object_class_install_properties (gobject_class, PROP_LAST, obj_props);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -292,10 +276,26 @@ update_tint_uniform (ClutterColorizeEffect *self)
|
||||
static void
|
||||
clutter_colorize_effect_init (ClutterColorizeEffect *self)
|
||||
{
|
||||
CoglPipeline *base_pipeline =
|
||||
CLUTTER_COLORIZE_EFFECT_GET_CLASS (self)->base_pipeline;
|
||||
ClutterColorizeEffectClass *klass = CLUTTER_COLORIZE_EFFECT_GET_CLASS (self);
|
||||
|
||||
self->pipeline = cogl_pipeline_copy (base_pipeline);
|
||||
if (G_UNLIKELY (klass->base_pipeline == NULL))
|
||||
{
|
||||
CoglSnippet *snippet;
|
||||
|
||||
klass->base_pipeline = cogl_pipeline_new ();
|
||||
|
||||
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 */
|
||||
COGL_TEXTURE_TYPE_2D);
|
||||
}
|
||||
|
||||
self->pipeline = cogl_pipeline_copy (klass->base_pipeline);
|
||||
|
||||
self->tint_uniform =
|
||||
cogl_pipeline_get_uniform_location (self->pipeline, "tint");
|
||||
|
Reference in New Issue
Block a user