Remove support for arbitrary rotations

There was some unused code-paths for rendering surfaces with an
arbitrary rotation applied. This was imported from rootston.

Since we don't have plans to make use of this, remove it.
master
Simon Ser 4 years ago committed by Kenny Levinsen
parent 4e6f515253
commit fd36289faa

@ -72,8 +72,8 @@ struct sway_output *output_get_in_direction(struct sway_output *reference,
void output_add_workspace(struct sway_output *output, void output_add_workspace(struct sway_output *output,
struct sway_workspace *workspace); struct sway_workspace *workspace);
typedef void (*sway_surface_iterator_func_t)(struct sway_output *output, struct sway_view *view, typedef void (*sway_surface_iterator_func_t)(struct sway_output *output,
struct wlr_surface *surface, struct wlr_box *box, float rotation, struct sway_view *view, struct wlr_surface *surface, struct wlr_box *box,
void *user_data); void *user_data);
void output_damage_whole(struct sway_output *output); void output_damage_whole(struct sway_output *output);

@ -56,26 +56,6 @@ struct sway_output *all_output_by_name_or_id(const char *name_or_id) {
return NULL; return NULL;
} }
/**
* Rotate a child's position relative to a parent. The parent size is (pw, ph),
* the child position is (*sx, *sy) and its size is (sw, sh).
*/
static void rotate_child_position(double *sx, double *sy, double sw, double sh,
double pw, double ph, float rotation) {
if (rotation == 0.0f) {
return;
}
// Coordinates relative to the center of the subsurface
double ox = *sx - pw/2 + sw/2,
oy = *sy - ph/2 + sh/2;
// Rotated coordinates
double rx = cos(-rotation)*ox - sin(-rotation)*oy,
ry = cos(-rotation)*oy + sin(-rotation)*ox;
*sx = rx + pw/2 - sw/2;
*sy = ry + ph/2 - sh/2;
}
struct surface_iterator_data { struct surface_iterator_data {
sway_surface_iterator_func_t user_iterator; sway_surface_iterator_func_t user_iterator;
void *user_data; void *user_data;
@ -84,7 +64,6 @@ struct surface_iterator_data {
struct sway_view *view; struct sway_view *view;
double ox, oy; double ox, oy;
int width, height; int width, height;
float rotation;
}; };
static bool get_surface_box(struct surface_iterator_data *data, static bool get_surface_box(struct surface_iterator_data *data,
@ -99,14 +78,9 @@ static bool get_surface_box(struct surface_iterator_data *data,
int sw = surface->current.width; int sw = surface->current.width;
int sh = surface->current.height; int sh = surface->current.height;
double _sx = sx;
double _sy = sy;
rotate_child_position(&_sx, &_sy, sw, sh, data->width, data->height,
data->rotation);
struct wlr_box box = { struct wlr_box box = {
.x = floor(data->ox + _sx), .x = floor(data->ox + sx),
.y = floor(data->oy + _sy), .y = floor(data->oy + sy),
.width = sw, .width = sw,
.height = sh, .height = sh,
}; };
@ -114,16 +88,13 @@ static bool get_surface_box(struct surface_iterator_data *data,
memcpy(surface_box, &box, sizeof(struct wlr_box)); memcpy(surface_box, &box, sizeof(struct wlr_box));
} }
struct wlr_box rotated_box;
wlr_box_rotated_bounds(&rotated_box, &box, data->rotation);
struct wlr_box output_box = { struct wlr_box output_box = {
.width = output->width, .width = output->width,
.height = output->height, .height = output->height,
}; };
struct wlr_box intersection; struct wlr_box intersection;
return wlr_box_intersection(&intersection, &output_box, &rotated_box); return wlr_box_intersection(&intersection, &output_box, &box);
} }
static void output_for_each_surface_iterator(struct wlr_surface *surface, static void output_for_each_surface_iterator(struct wlr_surface *surface,
@ -136,7 +107,7 @@ static void output_for_each_surface_iterator(struct wlr_surface *surface,
return; return;
} }
data->user_iterator(data->output, data->view, surface, &box, data->rotation, data->user_iterator(data->output, data->view, surface, &box,
data->user_data); data->user_data);
} }
@ -152,7 +123,6 @@ void output_surface_for_each_surface(struct sway_output *output,
.oy = oy, .oy = oy,
.width = surface->current.width, .width = surface->current.width,
.height = surface->current.height, .height = surface->current.height,
.rotation = 0,
}; };
wlr_surface_for_each_surface(surface, wlr_surface_for_each_surface(surface,
@ -173,7 +143,6 @@ void output_view_for_each_surface(struct sway_output *output,
- view->geometry.y, - view->geometry.y,
.width = view->container->current.content_width, .width = view->container->current.content_width,
.height = view->container->current.content_height, .height = view->container->current.content_height,
.rotation = 0, // TODO
}; };
view_for_each_surface(view, output_for_each_surface_iterator, &data); view_for_each_surface(view, output_for_each_surface_iterator, &data);
@ -193,7 +162,6 @@ void output_view_for_each_popup_surface(struct sway_output *output,
- view->geometry.y, - view->geometry.y,
.width = view->container->current.content_width, .width = view->container->current.content_width,
.height = view->container->current.content_height, .height = view->container->current.content_height,
.rotation = 0, // TODO
}; };
view_for_each_popup_surface(view, output_for_each_surface_iterator, &data); view_for_each_popup_surface(view, output_for_each_surface_iterator, &data);
@ -216,7 +184,6 @@ void output_layer_for_each_surface(struct sway_output *output,
.oy = layer_surface->geo.y, .oy = layer_surface->geo.y,
.width = surface->current.width, .width = surface->current.width,
.height = surface->current.height, .height = surface->current.height,
.rotation = 0,
}; };
wlr_layer_surface_v1_for_each_surface(wlr_layer_surface_v1, wlr_layer_surface_v1_for_each_surface(wlr_layer_surface_v1,
output_for_each_surface_iterator, &data); output_for_each_surface_iterator, &data);
@ -254,7 +221,6 @@ void output_layer_for_each_popup_surface(struct sway_output *output,
.oy = layer_surface->geo.y, .oy = layer_surface->geo.y,
.width = surface->current.width, .width = surface->current.width,
.height = surface->current.height, .height = surface->current.height,
.rotation = 0,
}; };
wlr_layer_surface_v1_for_each_popup_surface(wlr_layer_surface_v1, wlr_layer_surface_v1_for_each_popup_surface(wlr_layer_surface_v1,
output_for_each_surface_iterator, &data); output_for_each_surface_iterator, &data);
@ -426,9 +392,9 @@ struct send_frame_done_data {
int msec_until_refresh; int msec_until_refresh;
}; };
static void send_frame_done_iterator(struct sway_output *output, struct sway_view *view, static void send_frame_done_iterator(struct sway_output *output,
struct wlr_surface *surface, struct wlr_box *box, float rotation, struct sway_view *view, struct wlr_surface *surface,
void *user_data) { struct wlr_box *box, void *user_data) {
int view_max_render_time = 0; int view_max_render_time = 0;
if (view != NULL) { if (view != NULL) {
view_max_render_time = view->max_render_time; view_max_render_time = view->max_render_time;
@ -451,9 +417,9 @@ static void send_frame_done(struct sway_output *output, struct send_frame_done_d
output_for_each_surface(output, send_frame_done_iterator, data); output_for_each_surface(output, send_frame_done_iterator, data);
} }
static void count_surface_iterator(struct sway_output *output, struct sway_view *view, static void count_surface_iterator(struct sway_output *output,
struct wlr_surface *surface, struct wlr_box *_box, float rotation, struct sway_view *view, struct wlr_surface *surface,
void *data) { struct wlr_box *box, void *data) {
size_t *n = data; size_t *n = data;
(*n)++; (*n)++;
} }
@ -657,18 +623,15 @@ void output_damage_whole(struct sway_output *output) {
} }
} }
static void damage_surface_iterator(struct sway_output *output, struct sway_view *view, static void damage_surface_iterator(struct sway_output *output,
struct wlr_surface *surface, struct wlr_box *_box, float rotation, struct sway_view *view, struct wlr_surface *surface,
void *_data) { struct wlr_box *_box, void *_data) {
bool *data = _data; bool *data = _data;
bool whole = *data; bool whole = *data;
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_y = box.y + box.height/2;
if (pixman_region32_not_empty(&surface->buffer_damage)) { if (pixman_region32_not_empty(&surface->buffer_damage)) {
pixman_region32_t damage; pixman_region32_t damage;
pixman_region32_init(&damage); pixman_region32_init(&damage);
@ -681,14 +644,11 @@ static void damage_surface_iterator(struct sway_output *output, struct sway_view
ceil(output->wlr_output->scale) - surface->current.scale); ceil(output->wlr_output->scale) - surface->current.scale);
} }
pixman_region32_translate(&damage, box.x, box.y); 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); wlr_output_damage_add(output->damage, &damage);
pixman_region32_fini(&damage); pixman_region32_fini(&damage);
} }
if (whole) { if (whole) {
wlr_box_rotated_bounds(&box, &box, rotation);
wlr_output_damage_add_box(output->damage, &box); wlr_output_damage_add_box(output->damage, &box);
} }

