summaryrefslogtreecommitdiffstats
path: root/sway/desktop/render.c
diff options
context:
space:
mode:
authorLibravatar Ronan Pigott <rpigott@berkeley.edu>2019-11-13 11:23:36 -0700
committerLibravatar Simon Ser <contact@emersion.fr>2019-11-29 18:13:37 +0100
commit6968fb3123e69f563cd01d472967a9e6ddca2ec1 (patch)
tree0e313d5e19da37762ab572e38c36ff33798f25fb /sway/desktop/render.c
parentoutput: Ensure that frame_done is delayed on max_render_time (diff)
downloadsway-6968fb3123e69f563cd01d472967a9e6ddca2ec1.tar.gz
sway-6968fb3123e69f563cd01d472967a9e6ddca2ec1.tar.zst
sway-6968fb3123e69f563cd01d472967a9e6ddca2ec1.zip
add scale_filter output config option
Diffstat (limited to 'sway/desktop/render.c')
-rw-r--r--sway/desktop/render.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/sway/desktop/render.c b/sway/desktop/render.c
index 960fe083..2e66abd4 100644
--- a/sway/desktop/render.c
+++ b/sway/desktop/render.c
@@ -1,9 +1,11 @@
1#define _POSIX_C_SOURCE 200809L 1#define _POSIX_C_SOURCE 200809L
2#include <assert.h> 2#include <assert.h>
3#include <GLES2/gl2.h>
3#include <stdlib.h> 4#include <stdlib.h>
4#include <strings.h> 5#include <strings.h>
5#include <time.h> 6#include <time.h>
6#include <wayland-server-core.h> 7#include <wayland-server-core.h>
8#include <wlr/render/gles2.h>
7#include <wlr/render/wlr_renderer.h> 9#include <wlr/render/wlr_renderer.h>
8#include <wlr/types/wlr_box.h> 10#include <wlr/types/wlr_box.h>
9#include <wlr/types/wlr_buffer.h> 11#include <wlr/types/wlr_buffer.h>
@@ -70,6 +72,28 @@ static void scissor_output(struct wlr_output *wlr_output,
70 wlr_renderer_scissor(renderer, &box); 72 wlr_renderer_scissor(renderer, &box);
71} 73}
72 74
75static void set_scale_filter(struct wlr_output *wlr_output,
76 struct wlr_texture *texture, enum scale_filter_mode scale_filter) {
77 if (!wlr_texture_is_gles2(texture)) {
78 return;
79 }
80
81 struct wlr_gles2_texture_attribs attribs;
82 wlr_gles2_texture_get_attribs(texture, &attribs);
83
84 switch (scale_filter) {
85 case SCALE_FILTER_LINEAR:
86 glTexParameteri(attribs.target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
87 break;
88 case SCALE_FILTER_NEAREST:
89 glTexParameteri(attribs.target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
90 break;
91 case SCALE_FILTER_DEFAULT:
92 case SCALE_FILTER_SMART:
93 assert(false); // unreachable
94 }
95}
96
73static void render_texture(struct wlr_output *wlr_output, 97static void render_texture(struct wlr_output *wlr_output,
74 pixman_region32_t *output_damage, struct wlr_texture *texture, 98 pixman_region32_t *output_damage, struct wlr_texture *texture,
75 const struct wlr_box *box, const float matrix[static 9], float alpha) { 99 const struct wlr_box *box, const float matrix[static 9], float alpha) {
@@ -119,6 +143,7 @@ static void render_surface_iterator(struct sway_output *output, struct sway_view
119 wlr_matrix_project_box(matrix, &box, transform, rotation, 143 wlr_matrix_project_box(matrix, &box, transform, rotation,
120 wlr_output->transform_matrix); 144 wlr_output->transform_matrix);
121 145
146 set_scale_filter(wlr_output, texture, output->scale_filter);
122 render_texture(wlr_output, output_damage, texture, &box, matrix, alpha); 147 render_texture(wlr_output, output_damage, texture, &box, matrix, alpha);
123 148
124 wlr_presentation_surface_sampled_on_output(server.presentation, surface, 149 wlr_presentation_surface_sampled_on_output(server.presentation, surface,
@@ -268,6 +293,7 @@ static void render_saved_view(struct sway_view *view,
268 wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL, 0, 293 wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL, 0,
269 wlr_output->transform_matrix); 294 wlr_output->transform_matrix);
270 295
296 set_scale_filter(wlr_output, view->saved_buffer->texture, output->scale_filter);
271 render_texture(wlr_output, damage, view->saved_buffer->texture, 297 render_texture(wlr_output, damage, view->saved_buffer->texture,
272 &box, matrix, alpha); 298 &box, matrix, alpha);
273 299