diff options
author | Simon Ser <contact@emersion.fr> | 2020-01-13 16:13:50 +0100 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2020-01-13 12:36:14 -0700 |
commit | 679aa6032db5a077b86ecc34ba2a61680a24bcbf (patch) | |
tree | 02c1d6546c94f6eedc745b763757a320a1ac2c0d /sway/desktop/render.c | |
parent | Amend typo (diff) | |
download | sway-679aa6032db5a077b86ecc34ba2a61680a24bcbf.tar.gz sway-679aa6032db5a077b86ecc34ba2a61680a24bcbf.tar.zst sway-679aa6032db5a077b86ecc34ba2a61680a24bcbf.zip |
Fix unreliable scaling filter
Two changes were made:
- Bind the texture before glTexParameteri
- Set the scaling filter before each wlr_render_texture_with_matrix call
Logging in wlroots allows to check that the scaling filter is properly
set prior to rendering.
Fixes: 6968fb3123e6 ("add scale_filter output config option")
Closes: https://github.com/swaywm/sway/issues/4798
Diffstat (limited to 'sway/desktop/render.c')
-rw-r--r-- | sway/desktop/render.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 43a12046..477034fc 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c | |||
@@ -81,6 +81,8 @@ static void set_scale_filter(struct wlr_output *wlr_output, | |||
81 | struct wlr_gles2_texture_attribs attribs; | 81 | struct wlr_gles2_texture_attribs attribs; |
82 | wlr_gles2_texture_get_attribs(texture, &attribs); | 82 | wlr_gles2_texture_get_attribs(texture, &attribs); |
83 | 83 | ||
84 | glBindTexture(attribs.target, attribs.tex); | ||
85 | |||
84 | switch (scale_filter) { | 86 | switch (scale_filter) { |
85 | case SCALE_FILTER_LINEAR: | 87 | case SCALE_FILTER_LINEAR: |
86 | glTexParameteri(attribs.target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 88 | glTexParameteri(attribs.target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
@@ -99,6 +101,10 @@ static void render_texture(struct wlr_output *wlr_output, | |||
99 | const struct wlr_box *box, const float matrix[static 9], float alpha) { | 101 | const struct wlr_box *box, const float matrix[static 9], float alpha) { |
100 | struct wlr_renderer *renderer = | 102 | struct wlr_renderer *renderer = |
101 | wlr_backend_get_renderer(wlr_output->backend); | 103 | wlr_backend_get_renderer(wlr_output->backend); |
104 | struct sway_output *output = wlr_output->data; | ||
105 | |||
106 | struct wlr_gles2_texture_attribs attribs; | ||
107 | wlr_gles2_texture_get_attribs(texture, &attribs); | ||
102 | 108 | ||
103 | pixman_region32_t damage; | 109 | pixman_region32_t damage; |
104 | pixman_region32_init(&damage); | 110 | pixman_region32_init(&damage); |
@@ -114,6 +120,7 @@ static void render_texture(struct wlr_output *wlr_output, | |||
114 | pixman_box32_t *rects = pixman_region32_rectangles(&damage, &nrects); | 120 | pixman_box32_t *rects = pixman_region32_rectangles(&damage, &nrects); |
115 | for (int i = 0; i < nrects; ++i) { | 121 | for (int i = 0; i < nrects; ++i) { |
116 | scissor_output(wlr_output, &rects[i]); | 122 | scissor_output(wlr_output, &rects[i]); |
123 | set_scale_filter(wlr_output, texture, output->scale_filter); | ||
117 | wlr_render_texture_with_matrix(renderer, texture, matrix, alpha); | 124 | wlr_render_texture_with_matrix(renderer, texture, matrix, alpha); |
118 | } | 125 | } |
119 | 126 | ||
@@ -143,7 +150,6 @@ static void render_surface_iterator(struct sway_output *output, struct sway_view | |||
143 | wlr_matrix_project_box(matrix, &box, transform, rotation, | 150 | wlr_matrix_project_box(matrix, &box, transform, rotation, |
144 | wlr_output->transform_matrix); | 151 | wlr_output->transform_matrix); |
145 | 152 | ||
146 | set_scale_filter(wlr_output, texture, output->scale_filter); | ||
147 | render_texture(wlr_output, output_damage, texture, &box, matrix, alpha); | 153 | render_texture(wlr_output, output_damage, texture, &box, matrix, alpha); |
148 | 154 | ||
149 | wlr_presentation_surface_sampled_on_output(server.presentation, surface, | 155 | wlr_presentation_surface_sampled_on_output(server.presentation, surface, |
@@ -293,7 +299,6 @@ static void render_saved_view(struct sway_view *view, | |||
293 | wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL, 0, | 299 | wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL, 0, |
294 | wlr_output->transform_matrix); | 300 | wlr_output->transform_matrix); |
295 | 301 | ||
296 | set_scale_filter(wlr_output, view->saved_buffer->texture, output->scale_filter); | ||
297 | render_texture(wlr_output, damage, view->saved_buffer->texture, | 302 | render_texture(wlr_output, damage, view->saved_buffer->texture, |
298 | &box, matrix, alpha); | 303 | &box, matrix, alpha); |
299 | 304 | ||