pixman-renderer: share region_global_to_output()

Converting a region from global coordinates to output pixel coordinates
will become useful in GL-renderer soon, so move this function to be
shared. It is tricky to reinvent.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
dev
Pekka Paalanen 4 years ago
parent b5265af620
commit 0692079aae
  1. 4
      libweston/backend.h
  2. 30
      libweston/compositor.c
  3. 23
      libweston/pixman-renderer.c

@ -170,6 +170,10 @@ weston_output_transform_coordinate(struct weston_output *output,
double device_x, double device_y, double device_x, double device_y,
double *x, double *y); double *x, double *y);
void
weston_output_region_from_global(struct weston_output *output,
pixman_region32_t *region);
/* weston_seat */ /* weston_seat */
void void

@ -5844,6 +5844,36 @@ weston_compositor_reflow_outputs(struct weston_compositor *compositor,
} }
} }
/** Transform a region in-place from global to output coordinates
*
* \param output The output that defines the transformation.
* \param region The region to be transformed in-place.
*
* This takes a region in the global coordinate system, and takes into account
* output position, transform and scale, and the zoom, and converts the region
* into output pixel coordinates in the framebuffer.
*
* Uses floating-point operations if zoom is active, which may round to expand
* the region.
*
* \internal
* \ingroup output
*/
WL_EXPORT void
weston_output_region_from_global(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);
}
}
static void static void
weston_output_update_matrix(struct weston_output *output) weston_output_update_matrix(struct weston_output *output)
{ {

@ -125,20 +125,6 @@ pixman_renderer_read_pixels(struct weston_output *output,
return 0; return 0;
} }
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);
}
}
#define D2F(v) pixman_double_to_fixed((double)v) #define D2F(v) pixman_double_to_fixed((double)v)
static void static void
@ -426,7 +412,8 @@ draw_view_translated(struct weston_view *view, struct weston_output *output,
repaint_global, repaint_global,
&surface->opaque, &surface->opaque,
view); view);
region_global_to_output(output, &repaint_output); weston_output_region_from_global(output,
&repaint_output);
repaint_region(view, output, &repaint_output, NULL, repaint_region(view, output, &repaint_output, NULL,
PIXMAN_OP_SRC); PIXMAN_OP_SRC);
@ -437,7 +424,7 @@ draw_view_translated(struct weston_view *view, struct weston_output *output,
region_intersect_only_translation(&repaint_output, region_intersect_only_translation(&repaint_output,
repaint_global, repaint_global,
&surface_blend, view); &surface_blend, view);
region_global_to_output(output, &repaint_output); weston_output_region_from_global(output, &repaint_output);
repaint_region(view, output, &repaint_output, NULL, repaint_region(view, output, &repaint_output, NULL,
PIXMAN_OP_OVER); PIXMAN_OP_OVER);
@ -473,7 +460,7 @@ draw_view_source_clipped(struct weston_view *view,
pixman_region32_init(&repaint_output); pixman_region32_init(&repaint_output);
pixman_region32_copy(&repaint_output, repaint_global); pixman_region32_copy(&repaint_output, repaint_global);
region_global_to_output(output, &repaint_output); weston_output_region_from_global(output, &repaint_output);
repaint_region(view, output, &repaint_output, &buffer_region, repaint_region(view, output, &repaint_output, &buffer_region,
PIXMAN_OP_OVER); PIXMAN_OP_OVER);
@ -546,7 +533,7 @@ copy_to_hw_buffer(struct weston_output *output, pixman_region32_t *region)
pixman_region32_init(&output_region); pixman_region32_init(&output_region);
pixman_region32_copy(&output_region, region); pixman_region32_copy(&output_region, region);
region_global_to_output(output, &output_region); weston_output_region_from_global(output, &output_region);
pixman_image_set_clip_region32 (po->hw_buffer, &output_region); pixman_image_set_clip_region32 (po->hw_buffer, &output_region);
pixman_region32_fini(&output_region); pixman_region32_fini(&output_region);

Loading…
Cancel
Save