pixman-renderer: refactor transformation computation
authorPekka Paalanen <pekka.paalanen@collabora.co.uk>
Wed, 4 Mar 2015 12:18:39 +0000 (14:18 +0200)
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>
Wed, 11 Mar 2015 10:27:25 +0000 (12:27 +0200)
Move the code computing the end-to-end transformation from
repaint_region() into a new function
pixman_renderer_compute_transform().

The code itself is not modified.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/pixman-renderer.c

index c7f3a9f33afc352b41f0307f5dcf547b5a1d0db4..8fd50e3d13fab4f3ed7ca190d05868febe374f31 100644 (file)
@@ -156,6 +156,30 @@ weston_matrix_to_pixman_transform(pixman_transform_t *pt,
        pt->matrix[2][2] = pixman_double_to_fixed(wm->d[15]);
 }
 
+static void
+pixman_renderer_compute_transform(pixman_transform_t *transform_out,
+                                 struct weston_view *ev,
+                                 struct weston_output *output)
+{
+       struct weston_matrix matrix;
+
+       /* Set up the source transformation based on the surface
+          position, the output position/transform/scale and the client
+          specified buffer transform/scale */
+       weston_matrix_invert(&matrix, &output->matrix);
+
+       if (ev->transform.enabled) {
+               weston_matrix_multiply(&matrix, &ev->transform.inverse);
+       } else {
+               weston_matrix_translate(&matrix,
+                                       -ev->geometry.x, -ev->geometry.y, 0);
+       }
+
+       weston_matrix_multiply(&matrix, &ev->surface->surface_to_buffer_matrix);
+
+       weston_matrix_to_pixman_transform(transform_out, &matrix);
+}
+
 static void
 repaint_region(struct weston_view *ev, struct weston_output *output,
               pixman_region32_t *region, pixman_region32_t *surf_region,
@@ -169,7 +193,6 @@ repaint_region(struct weston_view *ev, struct weston_output *output,
        pixman_region32_t final_region;
        float view_x, view_y;
        pixman_transform_t transform;
-       struct weston_matrix matrix;
        pixman_image_t *mask_image;
        pixman_color_t mask = { 0, };
 
@@ -203,21 +226,7 @@ repaint_region(struct weston_view *ev, struct weston_output *output,
        /* And clip to it */
        pixman_image_set_clip_region32 (po->shadow_image, &final_region);
 
-       /* Set up the source transformation based on the surface
-          position, the output position/transform/scale and the client
-          specified buffer transform/scale */
-       weston_matrix_invert(&matrix, &output->matrix);
-
-       if (ev->transform.enabled) {
-               weston_matrix_multiply(&matrix, &ev->transform.inverse);
-       } else {
-               weston_matrix_translate(&matrix,
-                                       -ev->geometry.x, -ev->geometry.y, 0);
-       }
-
-       weston_matrix_multiply(&matrix, &ev->surface->surface_to_buffer_matrix);
-
-       weston_matrix_to_pixman_transform(&transform, &matrix);
+       pixman_renderer_compute_transform(&transform, ev, output);
        pixman_image_set_transform(ps->image, &transform);
 
        if (ev->transform.enabled || output->current_scale != vp->buffer.scale)