Compare commits

...

6 Commits

Author SHA1 Message Date
Georges Basile Stavracas Neto
16b14059b6 shell: Adapt to ClutterEffect vfunc changes
Add the new ClutterPaintNode argument to the vfuncs. No other
change is needed.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1350
2020-07-06 10:44:44 -03:00
Georges Basile Stavracas Neto
e8fc6a8919 st/scroll-view-fade: Adapt to paint_target() API changes
It now receives a ClutterPaintNode to paint on. Fortunately,
StScrollViewFade doesn't do any drawing itself, so no changes
are needed.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1350
2020-07-06 10:44:42 -03:00
Georges Basile Stavracas Neto
fc9abaf076 invert-lightness-effect: Switch to create_pipeline vfunc
Pretty much the exact same changes of the previous commit, applied
to the ShellInvertLightnessEffect subclass.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1350
2020-07-06 10:44:40 -03:00
Georges Basile Stavracas Neto
9f74040a89 glsl-effect: Switch to create_pipeline vfunc
This new ClutterOffscreenEffect vastly simplyfies subclasses
by allowing them to hand the parent class a CoglPipeline to
use.

Override the create_pipeline() vfunc and return the (cached)
pipeline. Remove the paint_target() override and the now
unnecessary texture size fields from the structure.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1350
2020-07-06 10:43:29 -03:00
Georges Basile Stavracas Neto
8b88c7724d lookingGlass: Port to paint nodes
Override vfunc_paint_node(), and add paint nodes to the
root node instead of directly calling CoglFramebuffer APIs.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1339
2020-07-06 10:41:15 -03:00
Georges Basile Stavracas Neto
71aae8366d blur-effect: Port to paint nodes
Port the blur effect to the new ClutterEffect.paint_node() vfunc.
Update the function names to match what they do, e.g. "apply_blur()"
now creates the blur subtree and thus was appropriately renamed to
"create_blur_nodes()".

There are 3 subtrees that can be generated by the blur effect:

 1. Actor mode (full subtree; no cache)

      Root
       |----------------------------
       |                            |
    Layer (brightness)           Pipeline
       |                      (final result)
    Layer (horizontal blur)
       |
    Layer (vertical blur)
       |
    Layer (actor)
       |
    Transform (downscale)
       |
     Actor

 2. Actor mode (partial subtree; cached contents)

      Root
       |
     Pipeline
  (final result)

 3. Background mode

      Root
       |-------------------------------------------
       |                            |              |
    Layer (brightness)           Pipeline        Actor
       |                      (final result)
    Layer (horizontal blur)
       |
    Layer (vertical blur)
       |
    Layer (background)
       |
      Blit

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1339
2020-07-06 10:41:15 -03:00
5 changed files with 179 additions and 206 deletions

View File

@ -482,13 +482,16 @@ class RedBorderEffect extends Clutter.Effect {
this._pipeline = null; this._pipeline = null;
} }
vfunc_paint(paintContext) { vfunc_paint_node(node, paintContext) {
let framebuffer = paintContext.get_framebuffer();
let coglContext = framebuffer.get_context();
let actor = this.get_actor(); let actor = this.get_actor();
actor.continue_paint(paintContext);
const actorNode = new Clutter.ActorNode(actor);
node.add_child(actorNode);
if (!this._pipeline) { if (!this._pipeline) {
const framebuffer = paintContext.get_framebuffer();
const coglContext = framebuffer.get_context();
let color = new Cogl.Color(); let color = new Cogl.Color();
color.init_from_4ub(0xff, 0, 0, 0xc4); color.init_from_4ub(0xff, 0, 0, 0xc4);
@ -499,18 +502,28 @@ class RedBorderEffect extends Clutter.Effect {
let alloc = actor.get_allocation_box(); let alloc = actor.get_allocation_box();
let width = 2; let width = 2;
const pipelineNode = new Clutter.PipelineNode(this._pipeline);
pipelineNode.set_name('Red Border');
actorNode.add_child(pipelineNode);
const box = new Clutter.ActorBox();
// clockwise order // clockwise order
framebuffer.draw_rectangle(this._pipeline, box.set_origin(0, 0);
0, 0, alloc.get_width(), width); box.set_size(alloc.get_width(), width);
framebuffer.draw_rectangle(this._pipeline, pipelineNode.add_rectangle(box);
alloc.get_width() - width, width,
alloc.get_width(), alloc.get_height()); box.set_origin(alloc.get_width() - width, width);
framebuffer.draw_rectangle(this._pipeline, box.set_size(width, alloc.get_height());
0, alloc.get_height(), pipelineNode.add_rectangle(box);
alloc.get_width() - width, alloc.get_height() - width);
framebuffer.draw_rectangle(this._pipeline, box.set_origin(0, alloc.get_height() - width);
0, alloc.get_height() - width, box.set_size(alloc.get_width() - width, width);
width, width); pipelineNode.add_rectangle(box);
box.set_origin(0, width);
box.set_size(width, alloc.get_height() - width);
pipelineNode.add_rectangle(box);
} }
}); });

