aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/render.c
diff options
context:
space:
mode:
authorLibravatar Alexander Orzechowski <alex@ozal.ski>2023-06-19 13:05:12 -0400
committerLibravatar Simon Ser <contact@emersion.fr>2023-06-19 19:14:28 +0200
commit876687000d4de503cdb01fcd8fa14f1b05dd9a1e (patch)
treeb438f8aa15357a0a4123769f9b8207278636f94b /sway/desktop/render.c
parentinput/libinput: add scroll_button_lock method (diff)
downloadsway-876687000d4de503cdb01fcd8fa14f1b05dd9a1e.tar.gz
sway-876687000d4de503cdb01fcd8fa14f1b05dd9a1e.tar.zst
sway-876687000d4de503cdb01fcd8fa14f1b05dd9a1e.zip
render: Use wlroots scale filter
Diffstat (limited to 'sway/desktop/render.c')
-rw-r--r--sway/desktop/render.c33
1 files changed, 7 insertions, 26 deletions
diff --git a/sway/desktop/render.c b/sway/desktop/render.c
index 21014042..f08e2c6c 100644
--- a/sway/desktop/render.c
+++ b/sway/desktop/render.c
@@ -27,10 +27,6 @@
27#include "sway/tree/view.h" 27#include "sway/tree/view.h"
28#include "sway/tree/workspace.h" 28#include "sway/tree/workspace.h"
29 29
30#if WLR_HAS_GLES2_RENDERER
31#include <wlr/render/gles2.h>
32#endif
33
34struct render_data { 30struct render_data {
35 struct render_context *ctx; 31 struct render_context *ctx;
36 const pixman_region32_t *damage; 32 const pixman_region32_t *damage;
@@ -71,30 +67,15 @@ static int scale_length(int length, int offset, float scale) {
71 return roundf((offset + length) * scale) - roundf(offset * scale); 67 return roundf((offset + length) * scale) - roundf(offset * scale);
72} 68}
73 69
74static void set_scale_filter(struct wlr_output *wlr_output, 70static enum wlr_scale_filter_mode get_scale_filter(struct sway_output *output) {
75 struct wlr_texture *texture, enum scale_filter_mode scale_filter) { 71 switch (output->scale_filter) {
76#if WLR_HAS_GLES2_RENDERER
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 glBindTexture(attribs.target, attribs.tex);
85
86 switch (scale_filter) {
87 case SCALE_FILTER_LINEAR: 72 case SCALE_FILTER_LINEAR:
88 glTexParameteri(attribs.target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 73 return WLR_SCALE_FILTER_BILINEAR;
89 break;
90 case SCALE_FILTER_NEAREST: 74 case SCALE_FILTER_NEAREST:
91 glTexParameteri(attribs.target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 75 return WLR_SCALE_FILTER_NEAREST;
92 break; 76 default:
93 case SCALE_FILTER_DEFAULT: 77 abort(); // unreachable
94 case SCALE_FILTER_SMART:
95 assert(false); // unreachable
96 } 78 }
97#endif
98} 79}
99 80
100static void render_texture(struct render_context *ctx, struct wlr_texture *texture, 81static void render_texture(struct render_context *ctx, struct wlr_texture *texture,
@@ -128,7 +109,6 @@ static void render_texture(struct render_context *ctx, struct wlr_texture *textu
128 transform_output_damage(&damage, output->wlr_output); 109 transform_output_damage(&damage, output->wlr_output);
129 transform = wlr_output_transform_compose(transform, output->wlr_output->transform); 110 transform = wlr_output_transform_compose(transform, output->wlr_output->transform);
130 111
131 set_scale_filter(output->wlr_output, texture, output->scale_filter);
132 wlr_render_pass_add_texture(ctx->pass, &(struct wlr_render_texture_options) { 112 wlr_render_pass_add_texture(ctx->pass, &(struct wlr_render_texture_options) {
133 .texture = texture, 113 .texture = texture,
134 .src_box = src_box, 114 .src_box = src_box,
@@ -136,6 +116,7 @@ static void render_texture(struct render_context *ctx, struct wlr_texture *textu
136 .transform = transform, 116 .transform = transform,
137 .alpha = &alpha, 117 .alpha = &alpha,
138 .clip = &damage, 118 .clip = &damage,
119 .filter_mode = get_scale_filter(output),
139 }); 120 });
140 121
141damage_finish: 122damage_finish: