summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2010-04-26 19:22:56 +0300
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-04-26 19:23:32 +0300
commitf38efd166e43f5cae783f38f9913d2859557143e (patch)
tree38f49af429d4147e390f0b52384294b2e35b9d6f /libvo
parent7a33e76943ecc3f2ba185a1bea56c8416b74d6dd (diff)
parent4e853e19ef349a453ef069d76b830a3dbfa444c3 (diff)
downloadmpv-f38efd166e43f5cae783f38f9913d2859557143e.tar.bz2
mpv-f38efd166e43f5cae783f38f9913d2859557143e.tar.xz
Merge svn changes up to r31097
Diffstat (limited to 'libvo')
-rw-r--r--libvo/gl_common.c140
-rw-r--r--libvo/gl_common.h5
-rw-r--r--libvo/osx_common.c2
-rw-r--r--libvo/sdl_common.c163
-rw-r--r--libvo/sdl_common.h37
-rw-r--r--libvo/video_out.c19
-rw-r--r--libvo/video_out.h8
-rw-r--r--libvo/vo_corevideo.m8
-rw-r--r--libvo/vo_directfb2.c6
-rw-r--r--libvo/vo_gl.c36
-rw-r--r--libvo/vo_gl2.c15
-rw-r--r--libvo/vo_kva.c6
-rw-r--r--libvo/vo_sdl.c138
-rw-r--r--libvo/w32_common.c11
-rw-r--r--libvo/x11_common.c13
15 files changed, 396 insertions, 211 deletions
diff --git a/libvo/gl_common.c b/libvo/gl_common.c
index bb2e7ce10c..800e5e6d7d 100644
--- a/libvo/gl_common.c
+++ b/libvo/gl_common.c
@@ -1,7 +1,7 @@
/*
* common OpenGL routines
*
- * copyleft (C) 2005 Reimar Döffinger <Reimar.Doeffinger@stud.uni-karlsruhe.de>
+ * copyleft (C) 2005-2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
* Special thanks go to the xine team and Matthias Hopf, whose video_out_opengl.c
* gave me lots of good ideas.
*
@@ -35,6 +35,7 @@
#include "old_vo_defines.h"
#include "gl_common.h"
#include "csputils.h"
+#include "aspect.h"
void (GLAPIENTRY *mpglBegin)(GLenum);
void (GLAPIENTRY *mpglEnd)(void);
@@ -350,8 +351,24 @@ int glFindFormat(uint32_t fmt, int *bpp, GLint *gl_texfmt,
return supported;
}
-static void *setNull(const GLubyte *s) {
- return NULL;
+#ifdef HAVE_LIBDL
+#include <dlfcn.h>
+#endif
+/**
+ * \brief find address of a linked function
+ * \param s name of function to find
+ * \return address of function or NULL if not found
+ */
+static void *getdladdr(const char *s) {
+ void *ret = NULL;
+#ifdef HAVE_LIBDL
+ void *handle = dlopen(NULL, RTLD_LAZY);
+ if (!handle)
+ return NULL;
+ ret = dlsym(handle, s);
+ dlclose(handle);
+#endif
+ return ret;
}
typedef struct {
@@ -461,7 +478,7 @@ static void getFunctions(void *(*getProcAddress)(const GLubyte *),
char *allexts;
if (!getProcAddress)
- getProcAddress = setNull;
+ getProcAddress = (void *)getdladdr;
// special case, we need glGetString before starting to find the other functions
mpglGetString = getProcAddress("glGetString");
@@ -1385,6 +1402,8 @@ static void glSetupYUVFragprog(gl_conversion_params_t *params) {
*/
int glAutodetectYUVConversion(void) {
const char *extensions = mpglGetString(GL_EXTENSIONS);
+ if (!extensions || !mpglMultiTexCoord2f)
+ return YUV_CONVERSION_NONE;
if (strstr(extensions, "GL_ARB_fragment_program"))
return YUV_CONVERSION_FRAGMENT;
if (strstr(extensions, "GL_ATI_text_fragment_shader"))
@@ -1493,12 +1512,16 @@ void glDisableYUVConversion(GLenum target, int type) {
mpglDisable(GL_FRAGMENT_SHADER_ATI);
break;
case YUV_CONVERSION_TEXT_FRAGMENT:
+ mpglDisable(GL_TEXT_FRAGMENT_SHADER_ATI);
+ // HACK: at least the Mac OS X 10.5 PPC Radeon drivers are broken and
+ // without this disable the texture units while the program is still
+ // running (10.4 PPC seems to work without this though).
+ mpglFlush();
mpglActiveTexture(GL_TEXTURE1);
mpglDisable(target);
mpglActiveTexture(GL_TEXTURE2);
mpglDisable(target);
mpglActiveTexture(GL_TEXTURE0);
- mpglDisable(GL_TEXT_FRAGMENT_SHADER_ATI);
break;
case YUV_CONVERSION_FRAGMENT_LOOKUP3D:
case YUV_CONVERSION_FRAGMENT_LOOKUP:
@@ -1669,26 +1692,7 @@ static void swapGlBuffers_w32(MPGLContext *ctx) {
}
#endif
#ifdef CONFIG_GL_X11
-#ifdef HAVE_LIBDL
-#include <dlfcn.h>
-#endif
#include "x11_common.h"
-/**
- * \brief find address of a linked function
- * \param s name of function to find
- * \return address of function or NULL if not found
- */
-static void *getdladdr(const char *s) {
- void *ret = NULL;
-#ifdef HAVE_LIBDL
- void *handle = dlopen(NULL, RTLD_LAZY);
- if (!handle)
- return NULL;
- ret = dlsym(handle, s);
- dlclose(handle);
-#endif
- return ret;
-}
/**
* \brief Returns the XVisualInfo associated with Window win.
@@ -1788,8 +1792,6 @@ static int setGlWindow_x11(MPGLContext *ctx)
getProcAddress = getdladdr("glXGetProcAddress");
if (!getProcAddress)
getProcAddress = getdladdr("glXGetProcAddressARB");
- if (!getProcAddress)
- getProcAddress = (void *)getdladdr;
glXExtStr = getdladdr("glXQueryExtensionsString");
if (glXExtStr)
appendstr(&glxstr, glXExtStr(mDisplay, DefaultScreen(mDisplay)));
@@ -1802,10 +1804,10 @@ static int setGlWindow_x11(MPGLContext *ctx)
getFunctions(getProcAddress, glxstr);
if (!mpglGenPrograms && mpglGetString &&
- getProcAddress != (void *)getdladdr &&
+ getProcAddress &&
strstr(mpglGetString(GL_EXTENSIONS), "GL_ARB_vertex_program")) {
mp_msg(MSGT_VO, MSGL_WARN, "Broken glXGetProcAddress detected, trying workaround\n");
- getFunctions((void *)getdladdr, glxstr);
+ getFunctions(NULL, glxstr);
}
free(glxstr);
@@ -1863,8 +1865,76 @@ static void gl_ontop(void)
}
#endif
+#ifdef CONFIG_GL_SDL
+#include "sdl_common.h"
+
+static void swapGlBuffers_sdl(MPGLContext *ctx) {
+ SDL_GL_SwapBuffers();
+}
+
+static void *sdlgpa(const GLubyte *name) {
+ return SDL_GL_GetProcAddress(name);
+}
+
+static int setGlWindow_sdl(MPGLContext *ctx) {
+ if (sdl_set_mode(0, SDL_OPENGL | SDL_RESIZABLE) < 0)
+ return SET_WINDOW_FAILED;
+ SDL_GL_LoadLibrary(NULL);
+ getFunctions(sdlgpa, NULL);
+ return SET_WINDOW_OK;
+}
+
+static int sdl_check_events(void) {
+ int res = 0;
+ SDL_Event event;
+ while (SDL_PollEvent(&event)) {
+ res |= sdl_default_handle_event(&event);
+ }
+ // poll "events" from within MPlayer code
+ res |= sdl_default_handle_event(NULL);
+ if (res & VO_EVENT_RESIZE)
+ sdl_set_mode(0, SDL_OPENGL | SDL_RESIZABLE);
+ return res;
+}
+
+#endif
+
+static int setGlWindow_dummy(MPGLContext *ctx) {
+ getFunctions(NULL, NULL);
+ return SET_WINDOW_OK;
+}
+
+static void releaseGlContext_dummy(MPGLContext *ctx) {
+}
+
+static int dummy_check_events(void) {
+ return 0;
+}
+
+static void dummy_update_xinerama_info(void) {
+ if (vo_screenwidth <= 0 || vo_screenheight <= 0) {
+ mp_msg(MSGT_VO, MSGL_ERR, "You must specify the screen dimensions "
+ "with -screenw and -screenh\n");
+ vo_screenwidth = 1280;
+ vo_screenheight = 768;
+ }
+ aspect_save_screenres(vo_screenwidth, vo_screenheight);
+}
+
int init_mpglcontext(MPGLContext *ctx, enum MPGLType type) {
+ if (type == GLTYPE_AUTO) {
+ int res = init_mpglcontext(ctx, GLTYPE_W32);
+ if (res) return res;
+ res = init_mpglcontext(ctx, GLTYPE_X11);
+ if (res) return res;
+ res = init_mpglcontext(ctx, GLTYPE_SDL);
+ return res;
+ }
memset(ctx, 0, sizeof(*ctx));
+ ctx->setGlWindow = setGlWindow_dummy;
+ ctx->releaseGlContext = releaseGlContext_dummy;
+ ctx->update_xinerama_info = dummy_update_xinerama_info;
+ ctx->check_events = dummy_check_events;
ctx->type = type;
switch (ctx->type) {
#ifdef CONFIG_GL_WIN32
@@ -1891,6 +1961,15 @@ int init_mpglcontext(MPGLContext *ctx, enum MPGLType type) {
ctx->ontop = gl_ontop;
return vo_init();
#endif
+#ifdef CONFIG_GL_SDL
+ case GLTYPE_SDL:
+ SDL_Init(SDL_INIT_VIDEO);
+ ctx->setGlWindow = setGlWindow_sdl;
+ ctx->swapGlBuffers = swapGlBuffers_sdl;
+ ctx->check_events = sdl_check_events;
+ ctx->fullscreen = vo_sdl_fullscreen;
+ return vo_sdl_init();
+#endif
default:
return 0;
}
@@ -1909,6 +1988,11 @@ void uninit_mpglcontext(MPGLContext *ctx) {
vo_x11_uninit();
break;
#endif
+#ifdef CONFIG_GL_SDL
+ case GLTYPE_SDL:
+ vo_sdl_uninit();
+ break;
+#endif
}
memset(ctx, 0, sizeof(*ctx));
}
diff --git a/libvo/gl_common.h b/libvo/gl_common.h
index 5cf4d2859e..534bc908c1 100644
--- a/libvo/gl_common.h
+++ b/libvo/gl_common.h
@@ -41,6 +41,9 @@
// This old-vo wrapper macro would conflict with the struct member
#undef update_xinerama_info
#endif
+#ifdef CONFIG_GL_SDL
+#include <GL/gl.h>
+#endif
// workaround for some gl.h headers
#ifndef GLAPIENTRY
@@ -372,8 +375,10 @@ void glDisableYUVConversion(GLenum target, int type);
/** \} */
enum MPGLType {
+ GLTYPE_AUTO,
GLTYPE_W32,
GLTYPE_X11,
+ GLTYPE_SDL,
};
typedef struct MPGLContext {
diff --git a/libvo/osx_common.c b/libvo/osx_common.c
index b3e39a62aa..315f4dbd13 100644
--- a/libvo/osx_common.c
+++ b/libvo/osx_common.c
@@ -77,7 +77,7 @@
#define kVK_UpArrow 0x7e
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED <= 1040 */
-static const struct keymap keymap[] = {
+static const struct mp_keymap keymap[] = {
// special keys
{0x34, KEY_ENTER}, // Enter key on some iBooks?
{kVK_Return, KEY_ENTER},
diff --git a/libvo/sdl_common.c b/libvo/sdl_common.c
new file mode 100644
index 0000000000..89ed0198e4
--- /dev/null
+++ b/libvo/sdl_common.c
@@ -0,0 +1,163 @@
+/*
+ * common SDL routines
+ *
+ * This file is part of MPlayer.
+ *
+ * MPlayer is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MPlayer is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with MPlayer; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "sdl_common.h"
+#include "old_vo_defines.h"
+#include "mp_msg.h"
+#include "mp_fifo.h"
+#include "osdep/keycodes.h"
+#include "input/input.h"
+#include "input/mouse.h"
+#include "video_out.h"
+
+static int old_w;
+static int old_h;
+static int mode_flags;
+static int reinit;
+
+int vo_sdl_init(void)
+{
+ reinit = 0;
+
+ if (!SDL_WasInit(SDL_INIT_VIDEO) &&
+ SDL_Init(SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE) < 0)
+ return 0;
+
+ // Setup Keyrepeats (500/30 are defaults)
+ SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, 100 /*SDL_DEFAULT_REPEAT_INTERVAL*/);
+
+ // Easiest way to get uppercase characters
+ SDL_EnableUNICODE(1);
+
+ // We don't want those in our event queue.
+ SDL_EventState(SDL_ACTIVEEVENT, SDL_IGNORE);
+ SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE);
+ SDL_EventState(SDL_USEREVENT, SDL_IGNORE);
+
+ return 1;
+}
+
+void vo_sdl_uninit(void)
+{
+ if (SDL_WasInit(SDL_INIT_VIDEO))
+ SDL_QuitSubSystem(SDL_INIT_VIDEO);
+}
+
+void vo_sdl_fullscreen(void)
+{
+ if (vo_fs) {
+ vo_dwidth = old_w;
+ vo_dheight = old_h;
+ } else {
+ old_w = vo_dwidth;
+ old_h = vo_dheight;
+ vo_dwidth = vo_screenwidth;
+ vo_dheight = vo_screenheight;
+ }
+ vo_fs = !vo_fs;
+ sdl_set_mode(0, mode_flags);
+ // on OSX at least we now need to do a full reinit.
+ // TODO: this should only be set if really necessary.
+ reinit = 1;
+}
+
+int sdl_set_mode(int bpp, uint32_t flags)
+{
+ SDL_Surface *s;
+ mode_flags = flags;
+ if (vo_fs) flags |= SDL_FULLSCREEN;
+ // doublebuf with opengl creates flickering
+ if (vo_doublebuffering && !(flags & SDL_OPENGL))
+ flags |= SDL_DOUBLEBUF;
+ s = SDL_SetVideoMode(vo_dwidth, vo_dheight, bpp, flags);
+ if (!s) {
+ mp_msg(MSGT_VO, MSGL_FATAL, "SDL SetVideoMode failed: %s\n", SDL_GetError());
+ return -1;
+ }
+ vo_dwidth = s->w;
+ vo_dheight = s->h;
+ return 0;
+}
+
+static const struct mp_keymap keysym_map[] = {
+ {SDLK_RETURN, KEY_ENTER}, {SDLK_ESCAPE, KEY_ESC},
+ {SDLK_F1, KEY_F+1}, {SDLK_F2, KEY_F+2}, {SDLK_F3, KEY_F+3},
+ {SDLK_F4, KEY_F+4}, {SDLK_F5, KEY_F+5}, {SDLK_F6, KEY_F+6},
+ {SDLK_F7, KEY_F+7}, {SDLK_F8, KEY_F+8}, {SDLK_F9, KEY_F+9},
+ {SDLK_F10, KEY_F+10}, {SDLK_F11, KEY_F+11}, {SDLK_F12, KEY_F+12},
+ {SDLK_KP_PLUS, '+'}, {SDLK_KP_MINUS, '-'}, {SDLK_TAB, KEY_TAB},
+ {SDLK_PAGEUP, KEY_PAGE_UP}, {SDLK_PAGEDOWN, KEY_PAGE_DOWN},
+ {SDLK_UP, KEY_UP}, {SDLK_DOWN, KEY_DOWN},
+ {SDLK_LEFT, KEY_LEFT}, {SDLK_RIGHT, KEY_RIGHT},
+ {SDLK_KP_MULTIPLY, '*'}, {SDLK_KP_DIVIDE, '/'},
+ {SDLK_KP0, KEY_KP0}, {SDLK_KP1, KEY_KP1}, {SDLK_KP2, KEY_KP2},
+ {SDLK_KP3, KEY_KP3}, {SDLK_KP4, KEY_KP4}, {SDLK_KP5, KEY_KP5},
+ {SDLK_KP6, KEY_KP6}, {SDLK_KP7, KEY_KP7}, {SDLK_KP8, KEY_KP8},
+ {SDLK_KP9, KEY_KP9},
+ {SDLK_KP_PERIOD, KEY_KPDEC}, {SDLK_KP_ENTER, KEY_KPENTER},
+};
+
+int sdl_default_handle_event(SDL_Event *event)
+{
+ int mpkey;
+ if (!event) {
+ int res = reinit ? VO_EVENT_REINIT : 0;
+ reinit = 0;
+ return res;
+ }
+ switch (event->type) {
+ case SDL_VIDEORESIZE:
+ vo_dwidth = event->resize.w;
+ vo_dheight = event->resize.h;
+ return VO_EVENT_RESIZE;
+
+ case SDL_VIDEOEXPOSE:
+ return VO_EVENT_EXPOSE;
+
+ case SDL_MOUSEMOTION:
+ vo_mouse_movement(global_vo, event->motion.x, event->motion.y);
+ break;
+
+ case SDL_MOUSEBUTTONDOWN:
+ if (!vo_nomouse_input)
+ mplayer_put_key((MOUSE_BTN0 + event->button.button - 1) | MP_KEY_DOWN);
+ break;
+
+ case SDL_MOUSEBUTTONUP:
+ if (!vo_nomouse_input)
+ mplayer_put_key(MOUSE_BTN0 + event->button.button - 1);
+ break;
+
+ case SDL_KEYDOWN:
+ mpkey = lookup_keymap_table(keysym_map, event->key.keysym.sym);
+ if (!mpkey &&
+ event->key.keysym.unicode > 0 &&
+ event->key.keysym.unicode < 128)
+ mpkey = event->key.keysym.unicode;
+ if (mpkey)
+ mplayer_put_key(mpkey);
+ break;
+
+ case SDL_QUIT:
+ mplayer_put_key(KEY_CLOSE_WIN);
+ break;
+ }
+ return 0;
+}
diff --git a/libvo/sdl_common.h b/libvo/sdl_common.h
new file mode 100644
index 0000000000..cc9ec60e21
--- /dev/null
+++ b/libvo/sdl_common.h
@@ -0,0 +1,37 @@
+/*
+ * common SDL routines
+ *
+ * This file is part of MPlayer.
+ *
+ * MPlayer is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MPlayer is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with MPlayer; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef MPLAYER_SDL_COMMON_H
+#define MPLAYER_SDL_COMMON_H
+
+#include "config.h"
+#ifdef CONFIG_SDL_SDL_H
+#include <SDL/SDL.h>
+#else
+#include <SDL.h>
+#endif
+
+int vo_sdl_init(void);
+void vo_sdl_uninit(void);
+void vo_sdl_fullscreen(void);
+int sdl_set_mode(int bpp, uint32_t flags);
+int sdl_default_handle_event(SDL_Event *event);
+
+#endif /* MPLAYER_SDL_COMMON_H */
diff --git a/libvo/video_out.c b/libvo/video_out.c
index 92dfcf47b6..25a988e4f1 100644
--- a/libvo/video_out.c
+++ b/libvo/video_out.c
@@ -34,6 +34,7 @@
#include "aspect.h"
#include "geometry.h"
#include "old_vo_wrapper.h"
+#include "input/input.h"
#include "mp_msg.h"
@@ -478,7 +479,7 @@ int vo_config(struct vo *vo, uint32_t width, uint32_t height,
* \result translation corresponding to key or "to" value of last mapping
* if not found.
*/
-int lookup_keymap_table(const struct keymap *map, int key) {
+int lookup_keymap_table(const struct mp_keymap *map, int key) {
while (map->from && map->from != key) map++;
return map->to;
}
@@ -555,6 +556,22 @@ void calc_src_dst_rects(struct vo *vo, int src_width, int src_height,
dst->height = dst->bottom - dst->top;
}
+/**
+ * Generates a mouse movement message if those are enable and sends it
+ * to the "main" MPlayer.
+ *
+ * \param posx new x position of mouse
+ * \param posy new y position of mouse
+ */
+void vo_mouse_movement(struct vo *vo, int posx, int posy)
+{
+ char cmd_str[40];
+ if (!enable_mouse_movements)
+ return;
+ snprintf(cmd_str, sizeof(cmd_str), "set_mouse_pos %i %i", posx, posy);
+ mp_input_queue_cmd(vo->input_ctx, mp_input_parse_cmd(cmd_str));
+}
+
#if defined(CONFIG_FBDEV) || defined(CONFIG_VESA)
/* Borrowed from vo_fbdev.c
Monitor ranges related functions*/
diff --git a/libvo/video_out.h b/libvo/video_out.h
index 0b5f71255c..1bdf74da96 100644
--- a/libvo/video_out.h
+++ b/libvo/video_out.h
@@ -35,6 +35,7 @@
#define VO_EVENT_EXPOSE 1
#define VO_EVENT_RESIZE 2
#define VO_EVENT_KEYPRESS 4
+#define VO_EVENT_REINIT 8
/* Obsolete: VOCTRL_QUERY_VAA 1 */
/* does the device support the required format */
@@ -311,6 +312,7 @@ extern int vo_rootwin;
extern int vo_border;
extern int vo_nomouse_input;
+extern int enable_mouse_movements;
extern int vo_pts;
extern float vo_fps;
@@ -336,17 +338,19 @@ extern char *monitor_hfreq_str;
extern char *monitor_vfreq_str;
extern char *monitor_dotclock_str;
-struct keymap {
+struct mp_keymap {
int from;
int to;
};
-int lookup_keymap_table(const struct keymap *map, int key);
+int lookup_keymap_table(const struct mp_keymap *map, int key);
struct vo_rect {
int left, right, top, bottom, width, height;
};
void calc_src_dst_rects(struct vo *vo, int src_width, int src_height,
struct vo_rect *src, struct vo_rect *dst,
struct vo_rect *borders, const struct vo_rect *crop);
+struct input_ctx;
+void vo_mouse_movement(struct vo *vo, int posx, int posy);
static inline int aspect_scaling(void)
{
diff --git a/libvo/vo_corevideo.m b/libvo/vo_corevideo.m
index 17086e7cb8..e40ae9c20b 100644
--- a/libvo/vo_corevideo.m
+++ b/libvo/vo_corevideo.m
@@ -83,7 +83,6 @@ static uint32_t image_format;
static int isFullscreen;
static int isOntop;
static int isRootwin;
-extern int enable_mouse_movements;
static float winAlpha = 1;
static int int_pause = 0;
@@ -954,11 +953,8 @@ static int control(uint32_t request, void *data)
if (enable_mouse_movements && !isRootwin) {
NSPoint p =[self convertPoint:[theEvent locationInWindow] fromView:nil];
if ([self mouse:p inRect:textureFrame]) {
- char cmdstr[40];
- snprintf(cmdstr, sizeof(cmdstr), "set_mouse_pos %i %i",
- (int)(vo_fs ? p.x : (p.x - textureFrame.origin.x)),
- (int)(vo_fs ? [self frame].size.height - p.y: (NSMaxY(textureFrame) - p.y)));
- mp_input_queue_cmd(global_vo->input_ctx, mp_input_parse_cmd(cmdstr));
+ vo_mouse_movement(global_vo, vo_fs ? p.x : p.x - textureFrame.origin.x,
+ vo_fs ? [self frame].size.height - p.y : NSMaxY(textureFrame) - p.y);
}
}
}
diff --git a/libvo/vo_directfb2.c b/libvo/vo_directfb2.c
index 4a88b3881e..673882dd49 100644
--- a/libvo/vo_directfb2.c
+++ b/libvo/vo_directfb2.c
@@ -34,12 +34,6 @@
#include <stdlib.h>
#include <string.h>
-#ifdef __linux__
-#include <sys/kd.h>
-#else
-#include <linux/kd.h>
-#endif
-
#include "config.h"
#include "video_out.h"
#include "video_out_internal.h"
diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c
index 5babb180b3..00c0d62167 100644
--- a/libvo/vo_gl.c
+++ b/libvo/vo_gl.c
@@ -34,6 +34,14 @@
#include "fastmemcpy.h"
#include "ass_mp.h"
+#ifdef CONFIG_GL_SDL
+#ifdef CONFIG_SDL_SDL_H
+#include <SDL/SDL.h>
+#else
+#include <SDL.h>
+#endif
+#endif
+
static const vo_info_t info =
{
"OpenGL",
@@ -485,7 +493,7 @@ static void autodetectGlExtensions(void) {
const char *extensions = mpglGetString(GL_EXTENSIONS);
const char *vendor = mpglGetString(GL_VENDOR);
const char *version = mpglGetString(GL_VERSION);
- int is_ati = strstr(vendor, "ATI") != NULL;
+ int is_ati = vendor && strstr(vendor, "ATI") != NULL;
int ati_broken_pbo = 0;
mp_msg(MSGT_VO, MSGL_V, "[gl] Running on OpenGL by '%s', versions '%s'\n", vendor, version);
if (is_ati && strncmp(version, "2.1.", 4) == 0) {
@@ -494,8 +502,12 @@ static void autodetectGlExtensions(void) {
ati_broken_pbo = ver && ver < 8395;
}
if (ati_hack == -1) ati_hack = ati_broken_pbo;
- if (force_pbo == -1) force_pbo = strstr(extensions, "_pixel_buffer_object") ? is_ati : 0;
- if (use_rectangle == -1) use_rectangle = strstr(extensions, "_texture_non_power_of_two") ? 0 : 0;
+ if (extensions && force_pbo == -1)
+ force_pbo = strstr(extensions, "_pixel_buffer_object") ? is_ati : 0;
+ if (extensions && use_rectangle == -1)
+ use_rectangle = strstr(extensions, "_texture_non_power_of_two") ? 0 : 0;
+ if (use_osd == -1)
+ use_osd = mpglBindTexture != NULL;
if (use_yuv == -1)
use_yuv = glAutodetectYUVConversion();
if (is_ati && (lscale == 1 || lscale == 2 || cscale == 1 || cscale == 2))
@@ -600,6 +612,13 @@ static int create_window(uint32_t d_width, uint32_t d_height, uint32_t flags, co
"gl", title);
}
#endif
+#ifdef CONFIG_GL_SDL
+ if (glctx.type == GLTYPE_SDL) {
+ SDL_WM_SetCaption(title, NULL);
+ vo_dwidth = d_width;
+ vo_dheight = d_height;
+ }
+#endif
return 0;
}
@@ -639,6 +658,10 @@ glconfig:
static void check_events(void)
{
int e=glctx.check_events();
+ if(e&VO_EVENT_REINIT) {
+ uninitGl();
+ initGl(vo_dwidth, vo_dheight);
+ }
if(e&VO_EVENT_RESIZE) resize(vo_dwidth,vo_dheight);
if(e&VO_EVENT_EXPOSE && int_pause) redraw();
}
@@ -1084,13 +1107,10 @@ static const opt_t subopts[] = {
static int preinit_internal(const char *arg, int allow_sw)
{
- enum MPGLType gltype = GLTYPE_X11;
// set defaults
-#ifdef CONFIG_GL_WIN32
- gltype = GLTYPE_W32;
-#endif
+ enum MPGLType gltype = GLTYPE_AUTO;
many_fmts = 1;
- use_osd = 1;
+ use_osd = -1;
scaled_osd = 0;
use_aspect = 1;
use_ycbcr = 0;
diff --git a/libvo/vo_gl2.c b/libvo/vo_gl2.c
index dafaa1e60a..4fb126d5c5 100644
--- a/libvo/vo_gl2.c
+++ b/libvo/vo_gl2.c
@@ -473,8 +473,9 @@ static int config_w32(uint32_t width, uint32_t height, uint32_t d_width, uint32_
return 0;
}
-#else
+#endif
+#ifdef CONFIG_GL_X11
static int choose_glx_visual(Display *dpy, int scr, XVisualInfo *res_vi)
{
XVisualInfo template, *vi_list;
@@ -620,7 +621,8 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
#ifdef CONFIG_GL_WIN32
if (config_w32(width, height, d_width, d_height, flags, title, format) == -1)
-#else
+#endif
+#ifdef CONFIG_GL_X11
if (config_glx(width, height, d_width, d_height, flags, title, format) == -1)
#endif
return -1;
@@ -668,7 +670,7 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
return 0;
}
-#ifndef CONFIG_GL_WIN32
+#ifdef CONFIG_GL_X11
static int gl_handlekey(int key)
{
if(key=='a'||key=='A') {
@@ -685,7 +687,7 @@ static int gl_handlekey(int key)
static void check_events(void)
{
int e;
-#ifndef CONFIG_GL_WIN32
+#ifdef CONFIG_GL_X11
XEvent Event;
char buf[100];
KeySym keySym;
@@ -866,7 +868,8 @@ static int preinit(const char *arg)
if (use_yuv == -1) {
#ifdef CONFIG_GL_WIN32
if (config_w32(320, 200, 320, 200, VOFLAG_HIDDEN, "", 0) == -1)
-#else
+#endif
+#ifdef CONFIG_GL_X11
if (config_glx(320, 200, 320, 200, VOFLAG_HIDDEN, "", 0) == -1)
#endif
goto err_out;
@@ -907,7 +910,7 @@ static int control(uint32_t request, void *data)
case VOCTRL_SET_PANSCAN:
resize(vo_dwidth, vo_dheight);
return VO_TRUE;
-#ifndef CONFIG_GL_WIN32
+#ifdef CONFIG_GL_X11
case VOCTRL_SET_EQUALIZER:
{
struct voctrl_set_equalizer_args *args = data;
diff --git a/libvo/vo_kva.c b/libvo/vo_kva.c
index 07f6629769..e75f44dbe5 100644
--- a/libvo/vo_kva.c
+++ b/libvo/vo_kva.c
@@ -69,7 +69,7 @@ const LIBVO_EXTERN(kva)
#define HWNDFROMWINID(wid) ((wid) + 0x80000000UL)
-static const struct keymap m_vk_map[] = {
+static const struct mp_keymap m_vk_map[] = {
{VK_NEWLINE, KEY_ENTER}, {VK_TAB, KEY_TAB}, {VK_SPACE, ' '},
// control keys
@@ -91,7 +91,7 @@ static const struct keymap m_vk_map[] = {
{0, 0}
};
-static const struct keymap m_keypad_map[] = {
+static const struct mp_keymap m_keypad_map[] = {
// keypad keys
{0x52, KEY_KP0}, {0x4F, KEY_KP1}, {0x50, KEY_KP2}, {0x51, KEY_KP3},
{0x4B, KEY_KP4}, {0x4C, KEY_KP5}, {0x4D, KEY_KP6}, {0x47, KEY_KP7},
@@ -100,7 +100,7 @@ static const struct keymap m_keypad_map[] = {
{0, 0}
};
-static const struct keymap m_mouse_map[] = {
+static const struct mp_keymap m_mouse_map[] = {
{WM_BUTTON1DOWN, MOUSE_BTN0},
{WM_BUTTON3DOWN, MOUSE_BTN1},
{WM_BUTTON2DOWN, MOUSE_BTN2},
diff --git a/libvo/vo_sdl.c b/libvo/vo_sdl.c
index 9ae325b98a..9715dd98fb 100644
--- a/libvo/vo_sdl.c
+++ b/libvo/vo_sdl.c
@@ -48,8 +48,6 @@
/* define to enable surface locks, this might be needed on SMP machines */
#undef SDL_ENABLE_LOCKS
-//#define BUGGY_SDL //defined by configure
-
/* MONITOR_ASPECT MUST BE FLOAT */
#define MONITOR_ASPECT 4.0/3.0
@@ -74,10 +72,7 @@
#include "x11_common.h"
#endif
-#include "input/input.h"
-#include "input/mouse.h"
#include "subopt-helper.h"
-#include "mp_fifo.h"
static const vo_info_t info =
{
@@ -89,11 +84,7 @@ static const vo_info_t info =
const LIBVO_EXTERN(sdl)
-#ifdef CONFIG_SDL_SDL_H
-#include <SDL/SDL.h>
-#else
-#include <SDL.h>
-#endif
+#include "sdl_common.h"
//#include <SDL/SDL_syswm.h>
@@ -405,9 +396,6 @@ static int sdl_open (void *plugin, void *name)
priv->sdlflags |= SDL_DOUBLEBUF;
#endif
- /* Setup Keyrepeats (500/30 are defaults) */
- SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, 100 /*SDL_DEFAULT_REPEAT_INTERVAL*/);
-
/* get information about the graphics adapter */
vidInfo = SDL_GetVideoInfo ();
@@ -452,18 +440,6 @@ static int sdl_open (void *plugin, void *name)
priv->bpp = 16;
}
- /* We don't want those in our event queue.
- * We use SDL_KEYUP cause SDL_KEYDOWN seems to cause problems
- * with keys need to be pressed twice, to be recognized.
- */
-#ifndef BUGGY_SDL
- SDL_EventState(SDL_ACTIVEEVENT, SDL_IGNORE);
- SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
-// SDL_EventState(SDL_QUIT, SDL_IGNORE);
- SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE);
- SDL_EventState(SDL_USEREVENT, SDL_IGNORE);
-#endif
-
/* Success! */
return 0;
}
@@ -606,6 +582,8 @@ static void set_video_mode(int width, int height, int bpp, uint32_t sdlflags)
priv->surface = newsurface;
priv->dstwidth = width;
priv->dstheight = height;
+ vo_dwidth = width;
+ vo_dheight = height;
setup_surfaces();
}
@@ -1101,9 +1079,6 @@ static int draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
* returns : doesn't return
**/
-#include "osdep/keycodes.h"
-
-#define shift_key (event.key.keysym.mod==(KMOD_LSHIFT||KMOD_RSHIFT))
static void check_events (void)
{
struct sdl_priv_s *priv = &sdl_priv;
@@ -1127,39 +1102,8 @@ static void check_events (void)
mp_msg(MSGT_VO,MSGL_DBG3, "SDL: Window resize\n");
break;
- case SDL_MOUSEBUTTONDOWN:
- if(vo_nomouse_input)
- break;
- mplayer_put_key((MOUSE_BTN0+event.button.button-1) | MP_KEY_DOWN);
- break;
-
- case SDL_MOUSEBUTTONUP:
- if(vo_nomouse_input)
- break;
- mplayer_put_key(MOUSE_BTN0+event.button.button-1);
- break;
-
/* graphics mode selection shortcuts */
-#ifdef BUGGY_SDL
- case SDL_KEYDOWN:
- switch(event.key.keysym.sym) {
- case SDLK_UP: mplayer_put_key(KEY_UP); break;
- case SDLK_DOWN: mplayer_put_key(KEY_DOWN); break;
- case SDLK_LEFT: mplayer_put_key(KEY_LEFT); break;
- case SDLK_RIGHT: mplayer_put_key(KEY_RIGHT); break;
- case SDLK_LESS: mplayer_put_key(shift_key?'>':'<'); break;
- case SDLK_GREATER: mplayer_put_key('>'); break;
- case SDLK_ASTERISK:
- case SDLK_KP_MULTIPLY:
- case SDLK_SLASH:
- case SDLK_KP_DIVIDE:
- default: break;
- }
- break;
- case SDL_KEYUP:
-#else
case SDL_KEYDOWN:
-#endif
keypressed = event.key.keysym.sym;
mp_msg(MSGT_VO,MSGL_DBG2, "SDL: Key pressed: '%i'\n", keypressed);
@@ -1191,78 +1135,13 @@ static void check_events (void)
}
}
- else switch(keypressed){
- case SDLK_RETURN: mplayer_put_key(KEY_ENTER);break;
- case SDLK_ESCAPE: mplayer_put_key(KEY_ESC);break;
- case SDLK_q: mplayer_put_key('q');break;
- case SDLK_F1: mplayer_put_key(KEY_F+1);break;
- case SDLK_F2: mplayer_put_key(KEY_F+2);break;
- case SDLK_F3: mplayer_put_key(KEY_F+3);break;
- case SDLK_F4: mplayer_put_key(KEY_F+4);break;
- case SDLK_F5: mplayer_put_key(KEY_F+5);break;
- case SDLK_F6: mplayer_put_key(KEY_F+6);break;
- case SDLK_F7: mplayer_put_key(KEY_F+7);break;
- case SDLK_F8: mplayer_put_key(KEY_F+8);break;
- case SDLK_F9: mplayer_put_key(KEY_F+9);break;
- case SDLK_F10: mplayer_put_key(KEY_F+10);break;
- case SDLK_F11: mplayer_put_key(KEY_F+11);break;
- case SDLK_F12: mplayer_put_key(KEY_F+12);break;
- /*case SDLK_o: mplayer_put_key('o');break;
- case SDLK_SPACE: mplayer_put_key(' ');break;
-