pixman-renderer: move code to draw_view_translated()

Move code from draw_view() into a new function draw_view_translated().
This new function is correct only if
view_transformation_is_translation().

The test for view->alpha is moved into draw_view_translated() too, so we
don't need to pass the pixman_op from draw_view(). The non-translation
path is already using PIXMAN_OP_OVER, so it does not care about the
alpha.

v2: Fixed commit message.

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>
This commit is contained in:
Pekka Paalanen 2015-03-05 12:57:35 +02:00
parent 11af0d9ea7
commit ccf99ce11a
1 changed files with 51 additions and 34 deletions

View File

@ -283,6 +283,54 @@ repaint_region(struct weston_view *ev, struct weston_output *output,
pixman_image_set_clip_region32 (po->shadow_image, NULL);
}
static void
draw_view_translated(struct weston_view *view, struct weston_output *output,
pixman_region32_t *repaint_global)
{
struct weston_surface *surface = view->surface;
/* non-opaque region in surface coordinates: */
pixman_region32_t surface_blend;
/* region to be painted in output coordinates: */
pixman_region32_t repaint_output;
pixman_region32_init(&repaint_output);
/* Blended region is whole surface minus opaque region,
* unless surface alpha forces us to blend all.
*/
pixman_region32_init_rect(&surface_blend, 0, 0,
surface->width, surface->height);
if (!(view->alpha < 1.0)) {
pixman_region32_subtract(&surface_blend, &surface_blend,
&surface->opaque);
if (pixman_region32_not_empty(&surface->opaque)) {
region_intersect_only_translation(&repaint_output,
repaint_global,
&surface->opaque,
view);
region_global_to_output(output, &repaint_output);
repaint_region(view, output, &repaint_output,
PIXMAN_OP_SRC);
}
}
if (pixman_region32_not_empty(&surface_blend)) {
region_intersect_only_translation(&repaint_output,
repaint_global,
&surface_blend, view);
region_global_to_output(output, &repaint_output);
repaint_region(view, output, &repaint_output,
PIXMAN_OP_OVER);
}
pixman_region32_fini(&surface_blend);
pixman_region32_fini(&repaint_output);
}
static void
draw_view(struct weston_view *ev, struct weston_output *output,
pixman_region32_t *damage) /* in global coordinates */
@ -291,9 +339,6 @@ draw_view(struct weston_view *ev, struct weston_output *output,
struct pixman_surface_state *ps = get_surface_state(ev->surface);
/* repaint bounding region in global coordinates: */
pixman_region32_t repaint;
/* non-opaque region in surface coordinates: */
pixman_region32_t surface_blend;
pixman_region32_t repaint_output;
/* No buffer attached */
if (!ps->image)
@ -313,41 +358,13 @@ draw_view(struct weston_view *ev, struct weston_output *output,
}
/* TODO: Implement repaint_region_complex() using pixman_composite_trapezoids() */
if (ev->alpha != 1.0 || !view_transformation_is_translation(ev)) {
if (view_transformation_is_translation(ev)) {
draw_view_translated(ev, output, &repaint);
} else {
region_global_to_output(output, &repaint);
repaint_region(ev, output, &repaint, PIXMAN_OP_OVER);
} else {
pixman_region32_init(&repaint_output);
/* blended region is whole surface minus opaque region: */
pixman_region32_init_rect(&surface_blend, 0, 0,
ev->surface->width, ev->surface->height);
pixman_region32_subtract(&surface_blend, &surface_blend, &ev->surface->opaque);
if (pixman_region32_not_empty(&ev->surface->opaque)) {
region_intersect_only_translation(&repaint_output,
&repaint,
&ev->surface->opaque,
ev);
region_global_to_output(output, &repaint_output);
repaint_region(ev, output, &repaint_output,
PIXMAN_OP_SRC);
}
if (pixman_region32_not_empty(&surface_blend)) {
region_intersect_only_translation(&repaint_output,
&repaint,
&surface_blend,
ev);
region_global_to_output(output, &repaint_output);
repaint_region(ev, output, &repaint_output,
PIXMAN_OP_OVER);
}
pixman_region32_fini(&surface_blend);
pixman_region32_fini(&repaint_output);
}
out:
pixman_region32_fini(&repaint);
}