returned extended damage
This commit is contained in:
parent
e065838dd9
commit
58fd78f389
4 changed files with 31 additions and 21 deletions
|
@ -92,7 +92,7 @@ struct sway_output *workspace_output_get_highest_available(
|
||||||
|
|
||||||
void workspace_detect_urgent(struct sway_workspace *workspace);
|
void workspace_detect_urgent(struct sway_workspace *workspace);
|
||||||
|
|
||||||
bool should_workspace_need_optimized_blur(struct sway_workspace *ws);
|
bool should_workspace_have_blur(struct sway_workspace *ws);
|
||||||
|
|
||||||
void workspace_for_each_container(struct sway_workspace *ws,
|
void workspace_for_each_container(struct sway_workspace *ws,
|
||||||
void (*f)(struct sway_container *con, void *data), void *data);
|
void (*f)(struct sway_container *con, void *data), void *data);
|
||||||
|
|
|
@ -746,17 +746,13 @@ static void damage_child_views_iterator(struct sway_container *con,
|
||||||
void output_damage_whole_container(struct sway_output *output,
|
void output_damage_whole_container(struct sway_output *output,
|
||||||
struct sway_container *con) {
|
struct sway_container *con) {
|
||||||
int shadow_sigma = con->shadow_enabled ? config->shadow_blur_sigma : 0;
|
int shadow_sigma = con->shadow_enabled ? config->shadow_blur_sigma : 0;
|
||||||
int blur_size = con->blur_enabled ?
|
|
||||||
pow(2, config->blur_params.num_passes) * config->blur_params.radius : 0;
|
|
||||||
// +1 as a margin of error
|
|
||||||
int effect_size = MAX(shadow_sigma, blur_size) + 1;
|
|
||||||
|
|
||||||
// Pad the box by 1px, because the width is a double and might be a fraction
|
// Pad the box by 1px, because the width is a double and might be a fraction
|
||||||
struct wlr_box box = {
|
struct wlr_box box = {
|
||||||
.x = con->current.x - output->lx - 1 - effect_size,
|
.x = con->current.x - output->lx - 1 - shadow_sigma,
|
||||||
.y = con->current.y - output->ly - 1 - effect_size,
|
.y = con->current.y - output->ly - 1 - shadow_sigma,
|
||||||
.width = con->current.width + 2 + effect_size * 2,
|
.width = con->current.width + 2 + shadow_sigma * 2,
|
||||||
.height = con->current.height + 2 + effect_size * 2,
|
.height = con->current.height + 2 + shadow_sigma * 2,
|
||||||
};
|
};
|
||||||
scale_box(&box, output->wlr_output->scale);
|
scale_box(&box, output->wlr_output->scale);
|
||||||
if (wlr_damage_ring_add_box(&output->damage_ring, &box)) {
|
if (wlr_damage_ring_add_box(&output->damage_ring, &box)) {
|
||||||
|
|
|
@ -54,6 +54,10 @@ bool 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int get_blur_size() {
|
||||||
|
return pow(2, config->blur_params.num_passes) * config->blur_params.radius;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: contribute wlroots function to allow creating an fbox from a box?
|
// TODO: contribute wlroots function to allow creating an fbox from a box?
|
||||||
struct wlr_fbox wlr_fbox_from_wlr_box(struct wlr_box *box) {
|
struct wlr_fbox wlr_fbox_from_wlr_box(struct wlr_box *box) {
|
||||||
return (struct wlr_fbox) {
|
return (struct wlr_fbox) {
|
||||||
|
@ -246,8 +250,7 @@ struct fx_framebuffer *get_main_buffer_blur(struct fx_renderer *renderer, struct
|
||||||
pixman_region32_copy(&damage, original_damage);
|
pixman_region32_copy(&damage, original_damage);
|
||||||
wlr_region_transform(&damage, &damage, transform, monitor_box.width, monitor_box.height);
|
wlr_region_transform(&damage, &damage, transform, monitor_box.width, monitor_box.height);
|
||||||
|
|
||||||
int blur_size = pow(2, config->blur_params.num_passes) * config->blur_params.radius;
|
wlr_region_expand(&damage, &damage, get_blur_size());
|
||||||
wlr_region_expand(&damage, &damage, blur_size);
|
|
||||||
|
|
||||||
// Initially blur main_buffer content into the effects_buffers
|
// Initially blur main_buffer content into the effects_buffers
|
||||||
struct fx_framebuffer *current_buffer = &renderer->main_buffer;
|
struct fx_framebuffer *current_buffer = &renderer->main_buffer;
|
||||||
|
@ -1832,6 +1835,11 @@ void output_render(struct sway_output *output, struct timespec *when,
|
||||||
goto renderer_end;
|
goto renderer_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool should_render_blur = false;
|
||||||
|
pixman_region32_t extended_damage;
|
||||||
|
pixman_region32_init(&extended_damage);
|
||||||
|
pixman_region32_copy(&extended_damage, damage);
|
||||||
|
|
||||||
if (output_has_opaque_overlay_layer_surface(output)) {
|
if (output_has_opaque_overlay_layer_surface(output)) {
|
||||||
goto render_overlay;
|
goto render_overlay;
|
||||||
}
|
}
|
||||||
|
@ -1886,7 +1894,12 @@ void output_render(struct sway_output *output, struct timespec *when,
|
||||||
|
|
||||||
// check if the background needs to be blurred
|
// check if the background needs to be blurred
|
||||||
if (should_parameters_blur() && renderer->blur_buffer_dirty) {
|
if (should_parameters_blur() && renderer->blur_buffer_dirty) {
|
||||||
if (should_workspace_need_optimized_blur(workspace)) {
|
should_render_blur = should_workspace_have_blur(workspace);
|
||||||
|
if (should_render_blur) {
|
||||||
|
wlr_region_expand(damage, damage, get_blur_size());
|
||||||
|
pixman_region32_copy(&extended_damage, damage);
|
||||||
|
wlr_region_expand(damage, damage, get_blur_size());
|
||||||
|
|
||||||
pixman_region32_union_rect(damage, damage, 0, 0, width, height);
|
pixman_region32_union_rect(damage, damage, 0, 0, width, height);
|
||||||
render_monitor_blur(output, damage);
|
render_monitor_blur(output, damage);
|
||||||
}
|
}
|
||||||
|
@ -1939,15 +1952,16 @@ renderer_end:
|
||||||
fx_framebuffer_bind(&renderer->wlr_buffer);
|
fx_framebuffer_bind(&renderer->wlr_buffer);
|
||||||
|
|
||||||
float clear_color[] = {0.0f, 0.0f, 0.0f, 1.0f};
|
float clear_color[] = {0.0f, 0.0f, 0.0f, 1.0f};
|
||||||
if (pixman_region32_not_empty(damage)) {
|
if (pixman_region32_not_empty(&extended_damage)) {
|
||||||
int nrects;
|
int nrects;
|
||||||
pixman_box32_t *rects = pixman_region32_rectangles(damage, &nrects);
|
pixman_box32_t *rects = pixman_region32_rectangles(&extended_damage, &nrects);
|
||||||
for (int i = 0; i < nrects; ++i) {
|
for (int i = 0; i < nrects; ++i) {
|
||||||
scissor_output(wlr_output, &rects[i]);
|
scissor_output(wlr_output, &rects[i]);
|
||||||
fx_renderer_clear(clear_color);
|
fx_renderer_clear(clear_color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
render_whole_output(renderer, wlr_output, damage, &renderer->main_buffer.texture);
|
|
||||||
|
render_whole_output(renderer, wlr_output, &extended_damage, &renderer->main_buffer.texture);
|
||||||
fx_renderer_end(renderer);
|
fx_renderer_end(renderer);
|
||||||
|
|
||||||
fx_renderer_scissor(NULL);
|
fx_renderer_scissor(NULL);
|
||||||
|
@ -1961,8 +1975,8 @@ renderer_end:
|
||||||
pixman_region32_init(&frame_damage);
|
pixman_region32_init(&frame_damage);
|
||||||
|
|
||||||
enum wl_output_transform transform = wlr_output_transform_invert(wlr_output->transform);
|
enum wl_output_transform transform = wlr_output_transform_invert(wlr_output->transform);
|
||||||
wlr_region_transform(&frame_damage, &output->damage_ring.current,
|
wlr_region_transform(&frame_damage, &extended_damage, transform, width, height);
|
||||||
transform, width, height);
|
pixman_region32_fini(&extended_damage);
|
||||||
|
|
||||||
if (debug.damage != DAMAGE_DEFAULT) {
|
if (debug.damage != DAMAGE_DEFAULT) {
|
||||||
pixman_region32_union_rect(&frame_damage, &frame_damage,
|
pixman_region32_union_rect(&frame_damage, &frame_damage,
|
||||||
|
|
|
@ -690,22 +690,22 @@ void workspace_detect_urgent(struct sway_workspace *workspace) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool find_optimized_blur_iterator(struct sway_container *con, void *data) {
|
static bool find_blurred_con_iterator(struct sway_container *con, void *data) {
|
||||||
struct sway_view *view = con->view;
|
struct sway_view *view = con->view;
|
||||||
if (!view) {
|
if (!view) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (con->blur_enabled && !view->surface->opaque && (!container_is_floating(con) || config->blur_xray)) {
|
if (con->blur_enabled && !view->surface->opaque) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool should_workspace_need_optimized_blur(struct sway_workspace *ws) {
|
bool should_workspace_have_blur(struct sway_workspace *ws) {
|
||||||
if (!workspace_is_visible(ws)) {
|
if (!workspace_is_visible(ws)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return (bool)workspace_find_container(ws, find_optimized_blur_iterator, NULL);
|
return (bool)workspace_find_container(ws, find_blurred_con_iterator, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void workspace_for_each_container(struct sway_workspace *ws,
|
void workspace_for_each_container(struct sway_workspace *ws,
|
||||||
|
|
Loading…
Add table
Reference in a new issue