mirror of
https://github.com/swaywm/sway.git
synced 2026-04-29 06:46:22 -04:00
Merge 26024ad434 into c1f09939ae
This commit is contained in:
commit
3a027cb0e1
3 changed files with 28 additions and 49 deletions
|
|
@ -75,7 +75,7 @@ void output_damage_whole(struct sway_output *output);
|
||||||
void output_damage_surface(struct sway_output *output, double ox, double oy,
|
void output_damage_surface(struct sway_output *output, double ox, double oy,
|
||||||
struct wlr_surface *surface, bool whole);
|
struct wlr_surface *surface, bool whole);
|
||||||
|
|
||||||
void output_damage_from_view(struct sway_output *output,
|
void output_damage_view_surfaces(struct sway_output *output,
|
||||||
struct sway_view *view);
|
struct sway_view *view);
|
||||||
|
|
||||||
void output_damage_box(struct sway_output *output, struct wlr_box *box);
|
void output_damage_box(struct sway_output *output, struct wlr_box *box);
|
||||||
|
|
|
||||||
|
|
@ -392,44 +392,37 @@ void output_damage_whole(struct sway_output *output) {
|
||||||
|
|
||||||
static void damage_surface_iterator(struct sway_output *output,
|
static void damage_surface_iterator(struct sway_output *output,
|
||||||
struct wlr_surface *surface, struct wlr_box *_box, float rotation,
|
struct wlr_surface *surface, struct wlr_box *_box, float rotation,
|
||||||
void *_data) {
|
void *data) {
|
||||||
bool *data = _data;
|
if (!pixman_region32_not_empty(&surface->buffer_damage)) {
|
||||||
bool whole = *data;
|
return;
|
||||||
|
}
|
||||||
struct wlr_box box = *_box;
|
struct wlr_box box = *_box;
|
||||||
scale_box(&box, output->wlr_output->scale);
|
scale_box(&box, output->wlr_output->scale);
|
||||||
|
|
||||||
int center_x = box.x + box.width/2;
|
int center_x = box.x + box.width/2;
|
||||||
int center_y = box.y + box.height/2;
|
int center_y = box.y + box.height/2;
|
||||||
|
|
||||||
if (pixman_region32_not_empty(&surface->buffer_damage)) {
|
enum wl_output_transform transform =
|
||||||
enum wl_output_transform transform =
|
wlr_output_transform_invert(surface->current.transform);
|
||||||
wlr_output_transform_invert(surface->current.transform);
|
|
||||||
|
|
||||||
pixman_region32_t damage;
|
pixman_region32_t damage;
|
||||||
pixman_region32_init(&damage);
|
pixman_region32_init(&damage);
|
||||||
pixman_region32_copy(&damage, &surface->buffer_damage);
|
pixman_region32_copy(&damage, &surface->buffer_damage);
|
||||||
wlr_region_transform(&damage, &damage, transform,
|
wlr_region_transform(&damage, &damage, transform,
|
||||||
surface->current.buffer_width, surface->current.buffer_height);
|
surface->current.buffer_width, surface->current.buffer_height);
|
||||||
wlr_region_scale(&damage, &damage,
|
wlr_region_scale(&damage, &damage,
|
||||||
output->wlr_output->scale / (float)surface->current.scale);
|
output->wlr_output->scale / (float)surface->current.scale);
|
||||||
if (ceil(output->wlr_output->scale) > surface->current.scale) {
|
if (ceil(output->wlr_output->scale) > surface->current.scale) {
|
||||||
// When scaling up a surface, it'll become blurry so we need to
|
// When scaling up a surface, it'll become blurry so we need to
|
||||||
// expand the damage region
|
// expand the damage region
|
||||||
wlr_region_expand(&damage, &damage,
|
wlr_region_expand(&damage, &damage,
|
||||||
ceil(output->wlr_output->scale) - surface->current.scale);
|
ceil(output->wlr_output->scale) - surface->current.scale);
|
||||||
}
|
|
||||||
pixman_region32_translate(&damage, box.x, box.y);
|
|
||||||
wlr_region_rotated_bounds(&damage, &damage, rotation,
|
|
||||||
center_x, center_y);
|
|
||||||
wlr_output_damage_add(output->damage, &damage);
|
|
||||||
pixman_region32_fini(&damage);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (whole) {
|
|
||||||
wlr_box_rotated_bounds(&box, rotation, &box);
|
|
||||||
wlr_output_damage_add_box(output->damage, &box);
|
|
||||||
}
|
}
|
||||||
|
pixman_region32_translate(&damage, box.x, box.y);
|
||||||
|
wlr_region_rotated_bounds(&damage, &damage, rotation,
|
||||||
|
center_x, center_y);
|
||||||
|
wlr_output_damage_add(output->damage, &damage);
|
||||||
|
pixman_region32_fini(&damage);
|
||||||
|
|
||||||
wlr_output_schedule_frame(output->wlr_output);
|
wlr_output_schedule_frame(output->wlr_output);
|
||||||
}
|
}
|
||||||
|
|
@ -440,17 +433,12 @@ void output_damage_surface(struct sway_output *output, double ox, double oy,
|
||||||
damage_surface_iterator, &whole);
|
damage_surface_iterator, &whole);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void output_damage_view(struct sway_output *output,
|
void output_damage_view_surfaces(struct sway_output *output,
|
||||||
struct sway_view *view, bool whole) {
|
struct sway_view *view) {
|
||||||
if (!view_is_visible(view)) {
|
if (!view_is_visible(view)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
output_view_for_each_surface(output, view, damage_surface_iterator, &whole);
|
output_view_for_each_surface(output, view, damage_surface_iterator, NULL);
|
||||||
}
|
|
||||||
|
|
||||||
void output_damage_from_view(struct sway_output *output,
|
|
||||||
struct sway_view *view) {
|
|
||||||
output_damage_view(output, view, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expecting an unscaled box in layout coordinates
|
// Expecting an unscaled box in layout coordinates
|
||||||
|
|
@ -463,15 +451,6 @@ void output_damage_box(struct sway_output *output, struct wlr_box *_box) {
|
||||||
wlr_output_damage_add_box(output->damage, &box);
|
wlr_output_damage_add_box(output->damage, &box);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void output_damage_whole_container_iterator(struct sway_container *con,
|
|
||||||
void *data) {
|
|
||||||
if (!sway_assert(con->view, "expected a view")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
struct sway_output *output = data;
|
|
||||||
output_damage_view(output, con->view, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
||||||
// 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
|
||||||
|
|
|
||||||
|
|
@ -371,7 +371,7 @@ void view_close_popups(struct sway_view *view) {
|
||||||
void view_damage_from(struct sway_view *view) {
|
void view_damage_from(struct sway_view *view) {
|
||||||
for (int i = 0; i < root->outputs->length; ++i) {
|
for (int i = 0; i < root->outputs->length; ++i) {
|
||||||
struct sway_output *output = root->outputs->items[i];
|
struct sway_output *output = root->outputs->items[i];
|
||||||
output_damage_from_view(output, view);
|
output_damage_view_surfaces(output, view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue