compositor: Remove weston_transformed_region

Replace all uses of weston_transform_region with
weston_matrix_transform_region, then remove the function completely.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2022-01-19 17:01:36 -06:00 committed by Pekka Paalanen
parent df96fd435c
commit c12ec7a2e5
8 changed files with 18 additions and 159 deletions

View File

@ -862,11 +862,11 @@ shared_output_repainted(struct wl_listener *listener, void *data)
wl_list_for_each(sb, &so->shm.buffers, link)
pixman_region32_union(&sb->damage, &sb->damage, &damage);
/* Translate back to global space for transform_region */
pixman_region32_translate(&damage, so->output->x, so->output->y);
/* Transform to buffer coordinates */
weston_transformed_region(so->output->width, so->output->height,
so->output->transform,
so->output->current_scale,
&damage, &damage);
weston_matrix_transform_region(&damage, &so->output->matrix, &damage);
if (shared_output_ensure_tmp_data(so, &damage) < 0)
goto err_pixman_init;

View File

@ -421,16 +421,10 @@ drm_output_render(struct drm_output_state *state, pixman_region32_t *damage)
return;
pixman_region32_init(&scanout_damage);
pixman_region32_copy(&scanout_damage, damage);
pixman_region32_translate(&scanout_damage,
-output->base.x, -output->base.y);
weston_transformed_region(output->base.width,
output->base.height,
output->base.transform,
output->base.current_scale,
&scanout_damage,
&scanout_damage);
weston_matrix_transform_region(&scanout_damage,
&output->base.matrix,
damage);
assert(scanout_state->damage_blob_id == 0);

View File

