[gnome] Update extensions

This commit is contained in:
2026-06-10 11:03:09 -04:00
parent 20fc1e4e75
commit 6c973853c6
394 changed files with 12513 additions and 1340 deletions

View File

@ -7,6 +7,7 @@ uniform float width;
uniform float height;
uniform bool corners_top;
uniform bool corners_bottom;
uniform bool straight_corners;
uniform float clip_x0;
uniform float clip_y0;
@ -65,7 +66,9 @@ float rounded_rect_coverage(vec2 p, vec4 bounds, float clip_radius) {
float center_top = bounds.y + clip_radius;
float center_bottom = bounds.w - clip_radius;
if (corners_top && p.y < center_top)
if (straight_corners)
return 1.0;
else if (corners_top && p.y < center_top)
center.y = center_top + 2.;
else if (corners_bottom && p.y > center_bottom)
center.y = center_bottom - 1.;

View File

@ -77,6 +77,7 @@ export const CornerEffect = utils.IS_IN_PREFERENCES ?
this._clip_height = null;
utils.setup_params(this, params);
this.straight_corners = false;
// set shader source
this._source = utils.get_shader_source(Shell, SHADER_FILENAME, import.meta.url);
@ -165,6 +166,18 @@ export const CornerEffect = utils.IS_IN_PREFERENCES ?
}
}
get straight_corners() {
return this._straight_corners;
}
set straight_corners(value) {
if (this._straight_corners !== value) {
this._straight_corners = value;
this.set_uniform_value('straight_corners', this._straight_corners ? 1 : 0);
}
}
get clip() {
return [this._clip_x0, this._clip_y0, this._clip_width, this._clip_height];
}

View File

