Commit 6a7ecbeb authored by Daniel van Vugt's avatar Daniel van Vugt
Browse files

clutter/blur: Add a mask option

To specify which part of the blur we want to keep.
parent 5e8c808c
......@@ -18,6 +18,8 @@
#ifndef CLUTTER_BLUR_PRIVATE_H
#define CLUTTER_BLUR_PRIVATE_H
#include "clutter/clutter-enums.h"
#include <glib-object.h>
#include <cogl/cogl.h>
......@@ -29,6 +31,9 @@ typedef struct _ClutterBlur ClutterBlur;
ClutterBlur * clutter_blur_new (CoglTexture *texture,
float sigma);
void clutter_blur_mask (ClutterBlur *blur,
ClutterBlurMask mask);
void clutter_blur_apply (ClutterBlur *blur);
CoglTexture * clutter_blur_get_texture (ClutterBlur *blur);
......
......@@ -378,6 +378,34 @@ out:
return g_steal_pointer (&blur);
}
void
clutter_blur_mask (ClutterBlur *blur,
ClutterBlurMask mask)
{
BlurPass *final_pass = &blur->pass[1];
switch (mask)
{
case CLUTTER_BLUR_MASK_ALL:
cogl_pipeline_remove_layer (final_pass->pipeline, 1);
break;
case CLUTTER_BLUR_MASK_INSIDE:
cogl_pipeline_set_layer_texture (final_pass->pipeline, 1,
blur->source_texture);
cogl_pipeline_set_layer_combine (final_pass->pipeline, 1,
"RGBA = MODULATE (PREVIOUS, TEXTURE[A])",
NULL);
break;
case CLUTTER_BLUR_MASK_OUTSIDE:
cogl_pipeline_set_layer_texture (final_pass->pipeline, 1,
blur->source_texture);
cogl_pipeline_set_layer_combine (final_pass->pipeline, 1,
"RGBA = MODULATE (PREVIOUS, 1 - TEXTURE[A])",
NULL);
break;
}
}
/**
* clutter_blur_apply:
* @blur: a #ClutterBlur
......
......@@ -1638,6 +1638,21 @@ typedef enum
CLUTTER_INPUT_PANEL_STATE_TOGGLE,
} ClutterInputPanelState;
/**
* ClutterBlurMask:
* @CLUTTER_BLUR_MASK_ALL: Blur all pixels
* @CLUTTER_BLUR_MASK_INSIDE: Blur only pixels inside the silhouette
* @CLUTTER_BLUR_MASK_OUTSIDE: Blur only pixels outside the silhouette
*
* Specifies which part of a blurred image to keep.
*/
typedef enum
{
CLUTTER_BLUR_MASK_ALL = 0,
CLUTTER_BLUR_MASK_INSIDE,
CLUTTER_BLUR_MASK_OUTSIDE,
} ClutterBlurMask;
G_END_DECLS
#endif /* __CLUTTER_ENUMS_H__ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment