[xrandr] Select NearestNeighbour filtering for pixel exact scaling
Chris Wilson
chris at chris-wilson.co.uk
Mon Apr 4 16:11:11 UTC 2016
When using pixel-exact scaling from for example running a 3840x2160 monitor
at 1920x1080 half-resolution upscaling using a bilinear filter
introduces blur where none is expected.
References: https://bugs.freedesktop.org/show_bug.cgi?id=94816
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
xrandr.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/xrandr.c b/xrandr.c
index dcfdde0..b6b208c 100644
--- a/xrandr.c
+++ b/xrandr.c
@@ -1292,6 +1292,7 @@ set_output_info (output_t *output, RROutput xid, XRROutputInfo *output_info)
/* for --scale-from, figure out the mode size and compute the transform
* for the target framebuffer area */
if (output->scale_from_w > 0 && output->mode_info) {
+ XTransform *t = &output->transform.transform;
double sx = (double)output->scale_from_w /
output->mode_info->width;
double sy = (double)output->scale_from_h /
@@ -1300,10 +1301,10 @@ set_output_info (output_t *output, RROutput xid, XRROutputInfo *output_info)
printf("scaling %s by %lfx%lf\n", output->output.string, sx,
sy);
init_transform (&output->transform);
- output->transform.transform.matrix[0][0] = XDoubleToFixed (sx);
- output->transform.transform.matrix[1][1] = XDoubleToFixed (sy);
- output->transform.transform.matrix[2][2] = XDoubleToFixed (1.0);
- if (sx != 1 || sy != 1)
+ t->matrix[0][0] = XDoubleToFixed (sx);
+ t->matrix[1][1] = XDoubleToFixed (sy);
+ t->matrix[2][2] = XDoubleToFixed (1.0);
+ if ((t->matrix[0][0] | t->matrix[1][1]) & 0xffff)
output->transform.filter = "bilinear";
else
output->transform.filter = "nearest";
--
2.8.0.rc3
More information about the xorg-devel
mailing list