Fixed #258 blur regression (#261)

This commit is contained in:
Erik Reider 2024-01-05 08:47:43 +01:00 committed by GitHub
parent 04b657b58c
commit 303b7dfb69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 2 deletions

View file

@ -773,6 +773,8 @@ int config_get_blur_size();
bool config_should_parameters_blur(); bool config_should_parameters_blur();
bool config_should_parameters_blur_effects();
bool config_should_parameters_shadow(); bool config_should_parameters_shadow();
/* Global config singleton. */ /* Global config singleton. */

View file

@ -1109,6 +1109,13 @@ bool config_should_parameters_blur() {
return config->blur_params.radius > 0 && config->blur_params.num_passes > 0; return config->blur_params.radius > 0 && config->blur_params.num_passes > 0;
} }
bool config_should_parameters_blur_effects() {
return config->blur_params.brightness != 1.0f
|| config->blur_params.saturation != 1.0f
|| config->blur_params.contrast != 1.0f
|| config->blur_params.noise > 0.0f;
}
bool config_should_parameters_shadow() { bool config_should_parameters_shadow() {
return config->shadow_blur_sigma > 0 && config->shadow_color[3] > 0.0; return config->shadow_blur_sigma > 0 && config->shadow_color[3] > 0.0;
} }

View file

@ -930,7 +930,6 @@ void fx_render_blur_effects(struct fx_renderer *renderer, const float matrix[sta
float blur_contrast, float blur_saturation) { float blur_contrast, float blur_saturation) {
struct effects_shader shader = renderer->shaders.blur_effects; struct effects_shader shader = renderer->shaders.blur_effects;
glEnable(GL_BLEND);
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture((*buffer)->texture.target, (*buffer)->texture.id); glBindTexture((*buffer)->texture.target, (*buffer)->texture.id);
glTexParameteri((*buffer)->texture.target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri((*buffer)->texture.target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

View file

@ -263,7 +263,13 @@ struct fx_framebuffer *get_main_buffer_blur(struct fx_renderer *renderer, struct
float blur_contrast = config->blur_params.contrast; float blur_contrast = config->blur_params.contrast;
float blur_saturation = config->blur_params.saturation; float blur_saturation = config->blur_params.saturation;
if (pixman_region32_not_empty(&damage)) { // Render additional blur effects like saturation, noise, contrast, etc...
if (config_should_parameters_blur_effects() && pixman_region32_not_empty(&damage)) {
if (current_buffer == &renderer->effects_buffer) {
fx_framebuffer_bind(&renderer->effects_buffer_swapped);
} else {
fx_framebuffer_bind(&renderer->effects_buffer);
}
int nrects; int nrects;
pixman_box32_t *rects = pixman_region32_rectangles(&damage, &nrects); pixman_box32_t *rects = pixman_region32_rectangles(&damage, &nrects);
for (int i = 0; i < nrects; ++i) { for (int i = 0; i < nrects; ++i) {
@ -273,6 +279,11 @@ struct fx_framebuffer *get_main_buffer_blur(struct fx_renderer *renderer, struct
fx_render_blur_effects(renderer, gl_matrix, &current_buffer, blur_noise, fx_render_blur_effects(renderer, gl_matrix, &current_buffer, blur_noise,
blur_brightness, blur_contrast, blur_saturation); blur_brightness, blur_contrast, blur_saturation);
} }
if (current_buffer != &renderer->effects_buffer) {
current_buffer = &renderer->effects_buffer;
} else {
current_buffer = &renderer->effects_buffer_swapped;
}
} }
pixman_region32_fini(&tempDamage); pixman_region32_fini(&tempDamage);