From 876687000d4de503cdb01fcd8fa14f1b05dd9a1e Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Mon, 19 Jun 2023 13:05:12 -0400 Subject: [PATCH] render: Use wlroots scale filter --- meson.build | 2 -- sway/desktop/render.c | 33 +++++++-------------------------- sway/meson.build | 1 - 3 files changed, 7 insertions(+), 29 deletions(-) diff --git a/meson.build b/meson.build index 559ee962d..eeee39cde 100644 --- a/meson.build +++ b/meson.build @@ -48,7 +48,6 @@ wlroots = dependency('wlroots', version: wlroots_version) wlroots_features = { 'xwayland': false, 'libinput_backend': false, - 'gles2_renderer': false, 'session': false, } foreach name, _ : wlroots_features @@ -75,7 +74,6 @@ pango = dependency('pango') pangocairo = dependency('pangocairo') gdk_pixbuf = dependency('gdk-pixbuf-2.0', required: get_option('gdk-pixbuf')) pixman = dependency('pixman-1') -glesv2 = wlroots_features['gles2_renderer'] ? dependency('glesv2') : null_dep libevdev = dependency('libevdev') libinput = wlroots_features['libinput_backend'] ? dependency('libinput', version: '>=1.21.0') : null_dep xcb = dependency('xcb', required: get_option('xwayland')) diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 210140424..f08e2c6c4 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c @@ -27,10 +27,6 @@ #include "sway/tree/view.h" #include "sway/tree/workspace.h" -#if WLR_HAS_GLES2_RENDERER -#include -#endif - struct render_data { struct render_context *ctx; const pixman_region32_t *damage; @@ -71,30 +67,15 @@ static int scale_length(int length, int offset, float scale) { return roundf((offset + length) * scale) - roundf(offset * scale); } -static void set_scale_filter(struct wlr_output *wlr_output, - struct wlr_texture *texture, enum scale_filter_mode scale_filter) { -#if WLR_HAS_GLES2_RENDERER - if (!wlr_texture_is_gles2(texture)) { - return; - } - - struct wlr_gles2_texture_attribs attribs; - wlr_gles2_texture_get_attribs(texture, &attribs); - - glBindTexture(attribs.target, attribs.tex); - - switch (scale_filter) { +static enum wlr_scale_filter_mode get_scale_filter(struct sway_output *output) { + switch (output->scale_filter) { case SCALE_FILTER_LINEAR: - glTexParameteri(attribs.target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - break; + return WLR_SCALE_FILTER_BILINEAR; case SCALE_FILTER_NEAREST: - glTexParameteri(attribs.target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - break; - case SCALE_FILTER_DEFAULT: - case SCALE_FILTER_SMART: - assert(false); // unreachable + return WLR_SCALE_FILTER_NEAREST; + default: + abort(); // unreachable } -#endif } static 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 transform_output_damage(&damage, output->wlr_output); transform = wlr_output_transform_compose(transform, output->wlr_output->transform); - set_scale_filter(output->wlr_output, texture, output->scale_filter); wlr_render_pass_add_texture(ctx->pass, &(struct wlr_render_texture_options) { .texture = texture, .src_box = src_box, @@ -136,6 +116,7 @@ static void render_texture(struct render_context *ctx, struct wlr_texture *textu .transform = transform, .alpha = &alpha, .clip = &damage, + .filter_mode = get_scale_filter(output), }); damage_finish: diff --git a/sway/meson.build b/sway/meson.build index bc193bf94..3abd778db 100644 --- a/sway/meson.build +++ b/sway/meson.build @@ -223,7 +223,6 @@ sway_deps = [ math, pango, pcre2, - glesv2, pixman, threads, wayland_server,