summaryrefslogtreecommitdiff
path: root/clutter
diff options
context:
space:
mode:
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>2020-07-05 15:12:57 -0300
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>2020-12-08 18:08:27 -0300
commit5d2c64c23a89d7a0ac6698892132413e86261d77 (patch)
tree4a6fe092be9eb788d3ca37a5c3dc432adddef4a7 /clutter
parent19053c2d78e8e49a704ccc51238456566f16b341 (diff)
downloadmutter-5d2c64c23a89d7a0ac6698892132413e86261d77.tar.gz
clutter/colorize-effect: Switch to create_pipeline vfunc
Diffstat (limited to 'clutter')
-rw-r--r--clutter/clutter/clutter-colorize-effect.c62
1 files changed, 13 insertions, 49 deletions
diff --git a/clutter/clutter/clutter-colorize-effect.c b/clutter/clutter/clutter-colorize-effect.c
index db372a9cb..8b8aba1d7 100644
--- a/clutter/clutter/clutter-colorize-effect.c
+++ b/clutter/clutter/clutter-colorize-effect.c
@@ -59,9 +59,6 @@ struct _ClutterColorizeEffect
gint tint_uniform;
- gint tex_width;
- gint tex_height;
-
CoglPipeline *pipeline;
};
@@ -104,16 +101,23 @@ G_DEFINE_TYPE (ClutterColorizeEffect,
clutter_colorize_effect,
CLUTTER_TYPE_OFFSCREEN_EFFECT);
+static CoglPipeline *
+clutter_colorize_effect_create_pipeline (ClutterOffscreenEffect *effect,
+ CoglTexture *texture)
+{
+ ClutterColorizeEffect *colorize_effect = CLUTTER_COLORIZE_EFFECT (effect);
+
+ cogl_pipeline_set_layer_texture (colorize_effect->pipeline, 0, texture);
+
+ return cogl_object_ref (colorize_effect->pipeline);
+}
+
static gboolean
clutter_colorize_effect_pre_paint (ClutterEffect *effect,
ClutterPaintContext *paint_context)
{
- ClutterColorizeEffect *self = CLUTTER_COLORIZE_EFFECT (effect);
ClutterEffectClass *parent_class;
- if (!clutter_actor_meta_get_enabled (CLUTTER_ACTOR_META (effect)))
- return FALSE;
-
if (!clutter_feature_available (CLUTTER_FEATURE_SHADERS_GLSL))
{
/* if we don't have support for GLSL shaders then we
@@ -127,47 +131,7 @@ clutter_colorize_effect_pre_paint (ClutterEffect *effect,
}
parent_class = CLUTTER_EFFECT_CLASS (clutter_colorize_effect_parent_class);
- if (parent_class->pre_paint (effect, paint_context))
- {
- ClutterOffscreenEffect *offscreen_effect =
- CLUTTER_OFFSCREEN_EFFECT (effect);
- CoglHandle texture;
-
- texture = clutter_offscreen_effect_get_texture (offscreen_effect);
- self->tex_width = cogl_texture_get_width (texture);
- self->tex_height = cogl_texture_get_height (texture);
-
- cogl_pipeline_set_layer_texture (self->pipeline, 0, texture);
-
- return TRUE;
- }
- else
- return FALSE;
-}
-
-static void
-clutter_colorize_effect_paint_target (ClutterOffscreenEffect *effect,
- ClutterPaintContext *paint_context)
-{
- ClutterColorizeEffect *self = CLUTTER_COLORIZE_EFFECT (effect);
- CoglFramebuffer *framebuffer =
- clutter_paint_context_get_framebuffer (paint_context);
- ClutterActor *actor;
- guint8 paint_opacity;
-
- actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (effect));
- paint_opacity = clutter_actor_get_paint_opacity (actor);
-
- cogl_pipeline_set_color4ub (self->pipeline,
- paint_opacity,
- paint_opacity,
- paint_opacity,
- paint_opacity);
-
- cogl_framebuffer_draw_rectangle (framebuffer,
- self->pipeline,
- 0, 0,
- self->tex_width, self->tex_height);
+ return parent_class->pre_paint (effect, paint_context);
}
static void
@@ -233,7 +197,7 @@ clutter_colorize_effect_class_init (ClutterColorizeEffectClass *klass)
ClutterOffscreenEffectClass *offscreen_class;
offscreen_class = CLUTTER_OFFSCREEN_EFFECT_CLASS (klass);
- offscreen_class->paint_target = clutter_colorize_effect_paint_target;
+ offscreen_class->create_pipeline = clutter_colorize_effect_create_pipeline;
effect_class->pre_paint = clutter_colorize_effect_pre_paint;