gl-renderer: Test axis alignment once per paint node
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 <loic.molinari@collabora.com>
This commit is contained in:
parent
445e83c417
commit
946bb51a2a
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue