mirror of
https://github.com/brl/mutter.git
synced 2025-02-18 06:04:10 +00:00
background: drop saturation and blur effects
We don't use them anymore, so drop them. https://bugzilla.gnome.org/show_bug.cgi?id=696157
This commit is contained in:
parent
13c7020b80
commit
0e58906194
@ -39,41 +39,6 @@
|
|||||||
#include <meta/meta-background.h>
|
#include <meta/meta-background.h>
|
||||||
#include "meta-background-actor-private.h"
|
#include "meta-background-actor-private.h"
|
||||||
|
|
||||||
#define TEXTURE_LOOKUP_SHADER_DECLARATIONS \
|
|
||||||
"uniform vec2 pixel_step;\n" \
|
|
||||||
"vec4 apply_blur(in sampler2D texture, in vec2 coordinates) {\n" \
|
|
||||||
" vec4 texel;\n" \
|
|
||||||
" texel = texture2D(texture, coordinates.st);\n" \
|
|
||||||
" texel += texture2D(texture, coordinates.st + pixel_step * vec2(-1.0, -1.0));\n"\
|
|
||||||
" texel += texture2D(texture, coordinates.st + pixel_step * vec2( 0.0, -1.0));\n"\
|
|
||||||
" texel += texture2D(texture, coordinates.st + pixel_step * vec2(+1.0, -1.0));\n"\
|
|
||||||
" texel += texture2D(texture, coordinates.st + pixel_step * vec2(-1.0, 0.0));\n"\
|
|
||||||
" texel += texture2D(texture, coordinates.st + pixel_step * vec2(+1.0, 0.0));\n"\
|
|
||||||
" texel += texture2D(texture, coordinates.st + pixel_step * vec2(-1.0, +1.0));\n"\
|
|
||||||
" texel += texture2D(texture, coordinates.st + pixel_step * vec2( 0.0, +1.0));\n"\
|
|
||||||
" texel += texture2D(texture, coordinates.st + pixel_step * vec2(+1.0, +1.0));\n"\
|
|
||||||
" texel /= 9.0;\n" \
|
|
||||||
" return texel;\n" \
|
|
||||||
"}\n" \
|
|
||||||
"uniform float saturation;\n" \
|
|
||||||
"vec3 desaturate(const vec3 color)\n" \
|
|
||||||
"{\n" \
|
|
||||||
" const vec3 gray_conv = vec3(0.299, 0.587, 0.114);\n" \
|
|
||||||
" vec3 gray = vec3(dot(gray_conv, color));\n" \
|
|
||||||
" return vec3(mix(color.rgb, gray, 1.0 - saturation));\n" \
|
|
||||||
"}\n" \
|
|
||||||
|
|
||||||
/* Used when we don't have a blur, as the texel is going to be junk
|
|
||||||
* unless we set something to it. */
|
|
||||||
#define DESATURATE_PRELUDE \
|
|
||||||
"cogl_texel = texture2D(cogl_sampler, cogl_tex_coord.st);\n"
|
|
||||||
|
|
||||||
#define DESATURATE_CODE \
|
|
||||||
"cogl_texel.rgb = desaturate(cogl_texel.rgb);\n"
|
|
||||||
|
|
||||||
#define BLUR_CODE \
|
|
||||||
"cogl_texel = apply_blur(cogl_sampler, cogl_tex_coord.st);\n"
|
|
||||||
|
|
||||||
#define FRAGMENT_SHADER_DECLARATIONS \
|
#define FRAGMENT_SHADER_DECLARATIONS \
|
||||||
"uniform vec2 texture_scale;\n" \
|
"uniform vec2 texture_scale;\n" \
|
||||||
"uniform vec2 actor_size;\n" \
|
"uniform vec2 actor_size;\n" \
|
||||||
@ -116,7 +81,6 @@ struct _MetaBackgroundPrivate
|
|||||||
|
|
||||||
float brightness;
|
float brightness;
|
||||||
float vignette_sharpness;
|
float vignette_sharpness;
|
||||||
float saturation;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -126,7 +90,6 @@ enum
|
|||||||
PROP_EFFECTS,
|
PROP_EFFECTS,
|
||||||
PROP_BRIGHTNESS,
|
PROP_BRIGHTNESS,
|
||||||
PROP_VIGNETTE_SHARPNESS,
|
PROP_VIGNETTE_SHARPNESS,
|
||||||
PROP_SATURATION
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void clutter_content_iface_init (ClutterContentIface *iface);
|
static void clutter_content_iface_init (ClutterContentIface *iface);
|
||||||
@ -367,25 +330,6 @@ clip_region_to_actor_box (cairo_region_t *region,
|
|||||||
cairo_region_intersect_rectangle (region, &clip_rect);
|
cairo_region_intersect_rectangle (region, &clip_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
set_blur_parameters (MetaBackground *self,
|
|
||||||
ClutterActorBox *actor_box)
|
|
||||||
{
|
|
||||||
MetaBackgroundPrivate *priv = self->priv;
|
|
||||||
float pixel_step[2];
|
|
||||||
|
|
||||||
if (!(priv->effects & META_BACKGROUND_EFFECTS_BLUR))
|
|
||||||
return;
|
|
||||||
|
|
||||||
pixel_step[0] = 1.0 / (actor_box->x2 - actor_box->x1);
|
|
||||||
pixel_step[1] = 1.0 / (actor_box->y2 - actor_box->y1);
|
|
||||||
|
|
||||||
cogl_pipeline_set_uniform_float (priv->pipeline,
|
|
||||||
cogl_pipeline_get_uniform_location (priv->pipeline,
|
|
||||||
"pixel_step"),
|
|
||||||
2, 1, pixel_step);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_vignette_parameters (MetaBackground *self,
|
set_vignette_parameters (MetaBackground *self,
|
||||||
ClutterActorBox *actor_box,
|
ClutterActorBox *actor_box,
|
||||||
@ -447,8 +391,6 @@ meta_background_paint_content (ClutterContent *content,
|
|||||||
|
|
||||||
clutter_actor_get_content_box (actor, &actor_box);
|
clutter_actor_get_content_box (actor, &actor_box);
|
||||||
|
|
||||||
set_blur_parameters (self, &actor_box);
|
|
||||||
|
|
||||||
/* First figure out where on the monitor the texture is supposed to be painted.
|
/* First figure out where on the monitor the texture is supposed to be painted.
|
||||||
* If the actor is not the size of the monitor, this function makes sure to scale
|
* If the actor is not the size of the monitor, this function makes sure to scale
|
||||||
* everything down to fit in the actor.
|
* everything down to fit in the actor.
|
||||||
@ -589,63 +531,6 @@ set_vignette_sharpness (MetaBackground *self,
|
|||||||
g_object_notify (G_OBJECT (self), "vignette-sharpness");
|
g_object_notify (G_OBJECT (self), "vignette-sharpness");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
set_saturation (MetaBackground *self,
|
|
||||||
gfloat saturation)
|
|
||||||
{
|
|
||||||
MetaBackgroundPrivate *priv = self->priv;
|
|
||||||
|
|
||||||
if (priv->saturation == saturation)
|
|
||||||
return;
|
|
||||||
|
|
||||||
priv->saturation = saturation;
|
|
||||||
|
|
||||||
ensure_pipeline (self);
|
|
||||||
|
|
||||||
cogl_pipeline_set_uniform_1f (priv->pipeline,
|
|
||||||
cogl_pipeline_get_uniform_location (priv->pipeline,
|
|
||||||
"saturation"),
|
|
||||||
priv->saturation);
|
|
||||||
|
|
||||||
|
|
||||||
clutter_content_invalidate (CLUTTER_CONTENT (self));
|
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (self), "saturation");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
add_texture_lookup_shader (MetaBackground *self)
|
|
||||||
{
|
|
||||||
MetaBackgroundPrivate *priv = self->priv;
|
|
||||||
CoglSnippet *snippet;
|
|
||||||
const char *code = NULL;
|
|
||||||
|
|
||||||
if ((priv->effects & META_BACKGROUND_EFFECTS_BLUR) &&
|
|
||||||
(priv->effects & META_BACKGROUND_EFFECTS_DESATURATE))
|
|
||||||
code = BLUR_CODE "\n" DESATURATE_CODE;
|
|
||||||
else if (priv->effects & META_BACKGROUND_EFFECTS_BLUR)
|
|
||||||
code = BLUR_CODE;
|
|
||||||
else if (priv->effects & META_BACKGROUND_EFFECTS_DESATURATE)
|
|
||||||
code = DESATURATE_PRELUDE "\n" DESATURATE_CODE;
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
|
|
||||||
ensure_pipeline (self);
|
|
||||||
|
|
||||||
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_TEXTURE_LOOKUP,
|
|
||||||
TEXTURE_LOOKUP_SHADER_DECLARATIONS,
|
|
||||||
NULL);
|
|
||||||
cogl_snippet_set_replace (snippet, code);
|
|
||||||
cogl_pipeline_add_layer_snippet (priv->pipeline, 0, snippet);
|
|
||||||
cogl_object_unref (snippet);
|
|
||||||
|
|
||||||
if (priv->effects & META_BACKGROUND_EFFECTS_DESATURATE)
|
|
||||||
cogl_pipeline_set_uniform_1f (priv->pipeline,
|
|
||||||
cogl_pipeline_get_uniform_location (priv->pipeline,
|
|
||||||
"saturation"),
|
|
||||||
priv->saturation);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_vignette (MetaBackground *self)
|
add_vignette (MetaBackground *self)
|
||||||
{
|
{
|
||||||
@ -677,10 +562,6 @@ set_effects (MetaBackground *self,
|
|||||||
|
|
||||||
priv->effects = effects;
|
priv->effects = effects;
|
||||||
|
|
||||||
if ((priv->effects & META_BACKGROUND_EFFECTS_BLUR) ||
|
|
||||||
(priv->effects & META_BACKGROUND_EFFECTS_DESATURATE))
|
|
||||||
add_texture_lookup_shader (self);
|
|
||||||
|
|
||||||
if ((priv->effects & META_BACKGROUND_EFFECTS_VIGNETTE))
|
if ((priv->effects & META_BACKGROUND_EFFECTS_VIGNETTE))
|
||||||
add_vignette (self);
|
add_vignette (self);
|
||||||
|
|
||||||
@ -713,9 +594,6 @@ meta_background_set_property (GObject *object,
|
|||||||
case PROP_VIGNETTE_SHARPNESS:
|
case PROP_VIGNETTE_SHARPNESS:
|
||||||
set_vignette_sharpness (self, g_value_get_float (value));
|
set_vignette_sharpness (self, g_value_get_float (value));
|
||||||
break;
|
break;
|
||||||
case PROP_SATURATION:
|
|
||||||
set_saturation (self, g_value_get_float (value));
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -747,9 +625,6 @@ meta_background_get_property (GObject *object,
|
|||||||
case PROP_VIGNETTE_SHARPNESS:
|
case PROP_VIGNETTE_SHARPNESS:
|
||||||
g_value_set_float (value, priv->vignette_sharpness);
|
g_value_set_float (value, priv->vignette_sharpness);
|
||||||
break;
|
break;
|
||||||
case PROP_SATURATION:
|
|
||||||
g_value_set_float (value, priv->saturation);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -804,17 +679,9 @@ meta_background_class_init (MetaBackgroundClass *klass)
|
|||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
|
||||||
g_object_class_install_property (object_class, PROP_VIGNETTE_SHARPNESS, param_spec);
|
g_object_class_install_property (object_class, PROP_VIGNETTE_SHARPNESS, param_spec);
|
||||||
|
|
||||||
param_spec = g_param_spec_float ("saturation",
|
|
||||||
"saturation",
|
|
||||||
"Values less than 1.0 grays background",
|
|
||||||
0.0, 1.0,
|
|
||||||
1.0,
|
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
|
|
||||||
g_object_class_install_property (object_class, PROP_SATURATION, param_spec);
|
|
||||||
|
|
||||||
param_spec = g_param_spec_flags ("effects",
|
param_spec = g_param_spec_flags ("effects",
|
||||||
"Effects",
|
"Effects",
|
||||||
"Set to alter saturation, to blur, etc",
|
"Set to enable vignette",
|
||||||
meta_background_effects_get_type (),
|
meta_background_effects_get_type (),
|
||||||
META_BACKGROUND_EFFECTS_NONE,
|
META_BACKGROUND_EFFECTS_NONE,
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||||
@ -1256,15 +1123,11 @@ meta_background_copy (MetaBackground *self,
|
|||||||
background->priv->pipeline = cogl_pipeline_copy (self->priv->pipeline);
|
background->priv->pipeline = cogl_pipeline_copy (self->priv->pipeline);
|
||||||
background->priv->texture = cogl_object_ref (self->priv->texture);
|
background->priv->texture = cogl_object_ref (self->priv->texture);
|
||||||
background->priv->style = self->priv->style;
|
background->priv->style = self->priv->style;
|
||||||
background->priv->saturation = self->priv->saturation;
|
|
||||||
|
|
||||||
if (effects != self->priv->effects)
|
if (effects != self->priv->effects)
|
||||||
{
|
{
|
||||||
set_effects (background, effects);
|
set_effects (background, effects);
|
||||||
|
|
||||||
if (effects & META_BACKGROUND_EFFECTS_DESATURATE)
|
|
||||||
set_saturation (background, self->priv->saturation);
|
|
||||||
|
|
||||||
if (effects & META_BACKGROUND_EFFECTS_VIGNETTE)
|
if (effects & META_BACKGROUND_EFFECTS_VIGNETTE)
|
||||||
{
|
{
|
||||||
set_brightness (background, self->priv->brightness);
|
set_brightness (background, self->priv->brightness);
|
||||||
@ -1285,9 +1148,6 @@ meta_background_copy (MetaBackground *self,
|
|||||||
set_style (background, self->priv->style);
|
set_style (background, self->priv->style);
|
||||||
set_effects (background, effects);
|
set_effects (background, effects);
|
||||||
|
|
||||||
if (effects & META_BACKGROUND_EFFECTS_DESATURATE)
|
|
||||||
set_saturation (background, self->priv->saturation);
|
|
||||||
|
|
||||||
if (effects & META_BACKGROUND_EFFECTS_VIGNETTE)
|
if (effects & META_BACKGROUND_EFFECTS_VIGNETTE)
|
||||||
{
|
{
|
||||||
set_brightness (background, self->priv->brightness);
|
set_brightness (background, self->priv->brightness);
|
||||||
@ -1309,8 +1169,7 @@ meta_background_copy (MetaBackground *self,
|
|||||||
* The returned object should be set on a #MetaBackgroundActor with
|
* The returned object should be set on a #MetaBackgroundActor with
|
||||||
* clutter_actor_set_content().
|
* clutter_actor_set_content().
|
||||||
*
|
*
|
||||||
* The background may be desaturated, blurred, or given a vignette depending
|
* The background may be given a vignette by setting @effects
|
||||||
* on @effects.
|
|
||||||
*
|
*
|
||||||
* Return value: the newly created background content
|
* Return value: the newly created background content
|
||||||
*/
|
*/
|
||||||
|
@ -53,8 +53,6 @@ typedef struct _MetaBackgroundPrivate MetaBackgroundPrivate;
|
|||||||
/**
|
/**
|
||||||
* MetaBackgroundEffects:
|
* MetaBackgroundEffects:
|
||||||
* @META_BACKGROUND_EFFECTS_NONE: No effect
|
* @META_BACKGROUND_EFFECTS_NONE: No effect
|
||||||
* @META_BACKGROUND_EFFECTS_DESATURATE: Desaturate
|
|
||||||
* @META_BACKGROUND_EFFECTS_BLUR: Blur
|
|
||||||
* @META_BACKGROUND_EFFECTS_VIGNETTE: Vignette
|
* @META_BACKGROUND_EFFECTS_VIGNETTE: Vignette
|
||||||
*
|
*
|
||||||
* Which effects to enable on the background
|
* Which effects to enable on the background
|
||||||
@ -63,9 +61,7 @@ typedef struct _MetaBackgroundPrivate MetaBackgroundPrivate;
|
|||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
META_BACKGROUND_EFFECTS_NONE = 0,
|
META_BACKGROUND_EFFECTS_NONE = 0,
|
||||||
META_BACKGROUND_EFFECTS_DESATURATE = 1 << 0,
|
META_BACKGROUND_EFFECTS_VIGNETTE = 1 << 1,
|
||||||
META_BACKGROUND_EFFECTS_BLUR = 1 << 1,
|
|
||||||
META_BACKGROUND_EFFECTS_VIGNETTE = 1 << 2,
|
|
||||||
} MetaBackgroundEffects;
|
} MetaBackgroundEffects;
|
||||||
|
|
||||||
struct _MetaBackgroundClass
|
struct _MetaBackgroundClass
|
||||||
|
Loading…
x
Reference in New Issue
Block a user