From 6ac2afc0d7d8d51d4085767b901667393c11061b Mon Sep 17 00:00:00 2001 From: Pablo De La Garza Date: Thu, 23 Mar 2017 16:05:02 -0700 Subject: [PATCH] xrandr: Add a "--filter" flag Flag can be set to "nearest" or "bilinear" Signed-off-by: Pablo De La Garza [aplattner@nvidia.com: Fixed style and whitespace] Signed-off-by: Aaron Plattner --- xrandr.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/xrandr.c b/xrandr.c index 2aad946..2d4cb72 100644 --- a/xrandr.c +++ b/xrandr.c @@ -54,6 +54,11 @@ static Bool automatic = False; static Bool properties = False; static Bool grab_server = True; static Bool no_primary = False; +static int filter_type = -1; + +static const char *filter_names[2] = { + "bilinear", + "nearest"}; static const char *direction[5] = { "normal", @@ -135,6 +140,7 @@ usage(void) " --scale x\n" " --scale-from x\n" " --transform ,,,,,,,,\n" + " --filter nearest,bilinear\n" " --off\n" " --crtc \n" " --panning x[++[/x++[////]]]\n" @@ -285,6 +291,7 @@ typedef enum _changes { changes_panning = (1 << 10), changes_gamma = (1 << 11), changes_primary = (1 << 12), + changes_filter = (1 << 13), } changes_t; typedef enum _name_kind { @@ -1311,6 +1318,10 @@ set_output_info (output_t *output, RROutput xid, XRROutputInfo *output_info) output->transform.params = NULL; } } + if (output->changes & changes_filter) + { + output->transform.filter = filter_names[filter_type]; + } /* set primary */ if (!(output->changes & changes_primary)) @@ -2808,6 +2819,28 @@ main (int argc, char **argv) action_requested = True; continue; } + if (!strcmp("--filter", argv[i])) { + int t; + + if (!config_output) argerr ("%s must be used after --output\n", argv[i]); + if (++i >= argc) argerr("%s requires an argument\n", argv[i-1]); + + filter_type = -1; + for (t = 0; t < sizeof(filter_names) / sizeof(filter_names[0]); t++) + { + if (!strcmp(filter_names[t], argv[i])) + { + filter_type = t; + break; + } + } + + if (filter_type == -1) argerr("Bad argument: %s, for a filter\n", argv[i]); + + config_output->changes |= changes_filter; + action_requested = True; + continue; + } if (!strcmp ("--crtc", argv[i])) { if (!config_output) argerr ("%s must be used after --output\n", argv[i]); if (++i >= argc) argerr ("%s requires an argument\n", argv[i-1]); -- 2.32.0.93.g670b81a890