[gnome] Update extensions for version 48

This commit is contained in:
2025-03-29 17:52:56 -04:00
parent e01589e836
commit a84b79ca08
153 changed files with 3479 additions and 2189 deletions

View File

@ -148,6 +148,11 @@ export function get_supported_effects(_ = () => "") {
name: _("Use base pixel"),
description: _("Whether or not the original pixel is counted for the blur. If it is, the image will be more legible."),
type: "boolean"
},
prefer_closer_pixels: {
name: _("Prefer closer pixels"),
description: _("Whether or not the pixels that are closer to the original pixel will have more weight."),
type: "boolean"
}
}
},

View File

@ -5,6 +5,7 @@ uniform float brightness;
uniform float width;
uniform float height;
uniform bool use_base_pixel;
uniform bool prefer_closer_pixels;
float srand(vec2 a) {
return sin(dot(a, vec2(1233.224, 1743.335)));
@ -19,24 +20,31 @@ void main() {
vec2 uv = cogl_tex_coord0_in.st;
vec2 p = 16 * radius / vec2(width, height);
float r = srand(uv);
vec2 rv;
vec2 dir;
vec2 new_uv;
int strength;
int count = 0;
vec4 c = vec4(0.);
for (int i = 0; i < iterations; i++) {
rv.x = rand(r);
rv.y = rand(r);
vec2 new_uv = uv + rv * p;
rv.y = rand(r) * 3.141592;
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) {
c += texture2D(tex, new_uv);
count += 1;
strength = prefer_closer_pixels ? (iterations - i)^2 : 1;
c += strength * texture2D(tex, new_uv);
count += strength;
}
}
if (count == 0 || use_base_pixel) {
c += texture2D(tex, uv);
count += 1;
strength = prefer_closer_pixels ? (iterations + 1)^2 : 1;
c += strength * texture2D(tex, uv);
count += strength;
}
c.xyz *= brightness;

View File

@ -8,7 +8,8 @@ const Clutter = await utils.import_in_shell_only('gi://Clutter');
const SHADER_FILENAME = 'monte_carlo_blur.glsl';
const DEFAULT_PARAMS = {
radius: 2., iterations: 5, brightness: .6,
width: 0, height: 0, use_base_pixel: true
width: 0, height: 0, use_base_pixel: true,
prefer_closer_pixels: true,
};
@ -64,6 +65,13 @@ export const MonteCarloBlurEffect = utils.IS_IN_PREFERENCES ?
GObject.ParamFlags.READWRITE,
true,
),
'prefer_closer_pixels': GObject.ParamSpec.boolean(
`prefer_closer_pixels`,
`Prefer closer pixels`,
`Prefer closer pixels`,
GObject.ParamFlags.READWRITE,
true,
),
}
}, class MonteCarloBlurEffect extends Clutter.ShaderEffect {
constructor(params) {
@ -166,6 +174,18 @@ export const MonteCarloBlurEffect = utils.IS_IN_PREFERENCES ?
}
}
get prefer_closer_pixels() {
return this._prefer_closer_pixels;
}
set prefer_closer_pixels(value) {
if (this._prefer_closer_pixels !== value) {
this._prefer_closer_pixels = value;
this.set_uniform_value('prefer_closer_pixels', this._prefer_closer_pixels ? 1 : 0);
}
}
vfunc_set_actor(actor) {
if (this._actor_connection_size_id) {
let old_actor = this.get_actor();