[PATCH weston v2 11/20] compositor: Remove weston_transformed_region
Derek Foreman
derekf at osg.samsung.com
Thu Oct 16 08:55:29 PDT 2014
Replace all uses of weston_transform_region with
weston_matrix_transform_region, then remove the function completely.
---
src/compositor-wayland.c | 8 ++---
src/compositor-x11.c | 8 +----
src/compositor.c | 92 ------------------------------------------------
src/compositor.h | 6 ----
src/gl-renderer.c | 11 +++---
src/pixman-renderer.c | 10 +-----
src/screen-share.c | 8 ++---
src/screenshooter.c | 7 ++--
8 files changed, 19 insertions(+), 131 deletions(-)
diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index bf71a76..f571910 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -502,11 +502,9 @@ wayland_shm_buffer_attach(struct wayland_shm_buffer *sb)
int i, n;
pixman_region32_init(&damage);
- weston_transformed_region(sb->output->base.width,
- sb->output->base.height,
- sb->output->base.transform,
- sb->output->base.current_scale,
- &sb->damage, &damage);
+ pixman_region32_copy(&damage, &sb->damage);
+ pixman_region32_translate(&damage, sb->output->base.x, sb->output->base.y);
+ weston_matrix_transform_region(&damage, &sb->output->base.matrix, &damage);
if (sb->output->frame) {
frame_interior(sb->output->frame, &ix, &iy, &iwidth, &iheight);
diff --git a/src/compositor-x11.c b/src/compositor-x11.c
index 1baee29..971c718 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -374,13 +374,7 @@ set_clip_for_output(struct weston_output *output_base, pixman_region32_t *region
xcb_generic_error_t *err;
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));
diff --git a/src/compositor.c b/src/compositor.c
index b2b10dd..68fbd71 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -800,98 +800,6 @@ weston_matrix_transform_region(pixman_region32_t *dest,
}
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 = 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_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 = 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_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 = 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;
- 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 = 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;
- }
- }
- }
-
- 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)
{
diff --git a/src/compositor.h b/src/compositor.h
index 79b5190..4fdf4dc 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -1471,12 +1471,6 @@ void
weston_matrix_transform_region(pixman_region32_t *dest,
struct weston_matrix *matrix,
pixman_region32_t *src);
-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_load_module(const char *name, const char *entrypoint);
diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index 28b3b75..cfc1e88 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -924,10 +924,13 @@ gl_renderer_repaint_output(struct weston_output *output,
#ifdef EGL_EXT_swap_buffers_with_damage
if (gr->swap_buffers_with_damage) {
pixman_region32_init(&buffer_damage);
- weston_transformed_region(output->width, output->height,
- output->transform,
- output->current_scale,
- output_damage, &buffer_damage);
+ pixman_region32_copy(&buffer_damage, output_damage);
+ pixman_region32_translate(&buffer_damage,
+ output->x,
+ output->y);
+ weston_matrix_transform_region(&buffer_damage,
+ &output->matrix,
+ &buffer_damage);
if (output_has_borders(output)) {
pixman_region32_translate(&buffer_damage,
diff --git a/src/pixman-renderer.c b/src/pixman-renderer.c
index 9494142..2f54a64 100644
--- a/src/pixman-renderer.c
+++ b/src/pixman-renderer.c
@@ -130,15 +130,7 @@ pixman_renderer_read_pixels(struct weston_output *output,
static void
region_global_to_output(struct weston_output *output, pixman_region32_t *region)
{
- if (output->zoom.active) {
- weston_matrix_transform_region(region, &output->matrix, region);
- } else {
- 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);
}
#define D2F(v) pixman_double_to_fixed((double)v)
diff --git a/src/screen-share.c b/src/screen-share.c
index 524a0ca..ceb970c 100644
--- a/src/screen-share.c
+++ b/src/screen-share.c
@@ -790,11 +790,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);
+ /* put it back... */
+ 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);
width = so->output->current_mode->width;
height = so->output->current_mode->height;
diff --git a/src/screenshooter.c b/src/screenshooter.c
index cafbf10..469f19b 100644
--- a/src/screenshooter.c
+++ b/src/screenshooter.c
@@ -379,10 +379,9 @@ weston_recorder_frame_notify(struct wl_listener *listener, void *data)
pixman_region32_init(&transformed_damage);
pixman_region32_intersect(&damage, &output->region,
&output->previous_damage);
- 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);
--
2.1.1
More information about the wayland-devel
mailing list