summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUoti Urpala <uau@symbol.nonexistent.invalid>2008-04-20 23:29:28 +0300
committerUoti Urpala <uau@symbol.nonexistent.invalid>2008-04-23 13:46:40 +0300
commiteaab1ce896adbcb58e6503ea2dcf789d99bd29f5 (patch)
tree40a03206817797e1e293185e6df304c4cb63165f
parent7521aac66509d18666b7737160153986cc1437ac (diff)
downloadmpv-eaab1ce896adbcb58e6503ea2dcf789d99bd29f5.tar.bz2
mpv-eaab1ce896adbcb58e6503ea2dcf789d99bd29f5.tar.xz
Move vo_dx,vo_dy,vo_dwidth,vo_dheight to vo struct
-rw-r--r--command.c26
-rw-r--r--libvo/mga_common.c1
-rw-r--r--libvo/old_vo_defines.h4
-rw-r--r--libvo/video_out.c18
-rw-r--r--libvo/video_out.h8
-rw-r--r--libvo/vo_xv.c78
-rw-r--r--libvo/x11_common.c39
-rw-r--r--libvo/x11_common.h3
8 files changed, 91 insertions, 86 deletions
diff --git a/command.c b/command.c
index 0b4312aba9..4b3bc28476 100644
--- a/command.c
+++ b/command.c
@@ -66,32 +66,34 @@
extern int use_menu;
-static void rescale_input_coordinates(int ix, int iy, double *dx, double *dy)
+static void rescale_input_coordinates(struct MPContext *mpctx, int ix, int iy,
+ double *dx, double *dy)
{
+ struct vo *vo = mpctx->video_out;
//remove the borders, if any, and rescale to the range [0,1],[0,1]
if (vo_fs) { //we are in full-screen mode
- if (vo_screenwidth > vo_dwidth) //there are borders along the x axis
- ix -= (vo_screenwidth - vo_dwidth) / 2;
- if (vo_screenheight > vo_dheight) //there are borders along the y axis (usual way)
- iy -= (vo_screenheight - vo_dheight) / 2;
+ if (vo_screenwidth > vo->dwidth) //there are borders along the x axis
+ ix -= (vo_screenwidth - vo->dwidth) / 2;
+ if (vo_screenheight > vo->dheight) //there are borders along the y axis (usual way)
+ iy -= (vo_screenheight - vo->dheight) / 2;
- if (ix < 0 || ix > vo_dwidth) {
+ if (ix < 0 || ix > vo->dwidth) {
*dx = *dy = -1.0;
return;
} //we are on one of the borders
- if (iy < 0 || iy > vo_dheight) {
+ if (iy < 0 || iy > vo->dheight) {
*dx = *dy = -1.0;
return;
} //we are on one of the borders
}
- *dx = (double) ix / (double) vo_dwidth;
- *dy = (double) iy / (double) vo_dheight;
+ *dx = (double) ix / (double) vo->dwidth;
+ *dy = (double) iy / (double) vo->dheight;
mp_msg(MSGT_CPLAYER, MSGL_V,
"\r\nrescaled coordinates: %.3lf, %.3lf, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
- *dx, *dy, vo_screenwidth, vo_screenheight, vo_dwidth,
- vo_dheight, vo_fs);
+ *dx, *dy, vo_screenwidth, vo_screenheight, vo->dwidth,
+ vo->dheight, vo_fs);
}
static int sub_source_by_pos(MPContext * mpctx, int pos)
@@ -3076,7 +3078,7 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd)
double dx, dy;
pointer_x = cmd->args[0].v.i;
pointer_y = cmd->args[1].v.i;
- rescale_input_coordinates(pointer_x, pointer_y, &dx, &dy);
+ rescale_input_coordinates(mpctx, pointer_x, pointer_y, &dx, &dy);
#ifdef USE_DVDNAV
if (mpctx->stream->type == STREAMTYPE_DVDNAV
&& dx > 0.0 && dy > 0.0) {
diff --git a/libvo/mga_common.c b/libvo/mga_common.c
index 88997fb194..e90aebd764 100644
--- a/libvo/mga_common.c
+++ b/libvo/mga_common.c
@@ -6,6 +6,7 @@
#include "libmpcodecs/vf_scale.h"
#include "mp_msg.h"
#include "help_mp.h"
+#include "old_vo_wrapper.h"
// mga_vid drawing functions
static void set_window( void ); /* forward declaration to kill warnings */
diff --git a/libvo/old_vo_defines.h b/libvo/old_vo_defines.h
index ef52e52256..b4003937b6 100644
--- a/libvo/old_vo_defines.h
+++ b/libvo/old_vo_defines.h
@@ -10,5 +10,9 @@
#define vo_ontop global_vo->opts->vo_ontop
#define vo_config_count global_vo->config_count
+#define vo_dx global_vo->dx
+#define vo_dy global_vo->dy
+#define vo_dwidth global_vo->dwidth
+#define vo_dheight global_vo->dheight
#endif
diff --git a/libvo/video_out.c b/libvo/video_out.c
index 6cab65d25f..1f527af08f 100644
--- a/libvo/video_out.c
+++ b/libvo/video_out.c
@@ -36,10 +36,6 @@ int vo_screenwidth=0;
int vo_screenheight=0;
// requested resolution/bpp: (-x -y -bpp options)
-int vo_dx=0;
-int vo_dy=0;
-int vo_dwidth=0;
-int vo_dheight=0;
int vo_dbpp=0;
int vo_nomouse_input = 0;
@@ -367,14 +363,14 @@ int vo_config(struct vo *vo, uint32_t width, uint32_t height,
if (vo_control(vo, VOCTRL_UPDATE_SCREENINFO, NULL) == VO_TRUE) {
aspect(&d_width, &d_height, A_NOZOOM);
- vo_dx = (int)(vo_screenwidth - d_width) / 2;
- vo_dy = (int)(vo_screenheight - d_height) / 2;
- geometry(&vo_dx, &vo_dy, &d_width, &d_height,
+ vo->dx = (int)(vo_screenwidth - d_width) / 2;
+ vo->dy = (int)(vo_screenheight - d_height) / 2;
+ geometry(&vo->dx, &vo->dy, &d_width, &d_height,
vo_screenwidth, vo_screenheight);
- vo_dx += xinerama_x;
- vo_dy += xinerama_y;
- vo_dwidth = d_width;
- vo_dheight = d_height;
+ vo->dx += xinerama_x;
+ vo->dy += xinerama_y;
+ vo->dwidth = d_width;
+ vo->dheight = d_height;
}
int ret = vo->driver->config(vo, width, height, d_width, d_height, flags,
diff --git a/libvo/video_out.h b/libvo/video_out.h
index 1870af17d3..ad298c04f3 100644
--- a/libvo/video_out.h
+++ b/libvo/video_out.h
@@ -213,6 +213,10 @@ struct vo {
void *priv;
struct MPOpts *opts;
struct vo_x11_state *x11;
+ int dx;
+ int dy;
+ int dwidth;
+ int dheight;
};
struct vo *init_best_video_out(struct MPOpts *opts, struct vo_x11_state *x11);
@@ -245,10 +249,6 @@ extern int vo_screenwidth;
extern int vo_screenheight;
// requested resolution/bpp: (-x -y -bpp options)
-extern int vo_dx;
-extern int vo_dy;
-extern int vo_dwidth;
-extern int vo_dheight;
extern int vo_dbpp;
extern int vo_grabpointer;
diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c
index bc8a5015e7..ec2099866a 100644
--- a/libvo/vo_xv.c
+++ b/libvo/vo_xv.c
@@ -106,7 +106,7 @@ static void draw_alpha_yv12(void *p, int x0, int y0, int w, int h,
{
struct vo *vo = p;
struct xvctx *ctx = vo->priv;
- x0 += ctx->image_width * (vo_panscan_x >> 1) / (vo_dwidth + vo_panscan_x);
+ x0 += ctx->image_width * (vo_panscan_x >> 1) / (vo->dwidth + vo_panscan_x);
vo_draw_alpha_yv12(w, h, src, srca, stride,
ctx->xvimage[ctx->current_buf]->data +
ctx->xvimage[ctx->current_buf]->offsets[0] +
@@ -120,7 +120,7 @@ static void draw_alpha_yuy2(void *p, int x0, int y0, int w, int h,
{
struct vo *vo = p;
struct xvctx *ctx = vo->priv;
- x0 += ctx->image_width * (vo_panscan_x >> 1) / (vo_dwidth + vo_panscan_x);
+ x0 += ctx->image_width * (vo_panscan_x >> 1) / (vo->dwidth + vo_panscan_x);
vo_draw_alpha_yuy2(w, h, src, srca, stride,
ctx->xvimage[ctx->current_buf]->data +
ctx->xvimage[ctx->current_buf]->offsets[0] +
@@ -134,7 +134,7 @@ static void draw_alpha_uyvy(void *p, int x0, int y0, int w, int h,
{
struct vo *vo = p;
struct xvctx *ctx = vo->priv;
- x0 += ctx->image_width * (vo_panscan_x >> 1) / (vo_dwidth + vo_panscan_x);
+ x0 += ctx->image_width * (vo_panscan_x >> 1) / (vo->dwidth + vo_panscan_x);
vo_draw_alpha_yuy2(w, h, src, srca, stride,
ctx->xvimage[ctx->current_buf]->data +
ctx->xvimage[ctx->current_buf]->offsets[0] +
@@ -151,19 +151,19 @@ static void draw_alpha_null(void *p, int x0, int y0, int w, int h,
static void deallocate_xvimage(struct vo *vo, int foo);
-static void calc_drwXY(uint32_t *drwX, uint32_t *drwY) {
+static void calc_drwXY(struct vo *vo, uint32_t *drwX, uint32_t *drwY) {
*drwX = *drwY = 0;
if (vo_fs) {
- aspect(&vo_dwidth, &vo_dheight, A_ZOOM);
- vo_dwidth = FFMIN(vo_dwidth, vo_screenwidth);
- vo_dheight = FFMIN(vo_dheight, vo_screenheight);
- *drwX = (vo_screenwidth - vo_dwidth) / 2;
- *drwY = (vo_screenheight - vo_dheight) / 2;
+ aspect(&vo->dwidth, &vo->dheight, A_ZOOM);
+ vo->dwidth = FFMIN(vo->dwidth, vo_screenwidth);
+ vo->dheight = FFMIN(vo->dheight, vo_screenheight);
+ *drwX = (vo_screenwidth - vo->dwidth) / 2;
+ *drwY = (vo_screenheight - vo->dheight) / 2;
mp_msg(MSGT_VO, MSGL_V, "[xv-fs] dx: %d dy: %d dw: %d dh: %d\n",
- *drwX, *drwY, vo_dwidth, vo_dheight);
+ *drwX, *drwY, vo->dwidth, vo->dheight);
} else if (WinID == 0) {
- *drwX = vo_dx;
- *drwY = vo_dy;
+ *drwX = vo->dx;
+ *drwY = vo->dy;
}
}
@@ -223,8 +223,8 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
else
#endif
{
- hint.x = vo_dx;
- hint.y = vo_dy;
+ hint.x = vo->dx;
+ hint.y = vo->dy;
hint.width = d_width;
hint.height = d_height;
#ifdef HAVE_XF86VM
@@ -292,15 +292,15 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
Window mRoot;
uint32_t drwBorderWidth, drwDepth;
XGetGeometry(x11->display, vo_window, &mRoot,
- &ctx->drwX, &ctx->drwY, &vo_dwidth, &vo_dheight,
+ &ctx->drwX, &ctx->drwY, &vo->dwidth, &vo->dheight,
&drwBorderWidth, &drwDepth);
- if (vo_dwidth <= 0) vo_dwidth = d_width;
- if (vo_dheight <= 0) vo_dheight = d_height;
- aspect_save_prescale(vo_dwidth, vo_dheight);
+ if (vo->dwidth <= 0) vo->dwidth = d_width;
+ if (vo->dheight <= 0) vo->dheight = d_height;
+ aspect_save_prescale(vo->dwidth, vo->dheight);
}
} else
{
- vo_x11_create_vo_window(vo, &vinfo, vo_dx, vo_dy, d_width, d_height,
+ vo_x11_create_vo_window(vo, &vinfo, vo->dx, vo->dy, d_width, d_height,
flags, CopyFromParent, "xv", title);
XChangeWindowAttributes(x11->display, vo_window, xswamask, &xswa);
}
@@ -360,19 +360,19 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
set_gamma_correction();
#endif
- aspect(&vo_dwidth, &vo_dheight, A_NOZOOM);
+ aspect(&vo->dwidth, &vo->dheight, A_NOZOOM);
if ((flags & VOFLAG_FULLSCREEN) && WinID <= 0) vo_fs = 1;
- calc_drwXY(&ctx->drwX, &ctx->drwY);
+ calc_drwXY(vo, &ctx->drwX, &ctx->drwY);
panscan_calc();
vo_xv_draw_colorkey(vo, ctx->drwX - (vo_panscan_x >> 1),
ctx->drwY - (vo_panscan_y >> 1),
- vo_dwidth + vo_panscan_x - 1,
- vo_dheight + 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", ctx->drwX,
- ctx->drwY, vo_dwidth, vo_dheight);
+ ctx->drwY, vo->dwidth, vo->dheight);
if (opts->vo_ontop)
vo_x11_setlayer(x11->display, vo_window, opts->vo_ontop);
@@ -455,8 +455,8 @@ static inline void put_xvimage(struct vo *vo, XvImage *xvi)
XvShmPutImage(x11->display, xv_port, vo_window, vo_gc,
xvi, 0, 0, ctx->image_width,
ctx->image_height, ctx->drwX - (vo_panscan_x >> 1),
- ctx->drwY - (vo_panscan_y >> 1), vo_dwidth + vo_panscan_x,
- vo_dheight + vo_panscan_y,
+ ctx->drwY - (vo_panscan_y >> 1), vo->dwidth + vo_panscan_x,
+ vo->dheight + vo_panscan_y,
False);
} else
#endif
@@ -464,8 +464,8 @@ static inline void put_xvimage(struct vo *vo, XvImage *xvi)
XvPutImage(x11->display, xv_port, vo_window, vo_gc,
xvi, 0, 0, ctx->image_width, ctx->image_height,
ctx->drwX - (vo_panscan_x >> 1), ctx->drwY - (vo_panscan_y >> 1),
- vo_dwidth + vo_panscan_x,
- vo_dheight + vo_panscan_y);
+ vo->dwidth + vo_panscan_x,
+ vo->dheight + vo_panscan_y);
}
}
@@ -480,19 +480,19 @@ static void check_events(struct vo *vo)
Window mRoot;
uint32_t drwBorderWidth, drwDepth;
XGetGeometry(x11->display, vo_window, &mRoot, &ctx->drwX, &ctx->drwY,
- &vo_dwidth, &vo_dheight, &drwBorderWidth, &drwDepth);
+ &vo->dwidth, &vo->dheight, &drwBorderWidth, &drwDepth);
mp_msg(MSGT_VO, MSGL_V, "[xv] dx: %d dy: %d dw: %d dh: %d\n", ctx->drwX,
- ctx->drwY, vo_dwidth, vo_dheight);
+ ctx->drwY, vo->dwidth, vo->dheight);
- calc_drwXY(&ctx->drwX, &ctx->drwY);
+ calc_drwXY(vo, &ctx->drwX, &ctx->drwY);
}
if (e & VO_EVENT_EXPOSE || e & VO_EVENT_RESIZE)
{
vo_xv_draw_colorkey(vo, ctx->drwX - (vo_panscan_x >> 1),
ctx->drwY - (vo_panscan_y >> 1),
- vo_dwidth + vo_panscan_x - 1,
- vo_dheight + vo_panscan_y - 1);
+ vo->dwidth + vo_panscan_x - 1,
+ vo->dheight + vo_panscan_y - 1);
}
if ((e & VO_EVENT_EXPOSE || e & VO_EVENT_RESIZE) && ctx->is_paused)
@@ -511,7 +511,7 @@ static void draw_osd(struct vo *vo)
struct xvctx *ctx = vo->priv;
osd_draw_text(ctx->image_width -
- ctx->image_width * vo_panscan_x / (vo_dwidth + vo_panscan_x),
+ ctx->image_width * vo_panscan_x / (vo->dwidth + vo_panscan_x),
ctx->image_height, ctx->draw_alpha_fnc, vo);
}
@@ -883,14 +883,14 @@ static int control(struct vo *vo, uint32_t request, void *data)
if (old_y != vo_panscan_y)
{
- vo_x11_clearwindow_part(vo->x11->display, vo_window,
- vo_dwidth + vo_panscan_x - 1,
- vo_dheight + vo_panscan_y - 1,
+ vo_x11_clearwindow_part(vo, vo_window,
+ vo->dwidth + vo_panscan_x - 1,
+ vo->dheight + vo_panscan_y - 1,
1);
vo_xv_draw_colorkey(vo, ctx->drwX - (vo_panscan_x >> 1),
ctx->drwY - (vo_panscan_y >> 1),
- vo_dwidth + vo_panscan_x - 1,
- vo_dheight + vo_panscan_y - 1);
+ vo->dwidth + vo_panscan_x - 1,
+ vo->dheight + vo_panscan_y - 1);
flip_page(vo);
}
}
diff --git a/libvo/x11_common.c b/libvo/x11_common.c
index 8d30c7601d..989d45ce5f 100644
--- a/libvo/x11_common.c
+++ b/libvo/x11_common.c
@@ -385,8 +385,8 @@ void update_xinerama_info(struct vo *vo) {
if (screen >= num_screens)
screen = num_screens - 1;
if (screen == -1) {
- int x = vo_dx + vo_dwidth / 2;
- int y = vo_dy + vo_dheight / 2;
+ int x = vo->dx + vo->dwidth / 2;
+ int y = vo->dy + vo->dheight / 2;
for (screen = num_screens - 1; screen > 0; screen--) {
int left = screens[screen].x_org;
int right = left + screens[screen].width;
@@ -1058,12 +1058,12 @@ int vo_x11_check_events(struct vo *vo)
// if (vo_fs && Event.xconfigure.width != vo_screenwidth && Event.xconfigure.height != vo_screenheight) break;
if (vo_window == None)
break;
- vo_dwidth = Event.xconfigure.width;
- vo_dheight = Event.xconfigure.height;
+ vo->dwidth = Event.xconfigure.width;
+ vo->dheight = Event.xconfigure.height;
#if 0
/* when resizing, x and y are zero :( */
- vo_dx = Event.xconfigure.x;
- vo_dy = Event.xconfigure.y;
+ vo->dx = Event.xconfigure.x;
+ vo->dy = Event.xconfigure.y;
#else
{
Window root;
@@ -1074,7 +1074,7 @@ int vo_x11_check_events(struct vo *vo)
&foo /*width */ , &foo /*height */ , &foo,
&foo);
XTranslateCoordinates(display, vo_window, root, 0, 0,
- &vo_dx, &vo_dy, &win);
+ &vo->dx, &vo->dy, &win);
}
#endif
ret |= VO_EVENT_RESIZE;
@@ -1188,8 +1188,8 @@ static void vo_x11_nofs_sizepos(struct vo *vo, int x, int y,
}
else
{
- vo_dwidth = width;
- vo_dheight = height;
+ vo->dwidth = width;
+ vo->dheight = height;
XMoveResizeWindow(vo->x11->display, vo_window, x, y, width, height);
}
}
@@ -1311,8 +1311,8 @@ void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y,
XSizeHints hint;
XEvent xev;
vo_fs = 0;
- vo_dwidth = width;
- vo_dheight = height;
+ vo->dwidth = width;
+ vo->dheight = height;
vo_window = vo_x11_create_smooth_window(mDisplay, mRootWin, vis->visual,
x, y, width, height, vis->depth, col_map);
vo_x11_classhint(mDisplay, vo_window, classname);
@@ -1338,21 +1338,22 @@ void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y,
ButtonPressMask | ButtonReleaseMask | ExposureMask);
}
if (opts->vo_ontop) vo_x11_setlayer(mDisplay, vo_window, opts->vo_ontop);
- vo_x11_nofs_sizepos(vo, vo_dx, vo_dy, width, height);
+ vo_x11_nofs_sizepos(vo, vo->dx, vo->dy, width, height);
if (!!vo_fs != !!(flags & VOFLAG_FULLSCREEN))
vo_x11_fullscreen(vo);
}
-void vo_x11_clearwindow_part(Display * mDisplay, Window vo_window,
+void vo_x11_clearwindow_part(struct vo *vo, Window vo_window,
int img_width, int img_height, int use_fs)
{
+ Display *mDisplay = vo->x11->display;
int u_dheight, u_dwidth, left_ov, left_ov2;
if (!f_gc)
return;
- u_dheight = use_fs ? vo_screenheight : vo_dheight;
- u_dwidth = use_fs ? vo_screenwidth : vo_dwidth;
+ u_dheight = use_fs ? vo_screenheight : vo->dheight;
+ u_dwidth = use_fs ? vo_screenwidth : vo->dwidth;
if ((u_dheight <= img_height) && (u_dwidth <= img_width))
return;
@@ -1546,10 +1547,10 @@ void vo_x11_fullscreen(struct vo *vo)
vo_fs = VO_TRUE;
if ( ! (vo_fs_type & vo_wm_FULLSCREEN) ) // not needed with EWMH fs
{
- vo_old_x = vo_dx;
- vo_old_y = vo_dy;
- vo_old_width = vo_dwidth;
- vo_old_height = vo_dheight;
+ vo_old_x = vo->dx;
+ vo_old_y = vo->dy;
+ vo_old_width = vo->dwidth;
+ vo_old_height = vo->dheight;
}
update_xinerama_info(vo);
x = xinerama_x;
diff --git a/libvo/x11_common.h b/libvo/x11_common.h
index 018739a5a5..931c9ec233 100644
--- a/libvo/x11_common.h
+++ b/libvo/x11_common.h
@@ -57,7 +57,7 @@ extern void fstype_help(void);
void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis,
int x, int y, unsigned int width, unsigned int height, int flags,
Colormap col_map, const char *classname, const char *title);
-extern void vo_x11_clearwindow_part(Display *mDisplay, Window vo_window,
+void vo_x11_clearwindow_part(struct vo *vo, Window vo_window,
int img_width, int img_height, int use_fs);
extern void vo_x11_clearwindow( Display *mDisplay, Window vo_window );
void vo_x11_ontop(struct vo *vo);
@@ -140,6 +140,7 @@ int vo_find_depth_from_visuals(Display *dpy, int screen, Visual **visual_return)
#define vo_xv_get_max_img_dim(...) vo_xv_get_max_img_dim(global_vo, __VA_ARGS__)
#define vo_xv_init_colorkey() vo_xv_init_colorkey(global_vo)
#define vo_xv_draw_colorkey(...) vo_xv_draw_colorkey(global_vo, __VA_ARGS__)
+#define vo_x11_clearwindow_part(display, ...) vo_x11_clearwindow_part(global_vo, __VA_ARGS__)
#define mDisplay global_vo->x11->display
#endif