[mutter/gbsneto/offscreen-paint-node: 2/11] clutter/offscreen-effect: Add new create_pipeline() vfunc
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/offscreen-paint-node: 2/11] clutter/offscreen-effect: Add new create_pipeline() vfunc
- Date: Tue, 8 Dec 2020 20:51:05 +0000 (UTC)
commit 4e5d4d8f98b7c97b1801d6b36f082b1656de9fc8
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sun Jul 5 13:41:19 2020 -0300
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 creating 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
vfunc when necessary.
clutter/clutter/clutter-offscreen-effect.c | 36 +++++++++++++++++++++---------
clutter/clutter/clutter-offscreen-effect.h | 2 ++
2 files changed, 27 insertions(+), 11 deletions(-)
---
diff --git a/clutter/clutter/clutter-offscreen-effect.c b/clutter/clutter/clutter-offscreen-effect.c
index cfb0ddc955..020115d1b5 100644
--- a/clutter/clutter/clutter-offscreen-effect.c
+++ b/clutter/clutter/clutter-offscreen-effect.c
@@ -158,6 +158,25 @@ ensure_pipeline_filter_for_scale (ClutterOffscreenEffect *self,
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
video_memory_purged (ClutterOffscreenEffect *self)
{
@@ -171,6 +190,8 @@ update_fbo (ClutterEffect *effect,
float resource_scale)
{
ClutterOffscreenEffect *self = CLUTTER_OFFSCREEN_EFFECT (effect);
+ ClutterOffscreenEffectClass *offscreen_class =
+ CLUTTER_OFFSCREEN_EFFECT_GET_CLASS (self);
ClutterOffscreenEffectPrivate *priv = self->priv;
ClutterActor *stage_actor;
CoglOffscreen *offscreen;
@@ -211,15 +232,6 @@ update_fbo (ClutterEffect *effect,
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_object (&priv->offscreen);
@@ -228,8 +240,6 @@ update_fbo (ClutterEffect *effect,
if (priv->texture == NULL)
return FALSE;
- cogl_pipeline_set_layer_texture (priv->pipeline, 0, priv->texture);
-
priv->target_width = target_width;
priv->target_height = target_height;
@@ -250,6 +260,9 @@ update_fbo (ClutterEffect *effect,
priv->offscreen = offscreen;
+ cogl_clear_object (&priv->pipeline);
+ priv->pipeline = offscreen_class->create_pipeline (self, priv->texture);
+
return TRUE;
}
@@ -528,6 +541,7 @@ clutter_offscreen_effect_class_init (ClutterOffscreenEffectClass *klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
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;
meta_class->set_actor = clutter_offscreen_effect_set_actor;
diff --git a/clutter/clutter/clutter-offscreen-effect.h b/clutter/clutter/clutter-offscreen-effect.h
index 77cbb66135..51382f43b2 100644
--- a/clutter/clutter/clutter-offscreen-effect.h
+++ b/clutter/clutter/clutter-offscreen-effect.h
@@ -79,6 +79,8 @@ struct _ClutterOffscreenEffectClass
CoglHandle (* create_texture) (ClutterOffscreenEffect *effect,
gfloat width,
gfloat height);
+ CoglPipeline* (* create_pipeline) (ClutterOffscreenEffect *effect,
+ CoglTexture *texture);
void (* paint_target) (ClutterOffscreenEffect *effect,
ClutterPaintContext *paint_context);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]