render/pixman: half-pixel shift to match GPUs

Add a half-pixel shift in the pixman renderer to match the results given
by GPU-based renderers when scaling.
This commit is contained in:
David Turner 2024-04-30 13:54:56 +01:00 committed by Simon Ser
parent e08d52bbc6
commit 77006e5565

View File

@ -155,6 +155,13 @@ static void render_pass_add_texture(struct wlr_render_pass *wlr_pass,
pixman_transform_translate(&transform, NULL,
pixman_int_to_fixed(src_box.x), pixman_int_to_fixed(src_box.y));
// GPUs have a half pixel shift compared to pixman because GPU coordinates refer
// to the centre of each pixel rather than its top-left. This makes no difference
// when there's no transforms as we still copy the correct pixel across. But when
// we do scaling it does make a visible difference, so account for it here.
pixman_transform_translate(&transform, NULL,
-pixman_double_to_fixed(0.5), -pixman_double_to_fixed(0.5));
pixman_image_set_transform(texture->image, &transform);
switch (options->filter_mode) {