@ -615,15 +615,7 @@ wayland_shm_buffer_attach(struct wayland_shm_buffer *sb)
int i, n;
pixman_region32_init(&damage);
pixman_region32_copy(&damage, &sb->damage);
pixman_region32_translate(&damage, -sb->output->base.x,
-sb->output->base.y);
weston_transformed_region(sb->output->base.width,
sb->output->base.height,
sb->output->base.transform,
sb->output->base.current_scale,
&damage, &damage);
weston_matrix_transform_region(&damage, &sb->output->base.matrix, &sb->damage);
if (sb->output->frame) {
frame_interior(sb->output->frame, &ix, &iy, &iwidth, &iheight);

View File

@ -466,13 +466,9 @@ set_clip_for_output(struct weston_output *output_base, pixman_region32_t *region
b = to_x11_backend(ec);
pixman_region32_init(&transformed_region);
pixman_region32_copy(&transformed_region, region);
pixman_region32_translate(&transformed_region,
-output_base->x, -output_base->y);
weston_transformed_region(output_base->width, output_base->height,
output_base->transform,
output_base->current_scale,
&transformed_region, &transformed_region);
weston_matrix_transform_region(&transformed_region,
&output_base->matrix,
region);
rects = pixman_region32_rectangles(&transformed_region, &nrects);
output_rects = calloc(nrects, sizeof(xcb_rectangle_t));

View File

@ -846,116 +846,6 @@ weston_matrix_transform_region(pixman_region32_t *dest,
free(dest_rects);
}
/** Transform a region to buffer coordinates
*
* \param width Surface width.
* \param height Surface height.
* \param transform Buffer transform.
* \param scale Buffer scale.
* \param[in] src Region in surface coordinates.
* \param[out] dest Resulting region in buffer coordinates.
*
* Converts the given surface-local region to buffer coordinates
* according to the given buffer transform and scale.
* This ignores wp_viewport.
*
* The given width and height must be the result of inverse scaled and
* inverse transformed buffer size.
*
* src and dest are allowed to point to the same memory for in-place conversion.
*/
WL_EXPORT void
weston_transformed_region(int width, int height,
enum wl_output_transform transform,
int32_t scale,
pixman_region32_t *src, pixman_region32_t *dest)
{
pixman_box32_t *src_rects, *dest_rects;
int nrects, i;
if (transform == WL_OUTPUT_TRANSFORM_NORMAL && scale == 1) {
if (src != dest)
pixman_region32_copy(dest, src);
return;
}
src_rects = pixman_region32_rectangles(src, &nrects);
dest_rects = malloc(nrects * sizeof(*dest_rects));
if (!dest_rects)
return;
if (transform == WL_OUTPUT_TRANSFORM_NORMAL) {
memcpy(dest_rects, src_rects, nrects * sizeof(*dest_rects));
} else {
for (i = 0; i < nrects; i++) {
switch (transform) {
default:
case WL_OUTPUT_TRANSFORM_NORMAL:
dest_rects[i].x1 = src_rects[i].x1;
dest_rects[i].y1 = src_rects[i].y1;
dest_rects[i].x2 = src_rects[i].x2;
dest_rects[i].y2 = src_rects[i].y2;
break;
case WL_OUTPUT_TRANSFORM_90:
dest_rects[i].x1 = src_rects[i].y1;
dest_rects[i].y1 = width - src_rects[i].x2;
dest_rects[i].x2 = src_rects[i].y2;
dest_rects[i].y2 = width - src_rects[i].x1;
break;
case WL_OUTPUT_TRANSFORM_180:
dest_rects[i].x1 = width - src_rects[i].x2;
dest_rects[i].y1 = height - src_rects[i].y2;
dest_rects[i].x2 = width - src_rects[i].x1;
dest_rects[i].y2 = height - src_rects[i].y1;
break;
case WL_OUTPUT_TRANSFORM_270:
dest_rects[i].x1 = height - src_rects[i].y2;
dest_rects[i].y1 = src_rects[i].x1;
dest_rects[i].x2 = height - src_rects[i].y1;
dest_rects[i].y2 = src_rects[i].x2;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED:
dest_rects[i].x1 = width - src_rects[i].x2;
dest_rects[i].y1 = src_rects[i].y1;
dest_rects[i].x2 = width - src_rects[i].x1;
dest_rects[i].y2 = src_rects[i].y2;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
dest_rects[i].x1 = src_rects[i].y1;
dest_rects[i].y1 = src_rects[i].x1;
dest_rects[i].x2 = src_rects[i].y2;
dest_rects[i].y2 = src_rects[i].x2;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
dest_rects[i].x1 = src_rects[i].x1;
dest_rects[i].y1 = height - src_rects[i].y2;
dest_rects[i].x2 = src_rects[i].x2;
dest_rects[i].y2 = height - src_rects[i].y1;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
dest_rects[i].x1 = height - src_rects[i].y2;
dest_rects[i].y1 = width - src_rects[i].x2;
dest_rects[i].x2 = height - src_rects[i].y1;
dest_rects[i].y2 = width - src_rects[i].x1;
break;
}
}
}
if (scale != 1) {
for (i = 0; i < nrects; i++) {
dest_rects[i].x1 *= scale;
dest_rects[i].x2 *= scale;
dest_rects[i].y1 *= scale;
dest_rects[i].y2 *= scale;
}
}
pixman_region32_clear(dest);
pixman_region32_init_rects(dest, dest_rects, nrects);
free(dest_rects);
}
WL_EXPORT void
weston_surface_to_buffer_float(struct weston_surface *surface,
float sx, float sy, float *bx, float *by)
@ -6443,11 +6333,7 @@ WL_EXPORT void
weston_output_region_from_global(struct weston_output *output,
pixman_region32_t *region)
{
pixman_region32_translate(region, -output->x, -output->y);
weston_transformed_region(output->width, output->height,
output->transform,
output->current_scale,
region, region);
weston_matrix_transform_region(region, &output->matrix, region);
}
static void

View File

@ -347,11 +347,6 @@ weston_transformed_rect(int width, int height,
int32_t scale,
pixman_box32_t rect);
void
weston_transformed_region(int width, int height,
enum wl_output_transform transform,
int32_t scale,
pixman_region32_t *src, pixman_region32_t *dest);
void
weston_matrix_transform_region(pixman_region32_t *dest,
struct weston_matrix *matrix,
pixman_region32_t *src);

View File

@ -1447,12 +1447,9 @@ pixman_region_to_egl_y_invert(struct weston_output *output,
/* Translate from global to output co-ordinate space. */
pixman_region32_init(&transformed);
pixman_region32_copy(&transformed, global_region);
pixman_region32_translate(&transformed, -output->x, -output->y);
weston_transformed_region(output->width, output->height,
output->transform,
output->current_scale,
&transformed, &transformed);
weston_matrix_transform_region(&transformed,
&output->matrix,
global_region);
/* If we have borders drawn around the output, shift our output damage
* to account for borders being drawn around the outside, adding any

View File

@ -287,10 +287,9 @@ weston_recorder_frame_notify(struct wl_listener *listener, void *data)
pixman_region32_init(&damage);
pixman_region32_init(&transformed_damage);
pixman_region32_intersect(&damage, &output->region, data);
pixman_region32_translate(&damage, -output->x, -output->y);
weston_transformed_region(output->width, output->height,
output->transform, output->current_scale,
&damage, &transformed_damage);
weston_matrix_transform_region(&transformed_damage,
&output->matrix,
&damage);
pixman_region32_fini(&damage);
r = pixman_region32_rectangles(&transformed_damage, &n);