mirror of
https://github.com/swaywm/sway.git
synced 2025-11-08 13:29:50 -05:00
Completely switch over to new iterators
This commit is contained in:
parent
e9d674cfd2
commit
8d5cc8625c
3 changed files with 98 additions and 250 deletions
|
|
@ -29,10 +29,7 @@
|
|||
#include "sway/tree/workspace.h"
|
||||
|
||||
struct render_data {
|
||||
struct root_geometry root_geo;
|
||||
struct sway_output *output;
|
||||
pixman_region32_t *damage;
|
||||
struct sway_view *view;
|
||||
float alpha;
|
||||
};
|
||||
|
||||
|
|
@ -92,38 +89,7 @@ damage_finish:
|
|||
pixman_region32_fini(&damage);
|
||||
}
|
||||
|
||||
static void render_surface_iterator(struct wlr_surface *surface, int sx, int sy,
|
||||
void *_data) {
|
||||
struct render_data *data = _data;
|
||||
struct wlr_output *wlr_output = data->output->wlr_output;
|
||||
float rotation = data->root_geo.rotation;
|
||||
pixman_region32_t *output_damage = data->damage;
|
||||
float alpha = data->alpha;
|
||||
|
||||
struct wlr_texture *texture = wlr_surface_get_texture(surface);
|
||||
if (!texture) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct wlr_box box;
|
||||
bool intersects = output_get_surface_box(&data->root_geo, data->output,
|
||||
surface, sx, sy, &box);
|
||||
if (!intersects) {
|
||||
return;
|
||||
}
|
||||
|
||||
scale_box(&box, wlr_output->scale);
|
||||
|
||||
float matrix[9];
|
||||
enum wl_output_transform transform =
|
||||
wlr_output_transform_invert(surface->current.transform);
|
||||
wlr_matrix_project_box(matrix, &box, transform, rotation,
|
||||
wlr_output->transform_matrix);
|
||||
|
||||
render_texture(wlr_output, output_damage, texture, &box, matrix, alpha);
|
||||
}
|
||||
|
||||
static void render_surface_iterator2(struct sway_output *output,
|
||||
static void render_surface_iterator(struct sway_output *output,
|
||||
struct wlr_surface *surface, struct wlr_box *_box, float rotation,
|
||||
void *_data) {
|
||||
struct render_data *data = _data;
|
||||
|
|
@ -151,36 +117,33 @@ static void render_surface_iterator2(struct sway_output *output,
|
|||
static void render_layer(struct sway_output *output,
|
||||
pixman_region32_t *damage, struct wl_list *layer_surfaces) {
|
||||
struct render_data data = {
|
||||
.output = output,
|
||||
.damage = damage,
|
||||
.alpha = 1.0f,
|
||||
};
|
||||
output_layer_for_each_surface(output, layer_surfaces,
|
||||
render_surface_iterator2, &data);
|
||||
render_surface_iterator, &data);
|
||||
}
|
||||
|
||||
#ifdef HAVE_XWAYLAND
|
||||
static void render_unmanaged(struct sway_output *output,
|
||||
pixman_region32_t *damage, struct wl_list *unmanaged) {
|
||||
struct render_data data = {
|
||||
.output = output,
|
||||
.damage = damage,
|
||||
.alpha = 1.0f,
|
||||
};
|
||||
output_unmanaged_for_each_surface(output, unmanaged,
|
||||
render_surface_iterator2, &data);
|
||||
render_surface_iterator, &data);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void render_drag_icons(struct sway_output *output,
|
||||
pixman_region32_t *damage, struct wl_list *drag_icons) {
|
||||
struct render_data data = {
|
||||
.output = output,
|
||||
.damage = damage,
|
||||
.alpha = 1.0f,
|
||||
};
|
||||
output_drag_icons_for_each_surface(output, drag_icons,
|
||||
render_surface_iterator2, &data);
|
||||
render_surface_iterator, &data);
|
||||
}
|
||||
|
||||
static void render_rect(struct wlr_output *wlr_output,
|
||||
|
|
@ -226,12 +189,10 @@ static void premultiply_alpha(float color[4], float opacity) {
|
|||
static void render_view_surfaces(struct sway_view *view,
|
||||
struct sway_output *output, pixman_region32_t *damage, float alpha) {
|
||||
struct render_data data = {
|
||||
.output = output,
|
||||
.damage = damage,
|
||||
.view = view,
|
||||
.alpha = alpha,
|
||||
};
|
||||
output_view_for_each_surface(output, view, render_surface_iterator2, &data);
|
||||
output_view_for_each_surface(output, view, render_surface_iterator, &data);
|
||||
}
|
||||
|
||||
static void render_saved_view(struct sway_view *view,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue