summaryrefslogtreecommitdiff
path: root/src/zoom.c
diff options
context:
space:
mode:
authorScott Moreau <oreaus@gmail.com>2012-08-18 01:04:05 -0600
committerKristian Høgsberg <krh@bitplanet.net>2012-08-29 14:39:13 -0400
commit1bad5db9d69cd744bc48f60bb71f7b68b6a2f770 (patch)
treec11d1122dd3e962edae4ce826eac49722e1177ba /src/zoom.c
parent5418a904ca007a109f6af8c0c75ca97a134986d9 (diff)
downloadweston-1bad5db9d69cd744bc48f60bb71f7b68b6a2f770.tar.gz
weston-1bad5db9d69cd744bc48f60bb71f7b68b6a2f770.tar.bz2
weston-1bad5db9d69cd744bc48f60bb71f7b68b6a2f770.zip
Implement output transformations.
This patch allows rotation and mirroring outputs for x11 and drm backends. A new 'transform' key can be set in the [output] section. From the protocol: "The flipped values correspond to an initial flip around a vertical axis followed by rotation." The transform key can be one of the following 8 strings: normal 90 180 270 flipped flipped-90 flipped-180 flipped-270
Diffstat (limited to 'src/zoom.c')
-rw-r--r--src/zoom.c55
1 files changed, 51 insertions, 4 deletions
diff --git a/src/zoom.c b/src/zoom.c
index 56a9eadb..674a80ea 100644
--- a/src/zoom.c
+++ b/src/zoom.c
@@ -187,14 +187,58 @@ zoom_area_center_from_pointer(struct weston_output *output,
float level = output->zoom.spring_z.current;
wl_fixed_t offset_x = wl_fixed_from_int(output->x);
wl_fixed_t offset_y = wl_fixed_from_int(output->y);
- wl_fixed_t w = wl_fixed_from_int(output->current->width);
- wl_fixed_t h = wl_fixed_from_int(output->current->height);
+ wl_fixed_t w = wl_fixed_from_int(output->width);
+ wl_fixed_t h = wl_fixed_from_int(output->height);
*x -= ((((*x - offset_x) / (float) w) - 0.5) * (w * (1.0 - level)));
*y -= ((((*y - offset_y) / (float) h) - 0.5) * (h * (1.0 - level)));
}
static void
+weston_zoom_apply_output_transform(struct weston_output *output,
+ float *x, float *y)
+{
+ float tx, ty;
+
+ switch(output->transform) {
+ case WL_OUTPUT_TRANSFORM_NORMAL:
+ default:
+ return;
+ case WL_OUTPUT_TRANSFORM_90:
+ tx = -*y;
+ ty = *x;
+ break;
+ case WL_OUTPUT_TRANSFORM_180:
+ tx = -*x;
+ ty = -*y;
+ break;
+ case WL_OUTPUT_TRANSFORM_270:
+ tx = *y;
+ ty = -*x;
+ break;
+ case WL_OUTPUT_TRANSFORM_FLIPPED:
+ tx = -*x;
+ ty = *y;
+ break;
+ case WL_OUTPUT_TRANSFORM_FLIPPED_90:
+ tx = -*y;
+ ty = -*x;
+ break;
+ case WL_OUTPUT_TRANSFORM_FLIPPED_180:
+ tx = *x;
+ ty = -*y;
+ break;
+ case WL_OUTPUT_TRANSFORM_FLIPPED_270:
+ tx = *y;
+ ty = *x;
+ break;
+ }
+
+ *x = tx;
+ *y = ty;
+}
+
+static void
weston_output_update_zoom_transform(struct weston_output *output)
{
uint32_t type = output->zoom.type;
@@ -218,12 +262,15 @@ weston_output_update_zoom_transform(struct weston_output *output)
global_y = wl_fixed_to_double(y);
output->zoom.trans_x =
- ((((global_x - output->x) / output->current->width) *
+ ((((global_x - output->x) / output->width) *
(level * 2)) - level) * ratio;
output->zoom.trans_y =
- ((((global_y - output->y) / output->current->height) *
+ ((((global_y - output->y) / output->height) *
(level * 2)) - level) * ratio;
+ weston_zoom_apply_output_transform(output, &output->zoom.trans_x,
+ &output->zoom.trans_y);
+
trans_max = level * 2 - level;
trans_min = -trans_max;