From 94f21ca61c53e22ab8211a6c8f41058fd6ffa9ae Mon Sep 17 00:00:00 2001 From: Simon Long Date: Fri, 3 May 2024 11:33:33 +0100 Subject: [PATCH] Add filtering option to XML --- docs/rc.xml.all | 3 +++ include/config/rcxml.h | 1 + src/common/scene-helpers.c | 5 +---- src/config/rcxml.c | 3 +++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/rc.xml.all b/docs/rc.xml.all index 0dd10192..dcf011c6 100644 --- a/docs/rc.xml.all +++ b/docs/rc.xml.all @@ -595,12 +595,15 @@ colour of the border for the magnifier window. 'borderWidth' sets the width in pixels of the border for the magnifier window. + 'useFilter' sets whether to use a bilinear filter on the magnified + output or simply to take nearest pixel. --> 400 2 #ff0000 1 + true diff --git a/include/config/rcxml.h b/include/config/rcxml.h index 04ac756a..bab9913b 100644 --- a/include/config/rcxml.h +++ b/include/config/rcxml.h @@ -149,6 +149,7 @@ struct rcxml { int mag_size; struct rgb_colour mag_border_col; int mag_border_width; + bool mag_filter; }; extern struct rcxml rc; diff --git a/src/common/scene-helpers.c b/src/common/scene-helpers.c index 342a925b..5836ce93 100644 --- a/src/common/scene-helpers.c +++ b/src/common/scene-helpers.c @@ -74,7 +74,6 @@ magnify(struct output *output, struct wlr_buffer *output_buffer, struct wlr_box ox *= output->wlr_output->scale; oy *= output->wlr_output->scale; - /* TODO: refactor, to use rc. settings */ int width = rc.mag_size + 1; int height = width; double x = ox - (rc.mag_size / 2.0); @@ -156,7 +155,6 @@ magnify(struct output *output, struct wlr_buffer *output_buffer, struct wlr_box }; struct wlr_render_rect_options bg_opts = { .box = border_box, - /* TODO: make this a rc. setting */ .color = (struct wlr_render_color) { .r = rc.mag_border_col.r / 255.0, .g = rc.mag_border_col.g / 255.0, @@ -188,8 +186,7 @@ magnify(struct output *output, struct wlr_buffer *output_buffer, struct wlr_box }, .alpha = NULL, .clip = NULL, - //.filter_mode = WLR_SCALE_FILTER_NEAREST, - .filter_mode = WLR_SCALE_FILTER_BILINEAR, + .filter_mode = rc.mag_filter ? WLR_SCALE_FILTER_BILINEAR : WLR_SCALE_FILTER_NEAREST, }; wlr_render_pass_add_texture(tmp_render_pass, &opts); if (!wlr_render_pass_submit(tmp_render_pass)) { diff --git a/src/config/rcxml.c b/src/config/rcxml.c index 370c5c49..82d4c64b 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -1056,6 +1056,8 @@ entry(xmlNode *node, char *nodename, char *content) &rc.mag_border_col.b); } else if (!strcasecmp(nodename, "borderWidth.magnifier")) { rc.mag_border_width = atoi(content); + } else if (!strcasecmp(nodename, "useFilter.magnifier")) { + set_bool(content, &rc.mag_filter); } } @@ -1267,6 +1269,7 @@ rcxml_init(void) rc.mag_border_col.g = 0; rc.mag_border_col.b = 0; rc.mag_border_width = 1; + rc.mag_filter = true; } static void