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 <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2022-01-27 11:31:26 -06:00
parent 021fdf4244
commit fb20fe9b03
3 changed files with 18 additions and 3 deletions

View File

@ -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);
}

View File

@ -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;

View File

@ -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;