[PATCH weston 2/8] pixman-renderer: put transformation computation into function

Pekka Paalanen ppaalanen at gmail.com
Fri Mar 6 03:03:57 PST 2015


From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

Move the long piece of code computing the end-to-end transformation from
repaint_region() into a new function
pixman_renderer_compute_transform().

The code itself it not modified.

Because the number of moved lines is so big, git-diff will show the
changes in the context instead of the moved lines.

Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
 src/pixman-renderer.c | 94 +++++++++++++++++++++++++++++----------------------
 1 file changed, 53 insertions(+), 41 deletions(-)

diff --git a/src/pixman-renderer.c b/src/pixman-renderer.c
index 09e8c0e..2769168 100644
--- a/src/pixman-renderer.c
+++ b/src/pixman-renderer.c
@@ -169,51 +169,13 @@ transform_apply_viewport(pixman_transform_t *transform,
 }
 
 static void
-repaint_region(struct weston_view *ev, struct weston_output *output,
-	       pixman_region32_t *region, pixman_region32_t *surf_region,
-	       pixman_op_t pixman_op)
+pixman_renderer_compute_transform(pixman_transform_t *transform_out,
+				  struct weston_view *ev,
+				  struct weston_output *output)
 {
-	struct pixman_renderer *pr =
-		(struct pixman_renderer *) output->compositor->renderer;
-	struct pixman_surface_state *ps = get_surface_state(ev->surface);
-	struct pixman_output_state *po = get_output_state(output);
 	struct weston_buffer_viewport *vp = &ev->surface->buffer_viewport;
-	pixman_region32_t final_region;
-	float view_x, view_y;
 	pixman_transform_t transform;
 	pixman_fixed_t fw, fh;
-	pixman_image_t *mask_image;
-	pixman_color_t mask = { 0, };
-
-	/* The final region to be painted is the intersection of
-	 * 'region' and 'surf_region'. However, 'region' is in the global
-	 * coordinates, and 'surf_region' is in the surface-local
-	 * coordinates
-	 */
-	pixman_region32_init(&final_region);
-	if (surf_region) {
-		pixman_region32_copy(&final_region, surf_region);
-
-		/* Convert from surface to global coordinates */
-		if (!ev->transform.enabled) {
-			pixman_region32_translate(&final_region, ev->geometry.x, ev->geometry.y);
-		} else {
-			weston_view_to_global_float(ev, 0, 0, &view_x, &view_y);
-			pixman_region32_translate(&final_region, (int)view_x, (int)view_y);
-		}
-
-		/* We need to paint the intersection */
-		pixman_region32_intersect(&final_region, &final_region, region);
-	} else {
-		/* If there is no surface region, just use the global region */
-		pixman_region32_copy(&final_region, region);
-	}
-
-	/* Convert from global to output coord */
-	region_global_to_output(output, &final_region);
-
-	/* 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
@@ -333,6 +295,56 @@ repaint_region(struct weston_view *ev, struct weston_output *output,
 			       pixman_double_to_fixed(vp->buffer.scale),
 			       pixman_double_to_fixed(vp->buffer.scale));
 
+	*transform_out = transform;
+}
+
+static void
+repaint_region(struct weston_view *ev, struct weston_output *output,
+	       pixman_region32_t *region, pixman_region32_t *surf_region,
+	       pixman_op_t pixman_op)
+{
+	struct pixman_renderer *pr =
+		(struct pixman_renderer *) output->compositor->renderer;
+	struct pixman_surface_state *ps = get_surface_state(ev->surface);
+	struct pixman_output_state *po = get_output_state(output);
+	struct weston_buffer_viewport *vp = &ev->surface->buffer_viewport;
+	pixman_region32_t final_region;
+	float view_x, view_y;
+	pixman_transform_t transform;
+	pixman_image_t *mask_image;
+	pixman_color_t mask = { 0, };
+
+	/* The final region to be painted is the intersection of
+	 * 'region' and 'surf_region'. However, 'region' is in the global
+	 * coordinates, and 'surf_region' is in the surface-local
+	 * coordinates
+	 */
+	pixman_region32_init(&final_region);
+	if (surf_region) {
+		pixman_region32_copy(&final_region, surf_region);
+
+		/* Convert from surface to global coordinates */
+		if (!ev->transform.enabled) {
+			pixman_region32_translate(&final_region, ev->geometry.x, ev->geometry.y);
+		} else {
+			weston_view_to_global_float(ev, 0, 0, &view_x, &view_y);
+			pixman_region32_translate(&final_region, (int)view_x, (int)view_y);
+		}
+
+		/* We need to paint the intersection */
+		pixman_region32_intersect(&final_region, &final_region, region);
+	} else {
+		/* If there is no surface region, just use the global region */
+		pixman_region32_copy(&final_region, region);
+	}
+
+	/* Convert from global to output coord */
+	region_global_to_output(output, &final_region);
+
+	/* And clip to it */
+	pixman_image_set_clip_region32 (po->shadow_image, &final_region);
+
+	pixman_renderer_compute_transform(&transform, ev, output);
 	pixman_image_set_transform(ps->image, &transform);
 
 	if (ev->transform.enabled || output->current_scale != vp->buffer.scale)
-- 
2.0.5



More information about the wayland-devel mailing list