compositor: weston_surface_assign_output() to use bounding box

Use the bounding box to compute an approximation of which output
contains most of the surface.

Move the region32 init outside the loop, and fini it, too.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
This commit is contained in:
Pekka Paalanen
2012-01-26 11:34:16 +02:00
parent 3bfcd4d907
commit 45f3e405c6
+6 -5
View File
@@ -1037,14 +1037,14 @@ weston_surface_assign_output(struct weston_surface *es)
uint32_t max, area; uint32_t max, area;
pixman_box32_t *e; pixman_box32_t *e;
weston_surface_update_transform(es);
new_output = NULL; new_output = NULL;
max = 0; max = 0;
pixman_region32_init(&region);
wl_list_for_each(output, &ec->output_list, link) { wl_list_for_each(output, &ec->output_list, link) {
pixman_region32_init_rect(&region, pixman_region32_intersect(&region, &es->transform.boundingbox,
es->geometry.x, es->geometry.y, &output->region);
es->geometry.width,
es->geometry.height);
pixman_region32_intersect(&region, &region, &output->region);
e = pixman_region32_extents(&region); e = pixman_region32_extents(&region);
area = (e->x2 - e->x1) * (e->y2 - e->y1); area = (e->x2 - e->x1) * (e->y2 - e->y1);
@@ -1054,6 +1054,7 @@ weston_surface_assign_output(struct weston_surface *es)
max = area; max = area;
} }
} }
pixman_region32_fini(&region);
es->output = new_output; es->output = new_output;
if (!wl_list_empty(&es->frame_callback_list)) { if (!wl_list_empty(&es->frame_callback_list)) {