summaryrefslogtreecommitdiffstats
path: root/libvo/vo_xv.c
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2009-02-12 17:40:53 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2009-02-12 17:40:53 +0000
commit694c3dc03f157eb62442fb2f24118f2ae4432ec7 (patch)
treebb97f3f9bd760f87c4b48f42ae61ccc07ffd33c4 /libvo/vo_xv.c
parent8c2821f32d62e6a2a6f6df99b366d1a2ba40fdd3 (diff)
downloadmpv-694c3dc03f157eb62442fb2f24118f2ae4432ec7.tar.bz2
mpv-694c3dc03f157eb62442fb2f24118f2ae4432ec7.tar.xz
Add a calc_src_dst_rects that calculates from window size, panscan etc.
which part of the video source must be scaled onto which part of the window. Direct3D and (future) VDPAU need this, for XvMC it makes it easier to add cropping support and Xv is changed to keep the diff to XvMC small. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28546 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo/vo_xv.c')
-rw-r--r--libvo/vo_xv.c54
1 files changed, 18 insertions, 36 deletions
diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c
index a88621c9ee..ddde21a402 100644
--- a/libvo/vo_xv.c
+++ b/libvo/vo_xv.c
@@ -106,7 +106,8 @@ static uint32_t image_format;
static int int_pause;
-static uint32_t drwX, drwY;
+static struct vo_rect src_rect;
+static struct vo_rect dst_rect;
static uint32_t max_width = 0, max_height = 0; // zero means: not set
static void (*draw_alpha_fnc) (int x0, int y0, int w, int h,
@@ -158,6 +159,13 @@ static void draw_alpha_null(int x0, int y0, int w, int h,
static void deallocate_xvimage(int foo);
+static void resize(void)
+{
+ calc_src_dst_rects(image_width, image_height, &src_rect, &dst_rect, NULL);
+ vo_x11_clearwindow_part(mDisplay, vo_window, dst_rect.width, dst_rect.height, 1);
+ vo_xv_draw_colorkey(dst_rect.left, dst_rect.top, dst_rect.width, dst_rect.height);
+}
+
/*
* connect to server, create and map window,
* allocate colors and (shared) memory
@@ -288,17 +296,8 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
current_ip_buf = 0;
if ((flags & VOFLAG_FULLSCREEN) && WinID <= 0) vo_fs = 1;
- vo_calc_drwXY(&drwX, &drwY);
-
- panscan_calc();
- vo_xv_draw_colorkey(drwX - (vo_panscan_x >> 1),
- drwY - (vo_panscan_y >> 1),
- vo_dwidth + vo_panscan_x - 1,
- vo_dheight + vo_panscan_y - 1);
-
- mp_msg(MSGT_VO, MSGL_V, "[xv] dx: %d dy: %d dw: %d dh: %d\n", drwX,
- drwY, vo_dwidth, vo_dheight);
+ resize();
return 0;
}
@@ -371,19 +370,17 @@ static inline void put_xvimage( XvImage * xvi )
if (Shmem_Flag)
{
XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc,
- xvi, 0, 0, image_width,
- image_height, drwX - (vo_panscan_x >> 1),
- drwY - (vo_panscan_y >> 1), vo_dwidth + vo_panscan_x,
- vo_dheight + vo_panscan_y,
+ xvi,
+ src_rect.left, src_rect.top, src_rect.width, src_rect.height,
+ dst_rect.left, dst_rect.top, dst_rect.width, dst_rect.height,
False);
} else
#endif
{
XvPutImage(mDisplay, xv_port, vo_window, vo_gc,
- xvi, 0, 0, image_width, image_height,
- drwX - (vo_panscan_x >> 1), drwY - (vo_panscan_y >> 1),
- vo_dwidth + vo_panscan_x,
- vo_dheight + vo_panscan_y);
+ xvi,
+ src_rect.left, src_rect.top, src_rect.width, src_rect.height,
+ dst_rect.left, dst_rect.top, dst_rect.width, dst_rect.height);
}
}
@@ -391,17 +388,9 @@ static void check_events(void)
{
int e = vo_x11_check_events(mDisplay);
- if (e & VO_EVENT_RESIZE)
- {
- vo_calc_drwXY(&drwX, &drwY);
- }
-
if (e & VO_EVENT_EXPOSE || e & VO_EVENT_RESIZE)
{
- vo_xv_draw_colorkey(drwX - (vo_panscan_x >> 1),
- drwY - (vo_panscan_y >> 1),
- vo_dwidth + vo_panscan_x - 1,
- vo_dheight + vo_panscan_y - 1);
+ resize();
}
if ((e & VO_EVENT_EXPOSE || e & VO_EVENT_RESIZE) && int_pause)
@@ -777,14 +766,7 @@ static int control(uint32_t request, void *data, ...)
if (old_y != vo_panscan_y)
{
- vo_x11_clearwindow_part(mDisplay, vo_window,
- vo_dwidth + vo_panscan_x - 1,
- vo_dheight + vo_panscan_y - 1,
- 1);
- vo_xv_draw_colorkey(drwX - (vo_panscan_x >> 1),
- drwY - (vo_panscan_y >> 1),
- vo_dwidth + vo_panscan_x - 1,
- vo_dheight + vo_panscan_y - 1);
+ resize();
flip_page();
}
}