zoom: Use pixels instead of GL coordinates

Previously, the zoom functions used GL coordinates natively which doesn't
work with the new output matrix calculations.  This changes zoom to work in
pixel coordinates to match the new output matrix format.  This also cleans
up the math in the zoom code substantially.

This patch changes the meaning of weston_output_zoom::trans_x,trans_y,
and doing so probably breaks zoom on the rpi-renderer and all absolute
input devices. These problems are fixed by the following patches:

	rpi-renderer: minimal fix to zoom coordinates
	compositor: use weston_matrix_transform for
		weston_output_transform_coordinate

[Pekka: added a comment]
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
dev
Jason Ekstrand 11 years ago committed by Pekka Paalanen
parent fb23df7b35
commit 87535e24c2
  1. 41
      src/zoom.c

@ -73,18 +73,17 @@ zoom_area_center_from_pointer(struct weston_output *output,
wl_fixed_t w = wl_fixed_from_int(output->width); wl_fixed_t w = wl_fixed_from_int(output->width);
wl_fixed_t h = wl_fixed_from_int(output->height); wl_fixed_t h = wl_fixed_from_int(output->height);
*x -= ((((*x - offset_x) / (float) w) - 0.5) * (w * (1.0 - level))); *x = (*x - offset_x) * level + w / 2;
*y -= ((((*y - offset_y) / (float) h) - 0.5) * (h * (1.0 - level))); *y = (*y - offset_y) * level + h / 2;
} }
static void static void
weston_output_update_zoom_transform(struct weston_output *output) weston_output_update_zoom_transform(struct weston_output *output)
{ {
float global_x, global_y; float global_x, global_y;
wl_fixed_t x = output->zoom.current.x; wl_fixed_t x = output->zoom.current.x; /* global pointer coords */
wl_fixed_t y = output->zoom.current.y; wl_fixed_t y = output->zoom.current.y;
float trans_min, trans_max; float level;
float ratio, level;
level = output->zoom.spring_z.current; level = output->zoom.spring_z.current;
@ -92,32 +91,22 @@ weston_output_update_zoom_transform(struct weston_output *output)
level == 0.0f) level == 0.0f)
return; return;
ratio = 1 / level;
zoom_area_center_from_pointer(output, &x, &y); zoom_area_center_from_pointer(output, &x, &y);
global_x = wl_fixed_to_double(x); global_x = wl_fixed_to_double(x);
global_y = wl_fixed_to_double(y); global_y = wl_fixed_to_double(y);
output->zoom.trans_x = output->zoom.trans_x = global_x - (output->x + output->width / 2);
((((global_x - output->x) / output->width) * output->zoom.trans_y = global_y - (output->y + output->height / 2);
(level * 2)) - level) * ratio;
output->zoom.trans_y = if (output->zoom.trans_x < 0)
((((global_y - output->y) / output->height) * output->zoom.trans_x = 0;
(level * 2)) - level) * ratio; if (output->zoom.trans_y < 0)
output->zoom.trans_y = 0;
trans_max = level * 2 - level; if (output->zoom.trans_x > level * output->width)
trans_min = -trans_max; output->zoom.trans_x = level * output->width;
if (output->zoom.trans_y > level * output->height)
/* Clip zoom area to output */ output->zoom.trans_y = level * output->height;
if (output->zoom.trans_x > trans_max)
output->zoom.trans_x = trans_max;
else if (output->zoom.trans_x < trans_min)
output->zoom.trans_x = trans_min;
if (output->zoom.trans_y > trans_max)
output->zoom.trans_y = trans_max;
else if (output->zoom.trans_y < trans_min)
output->zoom.trans_y = trans_min;
} }
static void static void

Loading…
Cancel
Save