mirror of
https://github.com/NickHu/sway
synced 2024-12-27 21:58:11 +01:00
render: Use wlroots scale filter
This commit is contained in:
parent
c08762901e
commit
876687000d
3 changed files with 7 additions and 29 deletions
|
@ -48,7 +48,6 @@ wlroots = dependency('wlroots', version: wlroots_version)
|
||||||
wlroots_features = {
|
wlroots_features = {
|
||||||
'xwayland': false,
|
'xwayland': false,
|
||||||
'libinput_backend': false,
|
'libinput_backend': false,
|
||||||
'gles2_renderer': false,
|
|
||||||
'session': false,
|
'session': false,
|
||||||
}
|
}
|
||||||
foreach name, _ : wlroots_features
|
foreach name, _ : wlroots_features
|
||||||
|
@ -75,7 +74,6 @@ pango = dependency('pango')
|
||||||
pangocairo = dependency('pangocairo')
|
pangocairo = dependency('pangocairo')
|
||||||
gdk_pixbuf = dependency('gdk-pixbuf-2.0', required: get_option('gdk-pixbuf'))
|
gdk_pixbuf = dependency('gdk-pixbuf-2.0', required: get_option('gdk-pixbuf'))
|
||||||
pixman = dependency('pixman-1')
|
pixman = dependency('pixman-1')
|
||||||
glesv2 = wlroots_features['gles2_renderer'] ? dependency('glesv2') : null_dep
|
|
||||||
libevdev = dependency('libevdev')
|
libevdev = dependency('libevdev')
|
||||||
libinput = wlroots_features['libinput_backend'] ? dependency('libinput', version: '>=1.21.0') : null_dep
|
libinput = wlroots_features['libinput_backend'] ? dependency('libinput', version: '>=1.21.0') : null_dep
|
||||||
xcb = dependency('xcb', required: get_option('xwayland'))
|
xcb = dependency('xcb', required: get_option('xwayland'))
|
||||||
|
|
|
@ -27,10 +27,6 @@
|
||||||
#include "sway/tree/view.h"
|
#include "sway/tree/view.h"
|
||||||
#include "sway/tree/workspace.h"
|
#include "sway/tree/workspace.h"
|
||||||
|
|
||||||
#if WLR_HAS_GLES2_RENDERER
|
|
||||||
#include <wlr/render/gles2.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct render_data {
|
struct render_data {
|
||||||
struct render_context *ctx;
|
struct render_context *ctx;
|
||||||
const pixman_region32_t *damage;
|
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);
|
return roundf((offset + length) * scale) - roundf(offset * scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_scale_filter(struct wlr_output *wlr_output,
|
static enum wlr_scale_filter_mode get_scale_filter(struct sway_output *output) {
|
||||||
struct wlr_texture *texture, enum scale_filter_mode scale_filter) {
|
switch (output->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) {
|
|
||||||
case SCALE_FILTER_LINEAR:
|
case SCALE_FILTER_LINEAR:
|
||||||
glTexParameteri(attribs.target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
return WLR_SCALE_FILTER_BILINEAR;
|
||||||
break;
|
|
||||||
case SCALE_FILTER_NEAREST:
|
case SCALE_FILTER_NEAREST:
|
||||||
glTexParameteri(attribs.target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
return WLR_SCALE_FILTER_NEAREST;
|
||||||
break;
|
default:
|
||||||
case SCALE_FILTER_DEFAULT:
|
abort(); // unreachable
|
||||||
case SCALE_FILTER_SMART:
|
|
||||||
assert(false); // unreachable
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void render_texture(struct render_context *ctx, struct wlr_texture *texture,
|
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_output_damage(&damage, output->wlr_output);
|
||||||
transform = wlr_output_transform_compose(transform, output->wlr_output->transform);
|
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) {
|
wlr_render_pass_add_texture(ctx->pass, &(struct wlr_render_texture_options) {
|
||||||
.texture = texture,
|
.texture = texture,
|
||||||
.src_box = src_box,
|
.src_box = src_box,
|
||||||
|
@ -136,6 +116,7 @@ static void render_texture(struct render_context *ctx, struct wlr_texture *textu
|
||||||
.transform = transform,
|
.transform = transform,
|
||||||
.alpha = &alpha,
|
.alpha = &alpha,
|
||||||
.clip = &damage,
|
.clip = &damage,
|
||||||
|
.filter_mode = get_scale_filter(output),
|
||||||
});
|
});
|
||||||
|
|
||||||
damage_finish:
|
damage_finish:
|
||||||
|
|
|
@ -223,7 +223,6 @@ sway_deps = [
|
||||||
math,
|
math,
|
||||||
pango,
|
pango,
|
||||||
pcre2,
|
pcre2,
|
||||||
glesv2,
|
|
||||||
pixman,
|
pixman,
|
||||||
threads,
|
threads,
|
||||||
wayland_server,
|
wayland_server,
|
||||||
|
|
Loading…
Reference in a new issue