@ -11,6 +11,7 @@ import { PixelizeEffect } from './pixelize.js';
import { DerivativeEffect } from './derivative.js';
import { RgbToHslEffect } from './rgb_to_hsl.js';
import { HslToRgbEffect } from './hsl_to_rgb.js';
import { LuminosityEffect } from './luminosity.js';
// We do in this way because I've not found another way to store our preferences in a dictionnary
// while calling `gettext` on it while in preferences. Not so pretty, but works.
@ -33,6 +34,7 @@ export function get_effects_groups(_ = _ => "") {
"derivative",
"noise",
"color",
"luminosity",
"rgb_to_hsl",
"hsl_to_rgb"
]
@ -167,7 +169,8 @@ export function get_supported_effects(_ = () => "") {
color: {
name: _("Color"),
description: _("The color to blend in. The blending amount is controled by the opacity of the color."),
type: "rgba"
type: "rgba",
use_alpha: true
},
blend_mode: {
name: _("Blend mode"),
@ -197,6 +200,65 @@ export function get_supported_effects(_ = () => "") {
}
},
luminosity: {
class: LuminosityEffect,
name: _("Luminosity"),
description: _("An effect that affects the luminosity of the image."),
is_advanced: false,
editable_params: {
brightness_shift: {
name: _("Shift brightness"),
description: _("The brightness to add of remove to the image."),
type: "float",
min: -1.,
max: 1.,
increment: 0.01,
big_increment: 0.1,
digits: 2
},
brightness_multiplicator: {
name: _("Multiply brightness"),
description: _("The brightness multiplicator of the image, so that 0 means no brightness and 2 means infinite brightness."),
type: "float",
min: 0.,
max: 2.,
increment: 0.01,
big_increment: 0.1,
digits: 2
},
contrast: {
name: _("Contrast"),
description: _("The contrast of the image in regard to the center of the contrast."),
type: "float",
min: 0.,
max: 2.,
increment: 0.01,
big_increment: 0.1,
digits: 2
},
contrast_center: {
name: _("Contrast center"),
description: _("The center of the contrast to use."),
type: "float",
min: 0.,
max: 1.,
increment: 0.01,
big_increment: 0.1,
digits: 2
},
saturation_multiplicator: {
name: _("Saturation"),
description: _("The saturation of the image, so that 0 means no saturation and 2 means infinite saturation."),
type: "float",
min: 0.,
max: 2.,
increment: 0.01,
big_increment: 0.1,
digits: 2
},
}
},
pixelize: {
class: PixelizeEffect,
name: _("Pixelize"),
@ -343,7 +405,7 @@ export function get_supported_effects(_ = () => "") {
description: _("The radius of the corner. GNOME apps use a radius of 12 px by default."),
type: "integer",
min: 0,
max: 50,
max: 150,
increment: 1,
},
corners_top: {

View File

@ -0,0 +1,33 @@
uniform sampler2D tex;
uniform float brightness_shift;
uniform float brightness_multiplicator;
uniform float contrast;
uniform float contrast_center;
uniform float saturation_multiplicator;
vec3 hsl_to_rgb(vec3 c) {
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
vec3 rgb_to_hsl(vec3 c) {
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
void main() {
vec4 c = texture2D(tex, cogl_tex_coord_in[0].st);
vec3 pix_hsl = rgb_to_hsl(c.xyz) / c.a;
pix_hsl.z = clamp(pix_hsl.z * brightness_multiplicator, 0., 1.);
pix_hsl.z = clamp((pix_hsl.z - contrast_center) * contrast + contrast_center + brightness_shift, 0., 1.);
pix_hsl.y = clamp(pix_hsl.y * saturation_multiplicator, 0., 1.);
cogl_color_out = vec4(hsl_to_rgb(pix_hsl) * c.a, c.a);
}

View File

@ -0,0 +1,141 @@
import GObject from 'gi://GObject';
import * as utils from '../conveniences/utils.js';
const Shell = await utils.import_in_shell_only('gi://Shell');
const Clutter = await utils.import_in_shell_only('gi://Clutter');
const SHADER_FILENAME = 'luminosity.glsl';
const DEFAULT_PARAMS = {
brightness_shift: 0., brightness_multiplicator: 1., contrast: 1., contrast_center: 0.5, saturation_multiplicator: 1.
};
export const LuminosityEffect = utils.IS_IN_PREFERENCES ?
{ default_params: DEFAULT_PARAMS } :
new GObject.registerClass({
GTypeName: "LuminosityEffect",
Properties: {
'brightness_shift': GObject.ParamSpec.double(
`brightness_shift`,
`Brightness shift`,
`Brightness shift value in shader`,
GObject.ParamFlags.READWRITE,
-1.0, 1.0,
0.0,
),
'brightness_multiplicator': GObject.ParamSpec.double(
`brightness_multiplicator`,
`Brightness multiplicator`,
`Brightness multiplicator value in shader`,
GObject.ParamFlags.READWRITE,
0.0, 2.0,
1.0,
),
'contrast': GObject.ParamSpec.double(
`contrast`,
`Contrast`,
`Contrast value in shader`,
GObject.ParamFlags.READWRITE,
0.0, 2.0,
1.0,
),
'contrast_center': GObject.ParamSpec.double(
`contrast_center`,
`Contrast center`,
`Contrast center value in shader`,
GObject.ParamFlags.READWRITE,
0.0, 1.0,
0.5,
),
'saturation_multiplicator': GObject.ParamSpec.double(
`saturation_multiplicator`,
`Saturation multiplicator`,
`Saturation multiplicator value in shader`,
GObject.ParamFlags.READWRITE,
0.0, 2.0,
1.0,
),
}
}, class LuminosityEffect extends Clutter.ShaderEffect {
constructor(params) {
super(params);
utils.setup_params(this, params);
// set shader source
this._source = utils.get_shader_source(Shell, SHADER_FILENAME, import.meta.url);
if (this._source)
this.set_shader_source(this._source);
}
static get default_params() {
return DEFAULT_PARAMS;
}
get brightness_shift() {
return this._brightness;
}
set brightness_shift(value) {
if (this._brightness_shift !== value) {
this._brightness_shift = value;
this.set_uniform_value('brightness_shift', parseFloat(this._brightness_shift - 1e-6));
}
}
get brightness_multiplicator() {
return this._brightness_multiplicator;
}
set brightness_multiplicator(value) {
if (this._brightness_multiplicator !== value) {
this._brightness_multiplicator = value;
let brightness_mul = 600.;
if (value < 1.995)
brightness_mul = 3. * (1. / (1. - (value / 2.) ** 2) - 1.);
this.set_uniform_value('brightness_multiplicator', parseFloat(brightness_mul - 1e-6));
}
}
get contrast() {
return this._contrast;
}
set contrast(value) {
if (this._contrast !== value) {
this._contrast = value;
this.set_uniform_value('contrast', parseFloat(this._contrast - 1e-6));
}
}
get contrast_center() {
return this._contrast_center;
}
set contrast_center(value) {
if (this._contrast_center !== value) {
this._contrast_center = value;
this.set_uniform_value('contrast_center', parseFloat(this._contrast_center - 1e-6));
}
}
get saturation_multiplicator() {
return this._saturation_multiplicator;
}
set saturation_multiplicator(value) {
if (this._saturation_multiplicator !== value) {
this._saturation_multiplicator = value;
let saturation_mul = 600.;
if (value < 1.995)
saturation_mul = 3. * (1. / (1. - (value / 2.) ** 2) - 1.);
this.set_uniform_value('saturation_multiplicator', parseFloat(saturation_mul - 1e-6));
}
}
});

View File

@ -35,14 +35,14 @@ void main() {
dir = vec2(cos(rv.y), sin(rv.y));
new_uv = uv + rv.x * dir * p;
if (new_uv.x > 2. / width && new_uv.y > 2. / height && new_uv.x < 1. - 3. / width && new_uv.y < 1. - 3. / height) {
strength = prefer_closer_pixels ? (iterations - i)^2 : 1;
strength = prefer_closer_pixels ? ((iterations - i) * (iterations - i)) : 1;
c += strength * texture2D(tex, new_uv);
count += strength;
}
}
if (count == 0 || use_base_pixel) {
strength = prefer_closer_pixels ? (iterations + 1)^2 : 1;
strength = prefer_closer_pixels ? ((iterations + 1) * (iterations + 1)) : 1;
c += strength * texture2D(tex, uv);
count += strength;
}

View File

@ -2,10 +2,17 @@ import GObject from 'gi://GObject';
import * as utils from '../conveniences/utils.js';
const St = await utils.import_in_shell_only('gi://St');
const Shell = await utils.import_in_shell_only('gi://Shell');
let BlurOrShell = await utils.import_in_shell_only('gi://Blur');
let IS_BLUR_MODULE = true;
if (BlurOrShell === null) {
BlurOrShell = await utils.import_in_shell_only('gi://Shell');
IS_BLUR_MODULE = false;
}
const DEFAULT_PARAMS = {
unscaled_radius: 30, brightness: 0.6
unscaled_radius: 30, brightness: 0.6, corner_radius: 14
};
@ -13,15 +20,21 @@ export const NativeDynamicBlurEffect = utils.IS_IN_PREFERENCES ?
{ default_params: DEFAULT_PARAMS } :
new GObject.registerClass({
GTypeName: "NativeDynamicBlurEffect"
}, class NativeDynamicBlurEffect extends Shell.BlurEffect {
}, class NativeDynamicBlurEffect extends BlurOrShell.BlurEffect {
constructor(params) {
const { unscaled_radius, brightness, ...parent_params } = params;
super({ ...parent_params, mode: Shell.BlurMode.BACKGROUND });
const { unscaled_radius, brightness, corner_radius, ...parent_params } = params;
if (IS_BLUR_MODULE)
super({ ...parent_params, mode: BlurOrShell.BlurMode.BACKGROUND, ...{ 'corner_radius': corner_radius } });
else
super({ ...parent_params, mode: BlurOrShell.BlurMode.BACKGROUND });
this._theme_context = St.ThemeContext.get_for_stage(global.stage);
this._theme_context.connectObject(
'notify::scale-factor',
_ => this.radius = this.unscaled_radius * this._theme_context.scale_factor,
_ => {
this.radius = this.unscaled_radius * this._theme_context.scale_factor;
this.corner_radius = this.unscaled_corner_radius * this._theme_context.scale_factor;
},
this
);
@ -40,4 +53,13 @@ export const NativeDynamicBlurEffect = utils.IS_IN_PREFERENCES ?
this._unscaled_radius = value;
this.radius = value * this._theme_context.scale_factor;
}
});
get unscaled_corner_radius() {
return this._unscaled_corner_radius;
}
set unscaled_corner_radius(value) {
this._unscaled_corner_radius = value;
this.corner_radius = value * this._theme_context.scale_factor;
}
});