[vlc-devel] [PATCH 6/6] Making some vout modules handle movie rotations.
Matthias Keiser
matthias at tristan-inc.com
Thu Feb 27 23:39:44 CET 2014
This patch makes the following vout modules handle rotation:
macosx
xcb_glx
xcb_x11
sdl
The patch hopefully illustrates what needs to be done:
- All modules need to correct their coordinates before calling vout_display_SendEventMouseMoved. Most likely this means instead of using vd->source for your calculations, you need to use source_rot as filled in by video_format_ApplyRotation(&vd->source, &source_rot).
- Modules that don't handle the rotation themselves (currently all modules not using the code in opengl.c) need to adjust their vd->fmt like this (probably early on in the Open function):
video_format_t fmt = vd->fmt;
video_format_ApplyRotation(&fmt, vd->fmt).
- Generally make sure to use vd->fmt instead of vd->source when appropriate (for example when requesting drawing regions etc).
---
modules/video_output/macosx.m | 14 ++++++++------
modules/video_output/sdl.c | 9 +++++++--
modules/video_output/xcb/events.c | 11 +++++++----
modules/video_output/xcb/x11.c | 14 ++++++++++----
4 files changed, 32 insertions(+), 16 deletions(-)
diff --git a/modules/video_output/macosx.m b/modules/video_output/macosx.m
index f0ca190..4df6ff3 100644
--- a/modules/video_output/macosx.m
+++ b/modules/video_output/macosx.m
@@ -213,7 +213,6 @@ static int Open (vlc_object_t *this)
sys->gl.getProcAddress = OurGetProcAddress;
sys->gl.sys = sys;
const vlc_fourcc_t *subpicture_chromas;
- video_format_t fmt = vd->fmt;
sys->vgl = vout_display_opengl_New (&vd->fmt, &subpicture_chromas, &sys->gl);
if (!sys->vgl) {
@@ -238,7 +237,7 @@ static int Open (vlc_object_t *this)
vd->control = Control;
/* */
- vout_display_SendEventDisplaySize (vd, vd->source.i_visible_width, vd->source.i_visible_height, false);
+ vout_display_SendEventDisplaySize (vd, vd->fmt.i_visible_width, vd->fmt.i_visible_height, false);
return VLC_SUCCESS;
@@ -786,11 +785,14 @@ static void OpenglSwap (vlc_gl_t *gl)
if (vd) {
vout_display_place_t place = vd->sys->place;
+ video_format_t source_rot;
+ video_format_ApplyRotation(&vd->source, &source_rot);
+
if (place.width > 0 && place.height > 0) {
- const int x = vd->source.i_x_offset +
- (int64_t)(ml.x - place.x) * vd->source.i_visible_width / place.width;
- const int y = vd->source.i_y_offset +
- (int64_t)((int)s_rect.size.height - (int)ml.y - place.y) * vd->source.i_visible_height / place.height;
+ int x = source_rot.i_x_offset +
+ (int64_t)(ml.x - place.x) * source_rot.i_visible_width / place.width;
+ int y = source_rot.i_y_offset +
+ (int64_t)((int)s_rect.size.height - (int)ml.y - place.y) * source_rot.i_visible_height / place.height;
vout_display_SendEventMouseMoved (vd, x, y);
}
diff --git a/modules/video_output/sdl.c b/modules/video_output/sdl.c
index 5520bb2..7093e53 100644
--- a/modules/video_output/sdl.c
+++ b/modules/video_output/sdl.c
@@ -165,6 +165,8 @@ static int Open(vlc_object_t *object)
/* */
video_format_t fmt = vd->fmt;
+ video_format_ApplyRotation(&fmt, &vd->fmt);
+ fmt = vd->fmt;
/* */
vout_display_info_t info = vd->info;
@@ -638,8 +640,11 @@ static void Manage(vout_display_t *vd)
if (sys->place.width <= 0 || sys->place.height <= 0)
break;
- const int x = (int64_t)(event.motion.x - sys->place.x) * vd->source.i_width / sys->place.width;
- const int y = (int64_t)(event.motion.y - sys->place.y) * vd->source.i_height / sys->place.height;
+ video_format_t source_rot;
+ video_format_ApplyRotation(&vd->source, &source_rot);
+
+ const int x = (int64_t)(event.motion.x - sys->place.x) * source_rot.i_width / sys->place.width;
+ const int y = (int64_t)(event.motion.y - sys->place.y) * source_rot.i_height / sys->place.height;
SDL_ShowCursor(1);
vout_display_SendEventMouseMoved(vd, x, y);
diff --git a/modules/video_output/xcb/events.c b/modules/video_output/xcb/events.c
index efb3adb..bb94c1c 100644
--- a/modules/video_output/xcb/events.c
+++ b/modules/video_output/xcb/events.c
@@ -232,10 +232,13 @@ static void HandleMotionNotify (vout_display_t *vd, xcb_connection_t *conn,
if (place.width <= 0 || place.height <= 0)
return;
- const int x = vd->source.i_x_offset +
- (int64_t)(ev->event_x - place.x) * vd->source.i_visible_width / place.width;
- const int y = vd->source.i_y_offset +
- (int64_t)(ev->event_y - place.y) * vd->source.i_visible_height/ place.height;
+ video_format_t source_rot;
+ video_format_ApplyRotation(&vd->source, &source_rot);
+
+ const int x = source_rot.i_x_offset +
+ (int64_t)(ev->event_x - place.x) * source_rot.i_visible_width / place.width;
+ const int y = source_rot.i_y_offset +
+ (int64_t)(ev->event_y - place.y) * source_rot.i_visible_height/ place.height;
vout_display_SendEventMouseMoved (vd, x, y);
}
diff --git a/modules/video_output/xcb/x11.c b/modules/video_output/xcb/x11.c
index b2e782e..6b01bed 100644
--- a/modules/video_output/xcb/x11.c
+++ b/modules/video_output/xcb/x11.c
@@ -112,6 +112,9 @@ static int Open (vlc_object_t *obj)
vd->sys = sys;
sys->pool = NULL;
+ video_format_t fmt = vd->fmt;
+ video_format_ApplyRotation(&fmt, &vd->fmt);
+
/* Get window, connect to X server */
xcb_connection_t *conn;
const xcb_screen_t *scr;
@@ -533,13 +536,16 @@ static int Control (vout_display_t *vd, int query, va_list ap)
vout_display_place_t place;
vout_display_PlacePicture (&place, &vd->source, vd->cfg, false);
- vd->fmt.i_width = vd->source.i_width * place.width / vd->source.i_visible_width;
- vd->fmt.i_height = vd->source.i_height * place.height / vd->source.i_visible_height;
+ video_format_t source_rot;
+ video_format_ApplyRotation(&vd->source, &source_rot);
+
+ vd->fmt.i_width = source_rot.i_width * place.width / source_rot.i_visible_width;
+ vd->fmt.i_height = source_rot.i_height * place.height / source_rot.i_visible_height;
vd->fmt.i_visible_width = place.width;
vd->fmt.i_visible_height = place.height;
- vd->fmt.i_x_offset = vd->source.i_x_offset * place.width / vd->source.i_visible_width;
- vd->fmt.i_y_offset = vd->source.i_y_offset * place.height / vd->source.i_visible_height;
+ vd->fmt.i_x_offset = source_rot.i_x_offset * place.width / source_rot.i_visible_width;
+ vd->fmt.i_y_offset = source_rot.i_y_offset * place.height / source_rot.i_visible_height;
return VLC_SUCCESS;
}
--
1.8.3.4 (Apple Git-47)
More information about the vlc-devel
mailing list