pixman-renderer: refactor into region_intersect_only_translation()

Move code into a new helper function. No changes.

v3: Add assert, and reorder this patch with adding
view_transformation_is_translation().

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>
dev
Pekka Paalanen 10 years ago
parent 23d4af5969
commit f75b6bbfec
  1. 34
      src/pixman-renderer.c

@ -26,6 +26,7 @@
#include <errno.h>
#include <stdlib.h>
#include <assert.h>
#include "pixman-renderer.h"
@ -192,6 +193,24 @@ view_transformation_is_translation(struct weston_view *view)
return false;
}
static void
region_intersect_only_translation(pixman_region32_t *result_global,
pixman_region32_t *global,
pixman_region32_t *surf,
struct weston_view *view)
{
float view_x, view_y;
assert(view_transformation_is_translation(view));
/* Convert from surface to global coordinates */
pixman_region32_copy(result_global, surf);
weston_view_to_global_float(view, 0, 0, &view_x, &view_y);
pixman_region32_translate(result_global, (int)view_x, (int)view_y);
pixman_region32_intersect(result_global, result_global, global);
}
static void
repaint_region(struct weston_view *ev, struct weston_output *output,
pixman_region32_t *region, pixman_region32_t *surf_region,
@ -203,7 +222,6 @@ repaint_region(struct weston_view *ev, struct weston_output *output,
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, };
@ -215,18 +233,8 @@ repaint_region(struct weston_view *ev, struct weston_output *output,
*/
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);
region_intersect_only_translation(&final_region, region,
surf_region, ev);
} else {
/* If there is no surface region, just use the global region */
pixman_region32_copy(&final_region, region);

Loading…
Cancel
Save