From fb20fe9b0347f6d4c9e3c1aec25faed231861c8a Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Thu, 27 Jan 2022 11:31:26 -0600 Subject: [PATCH] compositor: Cache filtering decision in paint node Instead of basing this on simple checks, we can test the matrix. This should result in more opportunistically picking fast nearest neighbour filtering when it won't result in visible distortion. For now we only use this in the gl renderer, as paint nodes aren't plumbed into the pixman renderer yet. Signed-off-by: Derek Foreman --- libweston/compositor.c | 16 +++++++++++++++- libweston/libweston-internal.h | 2 ++ libweston/renderer-gl/gl-renderer.c | 3 +-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/libweston/compositor.c b/libweston/compositor.c index 6fbe3c626..da0a25743 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -104,6 +104,16 @@ weston_compositor_build_view_list(struct weston_compositor *compositor, static char * weston_output_create_heads_string(struct weston_output *output); +static void +paint_node_update(struct weston_paint_node *pnode) +{ + struct weston_matrix tmp_matrix; + + weston_view_buffer_to_output_matrix(pnode->view, pnode->output, + &tmp_matrix); + pnode->needs_filtering = weston_matrix_needs_filtering(&tmp_matrix); +} + static struct weston_paint_node * weston_paint_node_create(struct weston_surface *surface, struct weston_view *view, @@ -144,6 +154,8 @@ weston_paint_node_create(struct weston_surface *surface, wl_list_init(&pnode->z_order_link); + paint_node_update(pnode); + return pnode; } @@ -2781,8 +2793,10 @@ view_ensure_paint_node(struct weston_view *view, struct weston_output *output) return NULL; pnode = weston_view_find_paint_node(view, output); - if (pnode) + if (pnode) { + paint_node_update(pnode); return pnode; + } return weston_paint_node_create(view->surface, view, output); } diff --git a/libweston/libweston-internal.h b/libweston/libweston-internal.h index c0bb2d771..34feaf5d0 100644 --- a/libweston/libweston-internal.h +++ b/libweston/libweston-internal.h @@ -472,6 +472,8 @@ struct weston_paint_node { /* Mutable members: */ + bool needs_filtering; + /* struct weston_output::paint_node_z_order_list */ struct wl_list z_order_link; diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c index 861f1c768..adbcf9d3d 100644 --- a/libweston/renderer-gl/gl-renderer.c +++ b/libweston/renderer-gl/gl-renderer.c @@ -1032,8 +1032,7 @@ draw_paint_node(struct weston_paint_node *pnode, glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - if (pnode->view->transform.enabled || - pnode->output->current_scale != pnode->surface->buffer_viewport.buffer.scale) + if (pnode->needs_filtering) filter = GL_LINEAR; else filter = GL_NEAREST;