View File

@ -163,7 +163,6 @@ struct _ShellBlurEffect
ClutterEffect parent_instance; ClutterEffect parent_instance;
ClutterActor *actor; ClutterActor *actor;
int old_opacity_override;
BlurData blur[2]; BlurData blur[2];
@ -486,21 +485,6 @@ calculate_downscale_factor (float width,
return downscale_factor; return downscale_factor;
} }
static void
clear_framebuffer (CoglFramebuffer *framebuffer)
{
static CoglColor transparent;
static gboolean initialized = FALSE;
if (!initialized)
{
cogl_color_init_from_4ub (&transparent, 0, 0, 0, 0);
initialized = TRUE;
}
cogl_framebuffer_clear (framebuffer, COGL_BUFFER_BIT_COLOR, &transparent);
}
static void static void
shell_blur_effect_set_actor (ClutterActorMeta *meta, shell_blur_effect_set_actor (ClutterActorMeta *meta,
ClutterActor *actor) ClutterActor *actor)
@ -561,47 +545,45 @@ update_actor_box (ShellBlurEffect *self,
} }
static void static void
paint_texture (ShellBlurEffect *self, add_blurred_pipeline (ShellBlurEffect *self,
ClutterPaintContext *paint_context) ClutterPaintNode *node)
{ {
CoglFramebuffer *framebuffer; g_autoptr (ClutterPaintNode) pipeline_node = NULL;
float width, height; float width, height;
framebuffer = clutter_paint_context_get_framebuffer (paint_context);
/* Use the untransformed actor size here, since the framebuffer itself already /* Use the untransformed actor size here, since the framebuffer itself already
* has the actor transform matrix applied. * has the actor transform matrix applied.
*/ */
clutter_actor_get_size (self->actor, &width, &height); clutter_actor_get_size (self->actor, &width, &height);
update_brightness_uniform (self); update_brightness_uniform (self);
cogl_framebuffer_draw_rectangle (framebuffer,
self->brightness_fb.pipeline, pipeline_node = clutter_pipeline_node_new (self->brightness_fb.pipeline);
0, 0, clutter_paint_node_set_static_name (pipeline_node, "ShellBlurEffect (final)");
clutter_paint_node_add_child (node, pipeline_node);
clutter_paint_node_add_rectangle (pipeline_node,
&(ClutterActorBox) {
0.f, 0.f,
width, width,
height); height,
});
} }
static void static ClutterPaintNode *
apply_blur (ShellBlurEffect *self, create_blur_nodes (ShellBlurEffect *self,
ClutterPaintContext *paint_context, ClutterPaintNode *node,
FramebufferData *from,
uint8_t paint_opacity) uint8_t paint_opacity)
{ {
g_autoptr (ClutterPaintNode) brightness_node = NULL;
g_autoptr (ClutterPaintNode) hblur_node = NULL;
g_autoptr (ClutterPaintNode) vblur_node = NULL;
BlurData *vblur; BlurData *vblur;
BlurData *hblur; BlurData *hblur;
vblur = &self->blur[VERTICAL]; vblur = &self->blur[VERTICAL];
hblur = &self->blur[HORIZONTAL]; hblur = &self->blur[HORIZONTAL];
/* Copy the actor contents into the vblur framebuffer */
clear_framebuffer (vblur->data.framebuffer);
cogl_framebuffer_draw_rectangle (vblur->data.framebuffer,
from->pipeline,
0, 0,
cogl_texture_get_width (vblur->data.texture),
cogl_texture_get_height (vblur->data.texture));
/* Pass 1: /* Pass 1:
* *
* Draw the actor contents (which is in the vblur framebuffer * Draw the actor contents (which is in the vblur framebuffer
@ -611,12 +593,16 @@ apply_blur (ShellBlurEffect *self,
*/ */
update_blur_uniforms (self, vblur); update_blur_uniforms (self, vblur);
clear_framebuffer (hblur->data.framebuffer); vblur_node = clutter_layer_node_new_with_framebuffer (vblur->data.framebuffer,
cogl_framebuffer_draw_rectangle (hblur->data.framebuffer,
vblur->data.pipeline, vblur->data.pipeline,
0, 0, paint_opacity);
clutter_paint_node_set_static_name (vblur_node, "ShellBlurEffect (vertical pass)");
clutter_paint_node_add_rectangle (vblur_node,
&(ClutterActorBox) {
0.f, 0.f,
cogl_texture_get_width (hblur->data.texture), cogl_texture_get_width (hblur->data.texture),
cogl_texture_get_height (hblur->data.texture)); cogl_texture_get_height (hblur->data.texture)
});
/* Pass 2: /* Pass 2:
* *
@ -624,30 +610,44 @@ apply_blur (ShellBlurEffect *self,
* horizontal blur pipeline into the brightness framebuffer. * horizontal blur pipeline into the brightness framebuffer.
*/ */
update_blur_uniforms (self, hblur); update_blur_uniforms (self, hblur);
cogl_pipeline_set_color4ub (hblur->data.pipeline,
paint_opacity,
paint_opacity,
paint_opacity,
paint_opacity);
clear_framebuffer (self->brightness_fb.framebuffer); hblur_node = clutter_layer_node_new_with_framebuffer (hblur->data.framebuffer,
cogl_framebuffer_draw_rectangle (self->brightness_fb.framebuffer,
hblur->data.pipeline, hblur->data.pipeline,
0, 0, 255);
clutter_paint_node_set_static_name (hblur_node, "ShellBlurEffect (horizontal pass)");
clutter_paint_node_add_rectangle (hblur_node,
&(ClutterActorBox) {
0.f, 0.f,
cogl_texture_get_width (self->brightness_fb.texture), cogl_texture_get_width (self->brightness_fb.texture),
cogl_texture_get_height (self->brightness_fb.texture)); cogl_texture_get_height (self->brightness_fb.texture),
});
update_brightness_uniform (self);
brightness_node = clutter_layer_node_new_with_framebuffer (self->brightness_fb.framebuffer,
self->brightness_fb.pipeline,
255);
clutter_paint_node_set_static_name (brightness_node, "ShellBlurEffect (brightness)");
clutter_paint_node_add_child (hblur_node, vblur_node);
clutter_paint_node_add_child (brightness_node, hblur_node);
clutter_paint_node_add_child (node, brightness_node);
self->cache_flags |= BLUR_APPLIED; self->cache_flags |= BLUR_APPLIED;
return g_steal_pointer (&vblur_node);
} }
static gboolean static void
paint_background (ShellBlurEffect *self, paint_background (ShellBlurEffect *self,
ClutterPaintNode *node,
ClutterPaintContext *paint_context, ClutterPaintContext *paint_context,
ClutterActorBox *source_actor_box) ClutterActorBox *source_actor_box)
{ {
g_autoptr (GError) error = NULL; g_autoptr (ClutterPaintNode) background_node = NULL;
g_autoptr (ClutterPaintNode) blit_node = NULL;
CoglFramebuffer *framebuffer; CoglFramebuffer *framebuffer;
BlurData *vblur = &self->blur[VERTICAL];
float transformed_x; float transformed_x;
float transformed_y; float transformed_y;
float transformed_width; float transformed_width;
@ -662,23 +662,31 @@ paint_background (ShellBlurEffect *self,
&transformed_width, &transformed_width,
&transformed_height); &transformed_height);
clear_framebuffer (self->background_fb.framebuffer); /* Background layer node */
cogl_blit_framebuffer (framebuffer, background_node =
self->background_fb.framebuffer, clutter_layer_node_new_with_framebuffer (self->background_fb.framebuffer,
self->background_fb.pipeline,
255);
clutter_paint_node_set_static_name (background_node, "ShellBlurEffect (background)");
clutter_paint_node_add_child (node, background_node);
clutter_paint_node_add_rectangle (background_node,
&(ClutterActorBox) {
0.f, 0.f,
cogl_texture_get_width (vblur->data.texture),
cogl_texture_get_height (vblur->data.texture),
});
/* Blit node */
blit_node = clutter_blit_node_new (framebuffer,
self->background_fb.framebuffer);
clutter_paint_node_set_static_name (blit_node, "ShellBlurEffect (blit)");
clutter_paint_node_add_child (background_node, blit_node);
clutter_blit_node_add_blit_rectangle (CLUTTER_BLIT_NODE (blit_node),
transformed_x, transformed_x,
transformed_y, transformed_y,
0, 0, 0, 0,
transformed_width, transformed_width,
transformed_height, transformed_height);
&error);
if (error)
{
g_warning ("Error blitting overlay framebuffer: %s", error->message);
return FALSE;
}
return TRUE;
} }
static gboolean static gboolean
@ -711,11 +719,25 @@ update_framebuffers (ShellBlurEffect *self,
return updated; return updated;
} }
static void
add_actor_node (ShellBlurEffect *self,
ClutterPaintNode *node,
int opacity)
{
g_autoptr (ClutterPaintNode) actor_node = NULL;
actor_node = clutter_actor_node_new (self->actor, opacity);
clutter_paint_node_add_child (node, actor_node);
}
static void static void
paint_actor_offscreen (ShellBlurEffect *self, paint_actor_offscreen (ShellBlurEffect *self,
ClutterPaintContext *paint_context, ClutterPaintNode *node,
ClutterEffectPaintFlags flags) ClutterEffectPaintFlags flags)
{ {
g_autoptr (ClutterPaintNode) transform_node = NULL;
g_autoptr (ClutterPaintNode) layer_node = NULL;
CoglMatrix transform;
gboolean actor_dirty; gboolean actor_dirty;
actor_dirty = (flags & CLUTTER_EFFECT_PAINT_ACTOR_DIRTY) != 0; actor_dirty = (flags & CLUTTER_EFFECT_PAINT_ACTOR_DIRTY) != 0;
@ -724,27 +746,30 @@ paint_actor_offscreen (ShellBlurEffect *self,
if (!actor_dirty && (self->cache_flags & ACTOR_PAINTED)) if (!actor_dirty && (self->cache_flags & ACTOR_PAINTED))
return; return;
self->old_opacity_override = clutter_actor_get_opacity_override (self->actor); // Layer node
clutter_actor_set_opacity_override (self->actor, 0xff); layer_node = clutter_layer_node_new_with_framebuffer (self->actor_fb.framebuffer,
self->actor_fb.pipeline,
0xff);
clutter_paint_node_set_static_name (layer_node, "ShellBlurEffect (actor offscreen)");
clutter_paint_node_add_child (node, layer_node);
clutter_paint_node_add_rectangle (layer_node,
&(ClutterActorBox) {
0.f, 0.f,
cogl_texture_get_width (self->blur[VERTICAL].data.texture),
cogl_texture_get_height (self->blur[VERTICAL].data.texture),
});
/* Draw the actor contents into the actor offscreen framebuffer */ // Transform node
clear_framebuffer (self->actor_fb.framebuffer); cogl_matrix_init_identity (&transform);
cogl_matrix_scale (&transform,
cogl_framebuffer_push_matrix (self->actor_fb.framebuffer);
cogl_framebuffer_scale (self->actor_fb.framebuffer,
1.f / self->downscale_factor, 1.f / self->downscale_factor,
1.f / self->downscale_factor, 1.f / self->downscale_factor,
1.f); 1.f);
transform_node = clutter_transform_node_new (&transform);
clutter_paint_node_set_static_name (transform_node, "ShellBlurEffect (downscale)");
clutter_paint_node_add_child (layer_node, transform_node);
clutter_paint_context_push_framebuffer (paint_context, add_actor_node (self, transform_node, 255);
self->actor_fb.framebuffer);
clutter_actor_continue_paint (self->actor, paint_context);
cogl_framebuffer_pop_matrix (self->actor_fb.framebuffer);
clutter_paint_context_pop_framebuffer (paint_context);
clutter_actor_set_opacity_override (self->actor, self->old_opacity_override);
self->cache_flags |= ACTOR_PAINTED; self->cache_flags |= ACTOR_PAINTED;
} }
@ -775,6 +800,7 @@ needs_repaint (ShellBlurEffect *self,
static void static void
shell_blur_effect_paint (ClutterEffect *effect, shell_blur_effect_paint (ClutterEffect *effect,
ClutterPaintNode *node,
ClutterPaintContext *paint_context, ClutterPaintContext *paint_context,
ClutterEffectPaintFlags flags) ClutterEffectPaintFlags flags)
{ {
@ -785,6 +811,8 @@ shell_blur_effect_paint (ClutterEffect *effect,
if (self->sigma > 0) if (self->sigma > 0)
{ {
g_autoptr (ClutterPaintNode) blur_node = NULL;
if (needs_repaint (self, flags)) if (needs_repaint (self, flags))
{ {
ClutterActorBox source_actor_box; ClutterActorBox source_actor_box;
@ -802,20 +830,18 @@ shell_blur_effect_paint (ClutterEffect *effect,
case SHELL_BLUR_MODE_ACTOR: case SHELL_BLUR_MODE_ACTOR:
paint_opacity = clutter_actor_get_paint_opacity (self->actor); paint_opacity = clutter_actor_get_paint_opacity (self->actor);
paint_actor_offscreen (self, paint_context, flags); blur_node = create_blur_nodes (self, node, paint_opacity);
apply_blur (self, paint_context, &self->actor_fb, paint_opacity); paint_actor_offscreen (self, blur_node, flags);
break; break;
case SHELL_BLUR_MODE_BACKGROUND: case SHELL_BLUR_MODE_BACKGROUND:
if (!paint_background (self, paint_context, &source_actor_box)) blur_node = create_blur_nodes (self, node, 255);
goto fail; paint_background (self, blur_node, paint_context, &source_actor_box);
apply_blur (self, paint_context, &self->background_fb, 255);
break; break;
} }
} }
paint_texture (self, paint_context); add_blurred_pipeline (self, node);
/* Background blur needs to paint the actor after painting the blurred /* Background blur needs to paint the actor after painting the blurred
* background. * background.
@ -826,7 +852,7 @@ shell_blur_effect_paint (ClutterEffect *effect,
break; break;
case SHELL_BLUR_MODE_BACKGROUND: case SHELL_BLUR_MODE_BACKGROUND:
clutter_actor_continue_paint (self->actor, paint_context); add_actor_node (self, node, -1);
break; break;
} }
@ -837,7 +863,7 @@ fail:
/* When no blur is applied, or the offscreen framebuffers /* When no blur is applied, or the offscreen framebuffers
* couldn't be created, fallback to simply painting the actor. * couldn't be created, fallback to simply painting the actor.
*/ */
clutter_actor_continue_paint (self->actor, paint_context); add_actor_node (self, node, -1);
} }
static void static void
@ -927,7 +953,7 @@ shell_blur_effect_class_init (ShellBlurEffectClass *klass)
meta_class->set_actor = shell_blur_effect_set_actor; meta_class->set_actor = shell_blur_effect_set_actor;
effect_class->paint = shell_blur_effect_paint; effect_class->paint_node = shell_blur_effect_paint;
properties[PROP_SIGMA] = properties[PROP_SIGMA] =
g_param_spec_int ("sigma", g_param_spec_int ("sigma",

View File

@ -18,26 +18,16 @@ typedef struct _ShellGLSLEffectPrivate ShellGLSLEffectPrivate;
struct _ShellGLSLEffectPrivate struct _ShellGLSLEffectPrivate
{ {
CoglPipeline *pipeline; CoglPipeline *pipeline;
gint tex_width;
gint tex_height;
}; };
G_DEFINE_TYPE_WITH_PRIVATE (ShellGLSLEffect, shell_glsl_effect, CLUTTER_TYPE_OFFSCREEN_EFFECT); G_DEFINE_TYPE_WITH_PRIVATE (ShellGLSLEffect, shell_glsl_effect, CLUTTER_TYPE_OFFSCREEN_EFFECT);
static gboolean static gboolean
shell_glsl_effect_pre_paint (ClutterEffect *effect, shell_glsl_effect_pre_paint (ClutterEffect *effect,
ClutterPaintNode *node,
ClutterPaintContext *paint_context) ClutterPaintContext *paint_context)
{ {
ShellGLSLEffect *self = SHELL_GLSL_EFFECT (effect);
ClutterOffscreenEffect *offscreen_effect = CLUTTER_OFFSCREEN_EFFECT (effect);
ShellGLSLEffectPrivate *priv = shell_glsl_effect_get_instance_private (self);
ClutterEffectClass *parent_class; ClutterEffectClass *parent_class;
CoglHandle texture;
gboolean success;
if (!clutter_actor_meta_get_enabled (CLUTTER_ACTOR_META (effect)))
return FALSE;
if (!clutter_feature_available (CLUTTER_FEATURE_SHADERS_GLSL)) if (!clutter_feature_available (CLUTTER_FEATURE_SHADERS_GLSL))
{ {
@ -52,49 +42,21 @@ shell_glsl_effect_pre_paint (ClutterEffect *effect,
} }
parent_class = CLUTTER_EFFECT_CLASS (shell_glsl_effect_parent_class); parent_class = CLUTTER_EFFECT_CLASS (shell_glsl_effect_parent_class);
success = parent_class->pre_paint (effect, paint_context); return parent_class->pre_paint (effect, node, paint_context);
}
if (!success) static CoglPipeline *
return FALSE; shell_glsl_effect_create_pipeline (ClutterOffscreenEffect *effect,
CoglTexture *texture)
texture = clutter_offscreen_effect_get_texture (offscreen_effect); {
priv->tex_width = cogl_texture_get_width (texture); ShellGLSLEffect *self = SHELL_GLSL_EFFECT (effect);
priv->tex_height = cogl_texture_get_height (texture); ShellGLSLEffectPrivate *priv = shell_glsl_effect_get_instance_private (self);
cogl_pipeline_set_layer_texture (priv->pipeline, 0, texture); cogl_pipeline_set_layer_texture (priv->pipeline, 0, texture);
return TRUE; return cogl_object_ref (priv->pipeline);
} }
static void
shell_glsl_effect_paint_target (ClutterOffscreenEffect *effect,
ClutterPaintContext *paint_context)
{
ShellGLSLEffect *self = SHELL_GLSL_EFFECT (effect);
ShellGLSLEffectPrivate *priv;
ClutterActor *actor;
guint8 paint_opacity;
CoglFramebuffer *framebuffer;
priv = shell_glsl_effect_get_instance_private (self);
actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (effect));
paint_opacity = clutter_actor_get_paint_opacity (actor);
cogl_pipeline_set_color4ub (priv->pipeline,
paint_opacity,
paint_opacity,
paint_opacity,
paint_opacity);
framebuffer = clutter_paint_context_get_framebuffer (paint_context);
cogl_framebuffer_draw_rectangle (framebuffer,
priv->pipeline,
0, 0,
priv->tex_width, priv->tex_height);
}
/** /**
* shell_glsl_effect_add_glsl_snippet: * shell_glsl_effect_add_glsl_snippet:
* @effect: a #ShellGLSLEffect * @effect: a #ShellGLSLEffect
@ -199,7 +161,7 @@ shell_glsl_effect_class_init (ShellGLSLEffectClass *klass)
ClutterOffscreenEffectClass *offscreen_class; ClutterOffscreenEffectClass *offscreen_class;
offscreen_class = CLUTTER_OFFSCREEN_EFFECT_CLASS (klass); offscreen_class = CLUTTER_OFFSCREEN_EFFECT_CLASS (klass);
offscreen_class->paint_target = shell_glsl_effect_paint_target; offscreen_class->create_pipeline = shell_glsl_effect_create_pipeline;
effect_class->pre_paint = shell_glsl_effect_pre_paint; effect_class->pre_paint = shell_glsl_effect_pre_paint;

View File

@ -43,9 +43,6 @@ struct _ShellInvertLightnessEffect
{ {
ClutterOffscreenEffect parent_instance; ClutterOffscreenEffect parent_instance;
gint tex_width;
gint tex_height;
CoglPipeline *pipeline; CoglPipeline *pipeline;
}; };
@ -77,14 +74,12 @@ G_DEFINE_TYPE (ShellInvertLightnessEffect,
static gboolean static gboolean
shell_invert_lightness_effect_pre_paint (ClutterEffect *effect, shell_invert_lightness_effect_pre_paint (ClutterEffect *effect,
ClutterPaintNode *node,
ClutterPaintContext *paint_context) ClutterPaintContext *paint_context)
{ {
ShellInvertLightnessEffect *self = SHELL_INVERT_LIGHTNESS_EFFECT (effect); ShellInvertLightnessEffect *self = SHELL_INVERT_LIGHTNESS_EFFECT (effect);
ClutterEffectClass *parent_class; ClutterEffectClass *parent_class;
if (!clutter_actor_meta_get_enabled (CLUTTER_ACTOR_META (effect)))
return FALSE;
if (!clutter_feature_available (CLUTTER_FEATURE_SHADERS_GLSL)) if (!clutter_feature_available (CLUTTER_FEATURE_SHADERS_GLSL))
{ {
/* if we don't have support for GLSL shaders then we /* if we don't have support for GLSL shaders then we
@ -99,43 +94,19 @@ shell_invert_lightness_effect_pre_paint (ClutterEffect *effect,
parent_class = parent_class =
CLUTTER_EFFECT_CLASS (shell_invert_lightness_effect_parent_class); CLUTTER_EFFECT_CLASS (shell_invert_lightness_effect_parent_class);
if (parent_class->pre_paint (effect, paint_context))
{
ClutterOffscreenEffect *offscreen_effect =
CLUTTER_OFFSCREEN_EFFECT (effect);
CoglTexture *texture;
texture = clutter_offscreen_effect_get_texture (offscreen_effect); return parent_class->pre_paint (effect, node, paint_context);
self->tex_width = cogl_texture_get_width (texture); }
self->tex_height = cogl_texture_get_height (texture);
static CoglPipeline *
shell_glsl_effect_create_pipeline (ClutterOffscreenEffect *effect,
CoglTexture *texture)
{
ShellInvertLightnessEffect *self = SHELL_INVERT_LIGHTNESS_EFFECT (effect);
cogl_pipeline_set_layer_texture (self->pipeline, 0, texture); cogl_pipeline_set_layer_texture (self->pipeline, 0, texture);
return TRUE; return cogl_object_ref (self->pipeline);
}
else
return FALSE;
}
static void
shell_invert_lightness_effect_paint_target (ClutterOffscreenEffect *effect,
ClutterPaintContext *paint_context)
{
ShellInvertLightnessEffect *self = SHELL_INVERT_LIGHTNESS_EFFECT (effect);
ClutterActor *actor;
guint8 paint_opacity;
CoglFramebuffer *fb = clutter_paint_context_get_framebuffer (paint_context);
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 (fb, self->pipeline,
0, 0, self->tex_width, self->tex_height);
} }
static void static void
@ -160,7 +131,7 @@ shell_invert_lightness_effect_class_init (ShellInvertLightnessEffectClass *klass
ClutterOffscreenEffectClass *offscreen_class; ClutterOffscreenEffectClass *offscreen_class;
offscreen_class = CLUTTER_OFFSCREEN_EFFECT_CLASS (klass); offscreen_class = CLUTTER_OFFSCREEN_EFFECT_CLASS (klass);
offscreen_class->paint_target = shell_invert_lightness_effect_paint_target; offscreen_class->create_pipeline = shell_glsl_effect_create_pipeline;
effect_class->pre_paint = shell_invert_lightness_effect_pre_paint; effect_class->pre_paint = shell_invert_lightness_effect_pre_paint;

View File

@ -86,6 +86,7 @@ st_scroll_view_fade_get_static_shader_source (ClutterShaderEffect *effect)
static void static void
st_scroll_view_fade_paint_target (ClutterOffscreenEffect *effect, st_scroll_view_fade_paint_target (ClutterOffscreenEffect *effect,
ClutterPaintNode *node,
ClutterPaintContext *paint_context) ClutterPaintContext *paint_context)
{ {
StScrollViewFade *self = ST_SCROLL_VIEW_FADE (effect); StScrollViewFade *self = ST_SCROLL_VIEW_FADE (effect);
@ -154,7 +155,7 @@ st_scroll_view_fade_paint_target (ClutterOffscreenEffect *effect,
clutter_shader_effect_set_uniform (shader, "fade_area_bottomright", CLUTTER_TYPE_SHADER_FLOAT, 2, fade_area_bottomright); clutter_shader_effect_set_uniform (shader, "fade_area_bottomright", CLUTTER_TYPE_SHADER_FLOAT, 2, fade_area_bottomright);
parent = CLUTTER_OFFSCREEN_EFFECT_CLASS (st_scroll_view_fade_parent_class); parent = CLUTTER_OFFSCREEN_EFFECT_CLASS (st_scroll_view_fade_parent_class);
parent->paint_target (effect, paint_context); parent->paint_target (effect, node, paint_context);
} }
static void static void