Delete old damage tracking code

The new scene graph abstraction handles this for us.
This commit is contained in:
Alexander Orzechowski 2023-04-06 22:23:53 +02:00 committed by Kirill Primak
parent 06ad734e70
commit 1e018e72b4
20 changed files with 0 additions and 448 deletions

View file

@ -1,13 +0,0 @@
#include <wlr/types/wlr_compositor.h>
struct sway_container;
struct sway_view;
void desktop_damage_surface(struct wlr_surface *surface, double lx, double ly,
bool whole);
void desktop_damage_whole_container(struct sway_container *con);
void desktop_damage_box(struct wlr_box *box);
void desktop_damage_view(struct sway_view *view);

View file

@ -45,8 +45,6 @@ struct sway_output {
struct wlr_box usable_area;
struct wlr_damage_ring damage_ring;
int lx, ly; // layout coords
int width, height; // transformed buffer size
enum wl_output_subpixel detected_subpixel;
@ -99,19 +97,6 @@ typedef void (*sway_surface_iterator_func_t)(struct sway_output *output,
struct sway_view *view, struct wlr_surface *surface, struct wlr_box *box,
void *user_data);
void output_damage_whole(struct sway_output *output);
void output_damage_surface(struct sway_output *output, double ox, double oy,
struct wlr_surface *surface, bool whole);
void output_damage_from_view(struct sway_output *output,
struct sway_view *view);
void output_damage_box(struct sway_output *output, struct wlr_box *box);
void output_damage_whole_container(struct sway_output *output,
struct sway_container *con);
bool output_match_name_or_id(struct sway_output *output,
const char *name_or_id);
@ -129,18 +114,6 @@ void output_disable(struct sway_output *output);
struct sway_workspace *output_get_active_workspace(struct sway_output *output);
void output_surface_for_each_surface(struct sway_output *output,
struct wlr_surface *surface, double ox, double oy,
sway_surface_iterator_func_t iterator, void *user_data);
void output_view_for_each_surface(struct sway_output *output,
struct sway_view *view, sway_surface_iterator_func_t iterator,
void *user_data);
void output_view_for_each_popup_surface(struct sway_output *output,
struct sway_view *view, sway_surface_iterator_func_t iterator,
void *user_data);
void output_for_each_workspace(struct sway_output *output,
void (*f)(struct sway_workspace *ws, void *data), void *data);
@ -158,8 +131,6 @@ void output_get_box(struct sway_output *output, struct wlr_box *box);
enum sway_container_layout output_get_default_layout(
struct sway_output *output);
void scale_box(struct wlr_box *box, float scale);
enum wlr_direction opposite_direction(enum wlr_direction d);
void handle_output_layout_change(struct wl_listener *listener, void *data);

View file

@ -125,11 +125,6 @@ struct sway_container {
double child_total_width;
double child_total_height;
// In most cases this is the same as the content x and y, but if the view
// refuses to resize to the content dimensions then it can be smaller.
// These are in layout coordinates.
double surface_x, surface_y;
// Outputs currently being intersected
list_t *outputs; // struct sway_output
@ -181,8 +176,6 @@ bool container_has_ancestor(struct sway_container *container,
void container_update_textures_recursive(struct sway_container *con);
void container_damage_whole(struct sway_container *container);
void container_reap_empty(struct sway_container *con);
struct sway_container *container_flatten(struct sway_container *container);

View file

@ -46,10 +46,6 @@ struct sway_view_impl {
void (*set_fullscreen)(struct sway_view *view, bool fullscreen);
void (*set_resizing)(struct sway_view *view, bool resizing);
bool (*wants_floating)(struct sway_view *view);
void (*for_each_surface)(struct sway_view *view,
wlr_surface_iterator_func_t iterator, void *user_data);
void (*for_each_popup_surface)(struct sway_view *view,
wlr_surface_iterator_func_t iterator, void *user_data);
bool (*is_transient_for)(struct sway_view *child,
struct sway_view *ancestor);
void (*close)(struct sway_view *view);
@ -254,20 +250,6 @@ void view_close(struct sway_view *view);
void view_close_popups(struct sway_view *view);
void view_damage_from(struct sway_view *view);
/**
* Iterate all surfaces of a view (toplevels + popups).
*/
void view_for_each_surface(struct sway_view *view,
wlr_surface_iterator_func_t iterator, void *user_data);
/**
* Iterate all popup surfaces of a view.
*/
void view_for_each_popup_surface(struct sway_view *view,
wlr_surface_iterator_func_t iterator, void *user_data);
// view implementation
bool view_init(struct sway_view *view, enum sway_view_type type,

View file

@ -51,11 +51,6 @@ static struct cmd_results *handle_command(int argc, char **argv, char *cmd_name,
if (config->active) {
root_for_each_container(container_update_iterator, NULL);
for (int i = 0; i < root->outputs->length; ++i) {
struct sway_output *output = root->outputs->items[i];
output_damage_whole(output);
}
}
return cmd_results_new(CMD_SUCCESS, NULL);

View file

@ -37,6 +37,5 @@ struct cmd_results *cmd_opacity(int argc, char **argv) {
}
con->alpha = val;
container_damage_whole(con);
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -26,10 +26,5 @@ struct cmd_results *cmd_show_marks(int argc, char **argv) {
root_for_each_container(title_bar_update_iterator, NULL);
}
for (int i = 0; i < root->outputs->length; ++i) {
struct sway_output *output = root->outputs->items[i];
output_damage_whole(output);
}
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -27,10 +27,5 @@ struct cmd_results *cmd_title_align(int argc, char **argv) {
root_for_each_container(arrange_title_bar_iterator, NULL);
for (int i = 0; i < root->outputs->length; ++i) {
struct sway_output *output = root->outputs->items[i];
output_damage_whole(output);
}
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -27,7 +27,6 @@ struct cmd_results *cmd_titlebar_border_thickness(int argc, char **argv) {
"Expected output to have a workspace");
}
arrange_workspace(ws);
output_damage_whole(output);
}
return cmd_results_new(CMD_SUCCESS, NULL);

View file

@ -33,7 +33,6 @@ struct cmd_results *cmd_titlebar_padding(int argc, char **argv) {
for (int i = 0; i < root->outputs->length; ++i) {
struct sway_output *output = root->outputs->items[i];
arrange_workspace(output_get_active_workspace(output));
output_damage_whole(output);
}
return cmd_results_new(CMD_SUCCESS, NULL);

View file

@ -538,10 +538,6 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
return true;
}
if (config->reloading) {
output_damage_whole(output);
}
if (oc) {
enum scale_filter_mode scale_filter_old = output->scale_filter;
switch (oc->scale_filter) {

View file

@ -1,40 +0,0 @@
#include "sway/tree/container.h"
#include "sway/desktop.h"
#include "sway/output.h"
void desktop_damage_surface(struct wlr_surface *surface, double lx, double ly,
bool whole) {
for (int i = 0; i < root->outputs->length; ++i) {
struct sway_output *output = root->outputs->items[i];
struct wlr_box output_box;
wlr_output_layout_get_box(root->output_layout,
output->wlr_output, &output_box);
output_damage_surface(output, lx - output_box.x,
ly - output_box.y, surface, whole);
}
}
void desktop_damage_whole_container(struct sway_container *con) {
for (int i = 0; i < root->outputs->length; ++i) {
struct sway_output *output = root->outputs->items[i];
output_damage_whole_container(output, con);
}
}
void desktop_damage_box(struct wlr_box *box) {
for (int i = 0; i < root->outputs->length; ++i) {
struct sway_output *output = root->outputs->items[i];
output_damage_box(output, box);
}
}
void desktop_damage_view(struct sway_view *view) {
desktop_damage_whole_container(view->container);
struct wlr_box box = {
.x = view->container->current.content_x - view->geometry.x,
.y = view->container->current.content_y - view->geometry.y,
.width = view->surface->current.width,
.height = view->surface->current.height,
};
desktop_damage_box(&box);
}

View file

@ -71,127 +71,6 @@ struct sway_output *all_output_by_name_or_id(const char *name_or_id) {
return NULL;
}
struct surface_iterator_data {
sway_surface_iterator_func_t user_iterator;
void *user_data;
struct sway_output *output;
struct sway_view *view;
double ox, oy;
int width, height;
};
static bool get_surface_box(struct surface_iterator_data *data,
struct wlr_surface *surface, int sx, int sy,
struct wlr_box *surface_box) {
struct sway_output *output = data->output;
if (!wlr_surface_has_buffer(surface)) {
return false;
}
int sw = surface->current.width;
int sh = surface->current.height;
struct wlr_box box = {
.x = floor(data->ox + sx),
.y = floor(data->oy + sy),
.width = sw,
.height = sh,
};
if (surface_box != NULL) {
memcpy(surface_box, &box, sizeof(struct wlr_box));
}
struct wlr_box output_box = {
.width = output->width,
.height = output->height,
};
struct wlr_box intersection;
return wlr_box_intersection(&intersection, &output_box, &box);
}
static void output_for_each_surface_iterator(struct wlr_surface *surface,
int sx, int sy, void *_data) {
struct surface_iterator_data *data = _data;
struct wlr_box box;
bool intersects = get_surface_box(data, surface, sx, sy, &box);
if (!intersects) {
return;
}
data->user_iterator(data->output, data->view, surface, &box,
data->user_data);
}
void output_surface_for_each_surface(struct sway_output *output,
struct wlr_surface *surface, double ox, double oy,
sway_surface_iterator_func_t iterator, void *user_data) {
struct surface_iterator_data data = {
.user_iterator = iterator,
.user_data = user_data,
.output = output,
.view = NULL,
.ox = ox,
.oy = oy,
.width = surface->current.width,
.height = surface->current.height,
};
wlr_surface_for_each_surface(surface,
output_for_each_surface_iterator, &data);
}
void output_view_for_each_surface(struct sway_output *output,
struct sway_view *view, sway_surface_iterator_func_t iterator,
void *user_data) {
struct surface_iterator_data data = {
.user_iterator = iterator,
.user_data = user_data,
.output = output,
.view = view,
.ox = view->container->surface_x - output->lx
- view->geometry.x,
.oy = view->container->surface_y - output->ly
- view->geometry.y,
.width = view->container->current.content_width,
.height = view->container->current.content_height,
};
view_for_each_surface(view, output_for_each_surface_iterator, &data);
}
void output_view_for_each_popup_surface(struct sway_output *output,
struct sway_view *view, sway_surface_iterator_func_t iterator,
void *user_data) {
struct surface_iterator_data data = {
.user_iterator = iterator,
.user_data = user_data,
.output = output,
.view = view,
.ox = view->container->surface_x - output->lx
- view->geometry.x,
.oy = view->container->surface_y - output->ly
- view->geometry.y,
.width = view->container->current.content_width,
.height = view->container->current.content_height,
};
view_for_each_popup_surface(view, output_for_each_surface_iterator, &data);
}
static int scale_length(int length, int offset, float scale) {
return roundf((offset + length) * scale) - roundf(offset * scale);
}
void scale_box(struct wlr_box *box, float scale) {
box->width = scale_length(box->width, box->x, scale);
box->height = scale_length(box->height, box->y, scale);
box->x = roundf(box->x * scale);
box->y = roundf(box->y * scale);
}
struct sway_workspace *output_get_active_workspace(struct sway_output *output) {
struct sway_seat *seat = input_manager_current_seat();
@ -339,9 +218,6 @@ static int output_repaint_timer_handler(void *data) {
}
wlr_scene_output_commit(output->scene_output, NULL);
wlr_damage_ring_rotate(&output->damage_ring);
return 0;
}
@ -409,107 +285,6 @@ static void handle_frame(struct wl_listener *listener, void *user_data) {
wlr_scene_output_for_each_buffer(output->scene_output, send_frame_done_iterator, &data);
}
void output_damage_whole(struct sway_output *output) {
// The output can exist with no wlr_output if it's just been disconnected
// and the transaction to evacuate it has't completed yet.
if (output != NULL && output->wlr_output != NULL) {
wlr_damage_ring_add_whole(&output->damage_ring);
wlr_output_schedule_frame(output->wlr_output);
}
}
static void damage_surface_iterator(struct sway_output *output,
struct sway_view *view, struct wlr_surface *surface,
struct wlr_box *_box, void *_data) {
bool *data = _data;
bool whole = *data;
struct wlr_box box = *_box;
scale_box(&box, output->wlr_output->scale);
pixman_region32_t damage;
pixman_region32_init(&damage);
wlr_surface_get_effective_damage(surface, &damage);
wlr_region_scale(&damage, &damage, output->wlr_output->scale);
if (ceilf(output->wlr_output->scale) > surface->current.scale) {
// When scaling up a surface, it'll become blurry so we need to
// expand the damage region
wlr_region_expand(&damage, &damage,
ceilf(output->wlr_output->scale) - surface->current.scale);
}
pixman_region32_translate(&damage, box.x, box.y);
if (wlr_damage_ring_add(&output->damage_ring, &damage)) {
wlr_output_schedule_frame(output->wlr_output);
}
pixman_region32_fini(&damage);
if (whole) {
if (wlr_damage_ring_add_box(&output->damage_ring, &box)) {
wlr_output_schedule_frame(output->wlr_output);
}
}
if (!wl_list_empty(&surface->current.frame_callback_list)) {
wlr_output_schedule_frame(output->wlr_output);
}
}
void output_damage_surface(struct sway_output *output, double ox, double oy,
struct wlr_surface *surface, bool whole) {
output_surface_for_each_surface(output, surface, ox, oy,
damage_surface_iterator, &whole);
}
void output_damage_from_view(struct sway_output *output,
struct sway_view *view) {
if (!view_is_visible(view)) {
return;
}
bool whole = false;
output_view_for_each_surface(output, view, damage_surface_iterator, &whole);
}
// Expecting an unscaled box in layout coordinates
void output_damage_box(struct sway_output *output, struct wlr_box *_box) {
struct wlr_box box;
memcpy(&box, _box, sizeof(struct wlr_box));
box.x -= output->lx;
box.y -= output->ly;
scale_box(&box, output->wlr_output->scale);
if (wlr_damage_ring_add_box(&output->damage_ring, &box)) {
wlr_output_schedule_frame(output->wlr_output);
}
}
static void damage_child_views_iterator(struct sway_container *con,
void *data) {
if (!con->view || !view_is_visible(con->view)) {
return;
}
struct sway_output *output = data;
bool whole = true;
output_view_for_each_surface(output, con->view, damage_surface_iterator,
&whole);
}
void output_damage_whole_container(struct sway_output *output,
struct sway_container *con) {
// Pad the box by 1px, because the width is a double and might be a fraction
struct wlr_box box = {
.x = con->current.x - output->lx - 1,
.y = con->current.y - output->ly - 1,
.width = con->current.width + 2,
.height = con->current.height + 2,
};
scale_box(&box, output->wlr_output->scale);
// Damage subsurfaces as well, which may extend outside the box
if (con->view) {
damage_child_views_iterator(con, output);
} else {
container_for_each_child(con, damage_child_views_iterator, output);
}
}
static void update_output_manager_config(struct sway_server *server) {
struct wlr_output_configuration_v1 *config =
wlr_output_configuration_v1_create();
@ -553,8 +328,6 @@ static void begin_destroy(struct sway_output *output) {
wl_list_remove(&output->frame.link);
wl_list_remove(&output->request_state.link);
wlr_damage_ring_finish(&output->damage_ring);
wlr_scene_output_destroy(output->scene_output);
output->scene_output = NULL;
output->wlr_output->data = NULL;
@ -594,15 +367,6 @@ static void handle_commit(struct wl_listener *listener, void *data) {
update_output_manager_config(output->server);
}
if (event->state->committed & (
WLR_OUTPUT_STATE_MODE |
WLR_OUTPUT_STATE_TRANSFORM)) {
int width, height;
wlr_output_transformed_resolution(output->wlr_output, &width, &height);
wlr_damage_ring_set_bounds(&output->damage_ring, width, height);
wlr_output_schedule_frame(output->wlr_output);
}
// Next time the output is enabled, try to re-apply the gamma LUT
if ((event->state->committed & WLR_OUTPUT_STATE_ENABLED) && !output->wlr_output->enabled) {
output->gamma_lut_changed = true;
@ -684,7 +448,6 @@ void handle_new_output(struct wl_listener *listener, void *data) {
output->server = server;
output->scene_output = scene_output;
wlr_damage_ring_init(&output->damage_ring);
wl_signal_add(&root->output_layout->events.destroy, &output->layout_destroy);
output->layout_destroy.notify = handle_layout_destroy;
@ -712,9 +475,6 @@ void handle_new_output(struct wl_listener *listener, void *data) {
transaction_commit_dirty();
int width, height;
wlr_output_transformed_resolution(output->wlr_output, &width, &height);
wlr_damage_ring_set_bounds(&output->damage_ring, width, height);
update_output_manager_config(server);
}

View file

@ -5,7 +5,6 @@
#include <time.h>
#include <wlr/types/wlr_buffer.h>
#include "sway/config.h"
#include "sway/desktop.h"
#include "sway/desktop/idle_inhibit_v1.h"
#include "sway/desktop/transaction.h"
#include "sway/input/cursor.h"
@ -214,19 +213,15 @@ static void transaction_add_node(struct sway_transaction *transaction,
static void apply_output_state(struct sway_output *output,
struct sway_output_state *state) {
output_damage_whole(output);
list_free(output->current.workspaces);
memcpy(&output->current, state, sizeof(struct sway_output_state));
output_damage_whole(output);
}
static void apply_workspace_state(struct sway_workspace *ws,
struct sway_workspace_state *state) {
output_damage_whole(ws->current.output);
list_free(ws->current.floating);
list_free(ws->current.tiling);
memcpy(&ws->current, state, sizeof(struct sway_workspace_state));
output_damage_whole(ws->current.output);
}
static void apply_container_state(struct sway_container *container,
@ -256,19 +251,6 @@ static void apply_container_state(struct sway_container *container,
}
}
// Damage the new location
desktop_damage_whole_container(container);
if (view && view->surface) {
struct wlr_surface *surface = view->surface;
struct wlr_box box = {
.x = container->current.content_x - view->geometry.x,
.y = container->current.content_y - view->geometry.y,
.width = surface->current.width,
.height = surface->current.height,
};
desktop_damage_box(&box);
}
if (!container->node.destroying) {
container_discover_outputs(container);
}

View file

@ -214,24 +214,6 @@ static bool wants_floating(struct sway_view *view) {
|| toplevel->parent;
}
static void for_each_surface(struct sway_view *view,
wlr_surface_iterator_func_t iterator, void *user_data) {
if (xdg_shell_view_from_view(view) == NULL) {
return;
}
wlr_xdg_surface_for_each_surface(view->wlr_xdg_toplevel->base, iterator,
user_data);
}
static void for_each_popup_surface(struct sway_view *view,
wlr_surface_iterator_func_t iterator, void *user_data) {
if (xdg_shell_view_from_view(view) == NULL) {
return;
}
wlr_xdg_surface_for_each_popup_surface(view->wlr_xdg_toplevel->base,
iterator, user_data);
}
static bool is_transient_for(struct sway_view *child,
struct sway_view *ancestor) {
if (xdg_shell_view_from_view(child) == NULL) {
@ -279,8 +261,6 @@ static const struct sway_view_impl view_impl = {
.set_fullscreen = set_fullscreen,
.set_resizing = set_resizing,
.wants_floating = wants_floating,
.for_each_surface = for_each_surface,
.for_each_popup_surface = for_each_popup_surface,
.is_transient_for = is_transient_for,
.close = _close,
.close_popups = close_popups,

View file

@ -1,6 +1,5 @@
#define _POSIX_C_SOURCE 200809L
#include <wlr/types/wlr_cursor.h>
#include "sway/desktop.h"
#include "sway/desktop/transaction.h"
#include "sway/input/cursor.h"
#include "sway/input/seat.h"
@ -39,9 +38,7 @@ static void handle_tablet_tool_tip(struct sway_seat *seat,
static void handle_pointer_motion(struct sway_seat *seat, uint32_t time_msec) {
struct seatop_move_floating_event *e = seat->seatop_data;
struct wlr_cursor *cursor = seat->cursor->cursor;
desktop_damage_whole_container(e->con);
container_floating_move_to(e->con, cursor->x - e->dx, cursor->y - e->dy);
desktop_damage_whole_container(e->con);
transaction_commit_dirty();
}

View file

@ -15,7 +15,6 @@ sway_sources = files(
'xdg_activation_v1.c',
'xdg_decoration.c',
'desktop/desktop.c',
'desktop/idle_inhibit_v1.c',
'desktop/layer_shell.c',
'desktop/output.c',

View file

@ -597,12 +597,6 @@ bool container_has_ancestor(struct sway_container *descendant,
return false;
}
void container_damage_whole(struct sway_container *container) {
for (int i = 0; i < root->outputs->length; ++i) {
struct sway_output *output = root->outputs->items[i];
output_damage_whole_container(output, container);
}
}
/**
* Return the output which will be used for scale purposes.

View file

@ -16,7 +16,6 @@
#include "log.h"
#include "sway/criteria.h"
#include "sway/commands.h"
#include "sway/desktop.h"
#include "sway/desktop/transaction.h"
#include "sway/desktop/idle_inhibit_v1.h"
#include "sway/desktop/launcher.h"
@ -456,34 +455,6 @@ void view_close_popups(struct sway_view *view) {
}
}
void view_damage_from(struct sway_view *view) {
for (int i = 0; i < root->outputs->length; ++i) {
struct sway_output *output = root->outputs->items[i];
output_damage_from_view(output, view);
}
}
void view_for_each_surface(struct sway_view *view,
wlr_surface_iterator_func_t iterator, void *user_data) {
if (!view->surface) {
return;
}
if (view->impl->for_each_surface) {
view->impl->for_each_surface(view, iterator, user_data);
} else {
wlr_surface_for_each_surface(view->surface, iterator, user_data);
}
}
void view_for_each_popup_surface(struct sway_view *view,
wlr_surface_iterator_func_t iterator, void *user_data) {
if (!view->surface) {
return;
}
if (view->impl->for_each_popup_surface) {
view->impl->for_each_popup_surface(view, iterator, user_data);
}
}
static bool view_has_executed_criteria(struct sway_view *view,
struct criteria *criteria) {
for (int i = 0; i < view->executed_criteria->length; ++i) {
@ -1143,7 +1114,6 @@ void view_set_urgent(struct sway_view *view, bool enable) {
view->urgent_timer = NULL;
}
}
container_damage_whole(view->container);
ipc_event_window(view->container, "urgent");

View file

@ -686,7 +686,6 @@ void workspace_detect_urgent(struct sway_workspace *workspace) {
if (workspace->urgent != new_urgent) {
workspace->urgent = new_urgent;
ipc_event_workspace(NULL, workspace, "urgent");
output_damage_whole(workspace->output);
}
}