clutter/offscreen-effect: Add new create_pipeline() vfunc
The most annoying aspect of ClutterOffscreenEffect right now, and the reason for all its subclasses to override pre-paint, is that the pipeline creation isn't under subclasses' control. That means all subclasses must ask ClutterOffscreenEffect to run pre-paint and create the pipeline, then they all create their own pipelines to paint. To reduce this complexity, add a new create_pipeline() vfunc to ClutterOffscreenEffect. Next commits will port effects to use this new vfunc. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1355>
This commit is contained in:
parent
6654053250
commit
5794871977
@ -158,6 +158,25 @@ ensure_pipeline_filter_for_scale (ClutterOffscreenEffect *self,
|
|||||||
filter, filter);
|
filter, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static CoglPipeline *
|
||||||
|
clutter_offscreen_effect_real_create_pipeline (ClutterOffscreenEffect *effect,
|
||||||
|
CoglTexture *texture)
|
||||||
|
{
|
||||||
|
ClutterOffscreenEffectPrivate *priv = effect->priv;
|
||||||
|
CoglContext *ctx =
|
||||||
|
clutter_backend_get_cogl_context (clutter_get_default_backend ());
|
||||||
|
CoglPipeline *pipeline;
|
||||||
|
float resource_scale;
|
||||||
|
|
||||||
|
resource_scale = clutter_actor_get_real_resource_scale (priv->actor);
|
||||||
|
|
||||||
|
pipeline = cogl_pipeline_new (ctx);
|
||||||
|
ensure_pipeline_filter_for_scale (effect, resource_scale);
|
||||||
|
cogl_pipeline_set_layer_texture (pipeline, 0, texture);
|
||||||
|
|
||||||
|
return pipeline;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
video_memory_purged (ClutterOffscreenEffect *self)
|
video_memory_purged (ClutterOffscreenEffect *self)
|
||||||
{
|
{
|
||||||
@ -171,6 +190,8 @@ update_fbo (ClutterEffect *effect,
|
|||||||
float resource_scale)
|
float resource_scale)
|
||||||
{
|
{
|
||||||
ClutterOffscreenEffect *self = CLUTTER_OFFSCREEN_EFFECT (effect);
|
ClutterOffscreenEffect *self = CLUTTER_OFFSCREEN_EFFECT (effect);
|
||||||
|
ClutterOffscreenEffectClass *offscreen_class =
|
||||||
|
CLUTTER_OFFSCREEN_EFFECT_GET_CLASS (self);
|
||||||
ClutterOffscreenEffectPrivate *priv = self->priv;
|
ClutterOffscreenEffectPrivate *priv = self->priv;
|
||||||
ClutterActor *stage_actor;
|
ClutterActor *stage_actor;
|
||||||
CoglOffscreen *offscreen;
|
CoglOffscreen *offscreen;
|
||||||
@ -211,15 +232,6 @@ update_fbo (ClutterEffect *effect,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->pipeline == NULL)
|
|
||||||
{
|
|
||||||
CoglContext *ctx =
|
|
||||||
clutter_backend_get_cogl_context (clutter_get_default_backend ());
|
|
||||||
|
|
||||||
priv->pipeline = cogl_pipeline_new (ctx);
|
|
||||||
ensure_pipeline_filter_for_scale (self, resource_scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_clear_pointer (&priv->texture, cogl_object_unref);
|
g_clear_pointer (&priv->texture, cogl_object_unref);
|
||||||
g_clear_object (&priv->offscreen);
|
g_clear_object (&priv->offscreen);
|
||||||
|
|
||||||
@ -228,8 +240,6 @@ update_fbo (ClutterEffect *effect,
|
|||||||
if (priv->texture == NULL)
|
if (priv->texture == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
cogl_pipeline_set_layer_texture (priv->pipeline, 0, priv->texture);
|
|
||||||
|
|
||||||
priv->target_width = target_width;
|
priv->target_width = target_width;
|
||||||
priv->target_height = target_height;
|
priv->target_height = target_height;
|
||||||
|
|
||||||
@ -250,6 +260,9 @@ update_fbo (ClutterEffect *effect,
|
|||||||
|
|
||||||
priv->offscreen = offscreen;
|
priv->offscreen = offscreen;
|
||||||
|
|
||||||
|
cogl_clear_object (&priv->pipeline);
|
||||||
|
priv->pipeline = offscreen_class->create_pipeline (self, priv->texture);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -527,6 +540,7 @@ clutter_offscreen_effect_class_init (ClutterOffscreenEffectClass *klass)
|
|||||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
klass->create_texture = clutter_offscreen_effect_real_create_texture;
|
klass->create_texture = clutter_offscreen_effect_real_create_texture;
|
||||||
|
klass->create_pipeline = clutter_offscreen_effect_real_create_pipeline;
|
||||||
klass->paint_target = clutter_offscreen_effect_real_paint_target;
|
klass->paint_target = clutter_offscreen_effect_real_paint_target;
|
||||||
|
|
||||||
meta_class->set_actor = clutter_offscreen_effect_set_actor;
|
meta_class->set_actor = clutter_offscreen_effect_set_actor;
|
||||||
|
@ -79,6 +79,8 @@ struct _ClutterOffscreenEffectClass
|
|||||||
CoglHandle (* create_texture) (ClutterOffscreenEffect *effect,
|
CoglHandle (* create_texture) (ClutterOffscreenEffect *effect,
|
||||||
gfloat width,
|
gfloat width,
|
||||||
gfloat height);
|
gfloat height);
|
||||||
|
CoglPipeline* (* create_pipeline) (ClutterOffscreenEffect *effect,
|
||||||
|
CoglTexture *texture);
|
||||||
void (* paint_target) (ClutterOffscreenEffect *effect,
|
void (* paint_target) (ClutterOffscreenEffect *effect,
|
||||||
ClutterPaintContext *paint_context);
|
ClutterPaintContext *paint_context);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user