diff options
author | Simon Ser <contact@emersion.fr> | 2020-04-27 16:41:54 +0200 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2020-06-17 10:18:58 -0600 |
commit | e19bd1e47441e6292eb77d7caa8b3211666bef2e (patch) | |
tree | f86b9bc75ecb42e0eee529c131a3635514fae444 /sway/desktop | |
parent | input/pointer: don't trigger pointer bindings for emulated input (diff) | |
download | sway-e19bd1e47441e6292eb77d7caa8b3211666bef2e.tar.gz sway-e19bd1e47441e6292eb77d7caa8b3211666bef2e.tar.zst sway-e19bd1e47441e6292eb77d7caa8b3211666bef2e.zip |
Add support for viewporter
Depends on [1].
[1]: https://github.com/swaywm/wlroots/pull/2092
Diffstat (limited to 'sway/desktop')
-rw-r--r-- | sway/desktop/render.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 2996e135..d3d927c8 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c | |||
@@ -98,7 +98,8 @@ static void set_scale_filter(struct wlr_output *wlr_output, | |||
98 | 98 | ||
99 | static void render_texture(struct wlr_output *wlr_output, | 99 | static void render_texture(struct wlr_output *wlr_output, |
100 | pixman_region32_t *output_damage, struct wlr_texture *texture, | 100 | pixman_region32_t *output_damage, struct wlr_texture *texture, |
101 | const struct wlr_box *box, const float matrix[static 9], float alpha) { | 101 | const struct wlr_fbox *src_box, const struct wlr_box *dst_box, |
102 | const float matrix[static 9], float alpha) { | ||
102 | struct wlr_renderer *renderer = | 103 | struct wlr_renderer *renderer = |
103 | wlr_backend_get_renderer(wlr_output->backend); | 104 | wlr_backend_get_renderer(wlr_output->backend); |
104 | struct sway_output *output = wlr_output->data; | 105 | struct sway_output *output = wlr_output->data; |
@@ -108,8 +109,8 @@ static void render_texture(struct wlr_output *wlr_output, | |||
108 | 109 | ||
109 | pixman_region32_t damage; | 110 | pixman_region32_t damage; |
110 | pixman_region32_init(&damage); | 111 | pixman_region32_init(&damage); |
111 | pixman_region32_union_rect(&damage, &damage, box->x, box->y, | 112 | pixman_region32_union_rect(&damage, &damage, dst_box->x, dst_box->y, |
112 | box->width, box->height); | 113 | dst_box->width, dst_box->height); |
113 | pixman_region32_intersect(&damage, &damage, output_damage); | 114 | pixman_region32_intersect(&damage, &damage, output_damage); |
114 | bool damaged = pixman_region32_not_empty(&damage); | 115 | bool damaged = pixman_region32_not_empty(&damage); |
115 | if (!damaged) { | 116 | if (!damaged) { |
@@ -121,7 +122,11 @@ static void render_texture(struct wlr_output *wlr_output, | |||
121 | for (int i = 0; i < nrects; ++i) { | 122 | for (int i = 0; i < nrects; ++i) { |
122 | scissor_output(wlr_output, &rects[i]); | 123 | scissor_output(wlr_output, &rects[i]); |
123 | set_scale_filter(wlr_output, texture, output->scale_filter); | 124 | set_scale_filter(wlr_output, texture, output->scale_filter); |
124 | wlr_render_texture_with_matrix(renderer, texture, matrix, alpha); | 125 | if (src_box != NULL) { |
126 | wlr_render_subtexture_with_matrix(renderer, texture, src_box, matrix, alpha); | ||
127 | } else { | ||
128 | wlr_render_texture_with_matrix(renderer, texture, matrix, alpha); | ||
129 | } | ||
125 | } | 130 | } |
126 | 131 | ||
127 | damage_finish: | 132 | damage_finish: |
@@ -141,16 +146,20 @@ static void render_surface_iterator(struct sway_output *output, struct sway_view | |||
141 | return; | 146 | return; |
142 | } | 147 | } |
143 | 148 | ||
144 | struct wlr_box box = *_box; | 149 | struct wlr_fbox src_box; |
145 | scale_box(&box, wlr_output->scale); | 150 | wlr_surface_get_buffer_source_box(surface, &src_box); |
151 | |||
152 | struct wlr_box dst_box = *_box; | ||
153 | scale_box(&dst_box, wlr_output->scale); | ||
146 | 154 | ||
147 | float matrix[9]; | 155 | float matrix[9]; |
148 | enum wl_output_transform transform = | 156 | enum wl_output_transform transform = |
149 | wlr_output_transform_invert(surface->current.transform); | 157 | wlr_output_transform_invert(surface->current.transform); |
150 | wlr_matrix_project_box(matrix, &box, transform, rotation, | 158 | wlr_matrix_project_box(matrix, &dst_box, transform, rotation, |
151 | wlr_output->transform_matrix); | 159 | wlr_output->transform_matrix); |
152 | 160 | ||
153 | render_texture(wlr_output, output_damage, texture, &box, matrix, alpha); | 161 | render_texture(wlr_output, output_damage, texture, |
162 | &src_box, &dst_box, matrix, alpha); | ||
154 | 163 | ||
155 | wlr_presentation_surface_sampled_on_output(server.presentation, surface, | 164 | wlr_presentation_surface_sampled_on_output(server.presentation, surface, |
156 | wlr_output); | 165 | wlr_output); |
@@ -317,7 +326,7 @@ static void render_saved_view(struct sway_view *view, | |||
317 | wlr_output->transform_matrix); | 326 | wlr_output->transform_matrix); |
318 | 327 | ||
319 | render_texture(wlr_output, damage, saved_buf->buffer->texture, | 328 | render_texture(wlr_output, damage, saved_buf->buffer->texture, |
320 | &box, matrix, alpha); | 329 | &saved_buf->source_box, &box, matrix, alpha); |
321 | } | 330 | } |
322 | 331 | ||
323 | // FIXME: we should set the surface that this saved buffer originates from | 332 | // FIXME: we should set the surface that this saved buffer originates from |
@@ -497,7 +506,7 @@ static void render_titlebar(struct sway_output *output, | |||
497 | texture_box.width = ob_inner_width; | 506 | texture_box.width = ob_inner_width; |
498 | } | 507 | } |
499 | render_texture(output->wlr_output, output_damage, marks_texture, | 508 | render_texture(output->wlr_output, output_damage, marks_texture, |
500 | &texture_box, matrix, con->alpha); | 509 | NULL, &texture_box, matrix, con->alpha); |
501 | 510 | ||
502 | // Padding above | 511 | // Padding above |
503 | memcpy(&color, colors->background, sizeof(float) * 4); | 512 | memcpy(&color, colors->background, sizeof(float) * 4); |
@@ -565,7 +574,7 @@ static void render_titlebar(struct sway_output *output, | |||
565 | } | 574 | } |
566 | 575 | ||
567 | render_texture(output->wlr_output, output_damage, title_texture, | 576 | render_texture(output->wlr_output, output_damage, title_texture, |
568 | &texture_box, matrix, con->alpha); | 577 | NULL, &texture_box, matrix, con->alpha); |
569 | 578 | ||
570 | // Padding above | 579 | // Padding above |
571 | memcpy(&color, colors->background, sizeof(float) * 4); | 580 | memcpy(&color, colors->background, sizeof(float) * 4); |