From 946bb51a2abf92fdb122c36792e1dfb414c94653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Molinari?= Date: Thu, 31 Aug 2023 12:20:17 +0200 Subject: [PATCH] gl-renderer: Test axis alignment once per paint node MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The axis alignment test is part of the damage transformation routine executed for each damage rect. Extract it in order to compute it once per paint node. Signed-off-by: Loïc Molinari --- clients/cliptest.c | 24 +++++++++++++----------- libweston/renderer-gl/gl-renderer.c | 13 +++++++++---- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/clients/cliptest.c b/clients/cliptest.c index 4981d1db..d28d2bd8 100644 --- a/clients/cliptest.c +++ b/clients/cliptest.c @@ -112,7 +112,7 @@ weston_coord_global_to_surface(struct weston_view *view, struct weston_coord_glo static void global_to_surface(pixman_box32_t *rect, struct weston_view *ev, - struct clipper_vertex polygon[4], bool *axis_aligned) + struct clipper_vertex polygon[4]) { struct weston_coord_global rect_g[4] = { { .c = weston_coord(rect->x1, rect->y1) }, @@ -128,9 +128,13 @@ global_to_surface(pixman_box32_t *rect, struct weston_view *ev, polygon[i].x = (float)rect_s.x; polygon[i].y = (float)rect_s.y; } +} - *axis_aligned = !ev->transform.enabled || - (ev->transform.matrix.type < WESTON_MATRIX_TRANSFORM_ROTATE); +static bool +node_axis_aligned(const struct weston_view *view) +{ + return !view->transform.enabled || + (view->transform.matrix.type < WESTON_MATRIX_TRANSFORM_ROTATE); } /* ---------------------- copied ends -----------------------*/ @@ -279,12 +283,11 @@ redraw_handler(struct widget *widget, void *data) cairo_surface_t *surface; struct clipper_quad quad; struct clipper_vertex transformed_v[4], v[8]; - bool axis_aligned; int n; - global_to_surface(&g->quad, &cliptest->view, transformed_v, - &axis_aligned); - clipper_quad_init(&quad, transformed_v, axis_aligned); + global_to_surface(&g->quad, &cliptest->view, transformed_v); + clipper_quad_init(&quad, transformed_v, + node_axis_aligned(&cliptest->view)); n = clipper_quad_clip_box32(&quad, &g->surf, v); widget_get_allocation(cliptest->widget, &allocation); @@ -554,7 +557,6 @@ benchmark(void) struct geometry geom; struct clipper_quad quad; struct clipper_vertex transformed_v[4], v[8]; - bool axis_aligned; int i; double t; const int N = 1000000; @@ -579,9 +581,9 @@ benchmark(void) reset_timer(); for (i = 0; i < N; i++) { geometry_set_phi(&geom, (float)i / 360.0f); - global_to_surface(&geom.quad, &view, transformed_v, - &axis_aligned); - clipper_quad_init(&quad, transformed_v, axis_aligned); + global_to_surface(&geom.quad, &view, transformed_v); + clipper_quad_init(&quad, transformed_v, + node_axis_aligned(&view)); clipper_quad_clip_box32(&quad, &geom.surf, v); } t = read_timer(); diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c index c02567df..1bc6e497 100644 --- a/libweston/renderer-gl/gl-renderer.c +++ b/libweston/renderer-gl/gl-renderer.c @@ -1225,7 +1225,7 @@ compress_bands(pixman_box32_t *inrects, int nrects, pixman_box32_t **outrects) static void global_to_surface(pixman_box32_t *rect, struct weston_view *ev, - struct clipper_vertex polygon[4], bool *axis_aligned) + struct clipper_vertex polygon[4]) { struct weston_coord_global rect_g[4] = { { .c = weston_coord(rect->x1, rect->y1) }, @@ -1241,9 +1241,13 @@ global_to_surface(pixman_box32_t *rect, struct weston_view *ev, polygon[i].x = (float)rect_s.x; polygon[i].y = (float)rect_s.y; } +} - *axis_aligned = !ev->transform.enabled || - (ev->transform.matrix.type < WESTON_MATRIX_TRANSFORM_ROTATE); +static bool +node_axis_aligned(const struct weston_view *view) +{ + return !view->transform.enabled || + (view->transform.matrix.type < WESTON_MATRIX_TRANSFORM_ROTATE); } /* Transform damage 'region' in global coordinates to damage 'quads' in surface @@ -1276,8 +1280,9 @@ transform_damage(const struct weston_paint_node *pnode, *nquads = nrects; view = pnode->view; + axis_aligned = node_axis_aligned(view); for (i = 0; i < nrects; i++) { - global_to_surface(&rects[i], view, polygon, &axis_aligned); + global_to_surface(&rects[i], view, polygon); clipper_quad_init(&quads_alloc[i], polygon, axis_aligned); }