@ -131,9 +131,9 @@ damage_finish:
pixman_region32_fini(&damage); pixman_region32_fini(&damage);
} }
static void render_surface_iterator(struct sway_output *output, struct sway_view *view, static void render_surface_iterator(struct sway_output *output,
struct wlr_surface *surface, struct wlr_box *_box, float rotation, struct sway_view *view, struct wlr_surface *surface,
void *_data) { struct wlr_box *_box, void *_data) {
struct render_data *data = _data; struct render_data *data = _data;
struct wlr_output *wlr_output = output->wlr_output; struct wlr_output *wlr_output = output->wlr_output;
pixman_region32_t *output_damage = data->damage; pixman_region32_t *output_damage = data->damage;
@ -153,7 +153,7 @@ static void render_surface_iterator(struct sway_output *output, struct sway_view
float matrix[9]; float matrix[9];
enum wl_output_transform transform = enum wl_output_transform transform =
wlr_output_transform_invert(surface->current.transform); wlr_output_transform_invert(surface->current.transform);
wlr_matrix_project_box(matrix, &proj_box, transform, rotation, wlr_matrix_project_box(matrix, &proj_box, transform, 0.0,
wlr_output->transform_matrix); wlr_output->transform_matrix);
struct wlr_box dst_box = *_box; struct wlr_box dst_box = *_box;

Loading…
Cancel
Save