diff options
author | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2009-11-23 01:56:21 +0200 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2009-11-23 01:56:21 +0200 |
commit | 5995bc175aea0417ce7ff7285c1c8fc84ebb5704 (patch) | |
tree | 7fa0b90e03fc5b3a6447b79754b654bc279f5237 /libvo | |
parent | 4c552b2e420ba4cb6d888b12360c7bf63e7cd03a (diff) | |
parent | af2988cbcef1b057772d44b9f9752be3f15960b0 (diff) | |
download | mpv-5995bc175aea0417ce7ff7285c1c8fc84ebb5704.tar.bz2 mpv-5995bc175aea0417ce7ff7285c1c8fc84ebb5704.tar.xz |
Merge svn changes up to r29962
Diffstat (limited to 'libvo')
-rw-r--r-- | libvo/gl_common.c | 21 | ||||
-rw-r--r-- | libvo/vo_gl.c | 1 | ||||
-rw-r--r-- | libvo/vo_gl2.c | 4 | ||||
-rw-r--r-- | libvo/w32_common.c | 44 | ||||
-rw-r--r-- | libvo/w32_common.h | 2 |
5 files changed, 60 insertions, 12 deletions
diff --git a/libvo/gl_common.c b/libvo/gl_common.c index f827771a97..ca3fc7ee45 100644 --- a/libvo/gl_common.c +++ b/libvo/gl_common.c @@ -197,6 +197,10 @@ int glFindFormat(uint32_t fmt, int *bpp, GLint *gl_texfmt, *bpp = IMGFMT_IS_BGR(fmt)?IMGFMT_BGR_DEPTH(fmt):IMGFMT_RGB_DEPTH(fmt); *gl_texfmt = 3; switch (fmt) { + case IMGFMT_RGB48NE: + *gl_format = GL_RGB; + *gl_type = GL_UNSIGNED_SHORT; + break; case IMGFMT_RGB24: *gl_format = GL_RGB; *gl_type = GL_UNSIGNED_BYTE; @@ -336,7 +340,7 @@ static void getFunctions(void *(*getProcAddress)(const GLubyte *), strcpy(allexts, extensions); strcat(allexts, " "); strcat(allexts, ext2); - mp_msg(MSGT_VO, MSGL_V, "OpenGL extensions string:\n%s\n", allexts); + mp_msg(MSGT_VO, MSGL_DBG2, "OpenGL extensions string:\n%s\n", allexts); if (!getProcAddress) getProcAddress = setNull; for (dsc = extfuncs; dsc->funcptr; dsc++) { @@ -696,7 +700,7 @@ static void store_weights(float x, GLfloat *dst) { * \param unit texture unit to attach texture to */ static void gen_spline_lookup_tex(GLenum unit) { - GLfloat tex[4 * LOOKUP_BSPLINE_RES]; + GLfloat *tex = calloc(4 * LOOKUP_BSPLINE_RES, sizeof(*tex)); GLfloat *tp = tex; int i; for (i = 0; i < LOOKUP_BSPLINE_RES; i++) { @@ -713,6 +717,7 @@ static void gen_spline_lookup_tex(GLenum unit) { glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_REPEAT); ActiveTexture(GL_TEXTURE0); + free(tex); } static const char *bilin_filt_template = @@ -1162,7 +1167,7 @@ int loadGPUProgram(GLenum target, char *prog) { glGetString(GL_PROGRAM_ERROR_STRING), &prog[err]); return 0; } - if (!GetProgramiv || !mp_msg_test(MSGT_VO, MSGL_V)) + if (!GetProgramiv || !mp_msg_test(MSGT_VO, MSGL_DBG2)) return 1; mp_msg(MSGT_VO, MSGL_V, "[gl] Program statistics:\n"); for (i = 0; progstats[i].name; i++) { @@ -1258,7 +1263,7 @@ static void glSetupYUVFragprog(gl_conversion_params_t *params) { mp_msg(MSGT_VO, MSGL_ERR, "[gl] unknown conversion type %i\n", YUV_CONVERSION(type)); break; } - mp_msg(MSGT_VO, MSGL_V, "[gl] generated fragment program:\n%s\n", yuv_prog); + mp_msg(MSGT_VO, MSGL_DBG2, "[gl] generated fragment program:\n%s\n", yuv_prog); loadGPUProgram(GL_FRAGMENT_PROGRAM, yuv_prog); free(yuv_prog); } @@ -1457,7 +1462,7 @@ static void *w32gpa(const GLubyte *procName) { int setGlWindow(int *vinfo, HGLRC *context, HWND win) { int new_vinfo; - HDC windc = GetDC(win); + HDC windc = vo_w32_get_dc(win); HGLRC new_context = 0; int keep_context = 0; int res = SET_WINDOW_FAILED; @@ -1510,7 +1515,7 @@ int setGlWindow(int *vinfo, HGLRC *context, HWND win) res = SET_WINDOW_OK; out: - ReleaseDC(win, windc); + vo_w32_release_dc(win, windc); return res; } @@ -1524,9 +1529,9 @@ void releaseGlContext(int *vinfo, HGLRC *context) { } void swapGlBuffers(void) { - HDC vo_hdc = GetDC(vo_w32_window); + HDC vo_hdc = vo_w32_get_dc(vo_w32_window); SwapBuffers(vo_hdc); - ReleaseDC(vo_w32_window, vo_hdc); + vo_w32_release_dc(vo_w32_window, vo_hdc); } #else #ifdef HAVE_LIBDL diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c index 1bd908f22b..b319ecde67 100644 --- a/libvo/vo_gl.c +++ b/libvo/vo_gl.c @@ -547,6 +547,7 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin mp_msg(MSGT_VO, MSGL_ERR, "[gl] no GLX support present\n"); return -1; } + mp_msg(MSGT_VO, MSGL_V, "[gl] GLX chose visual with ID 0x%x\n", (int)vinfo->visualid); vo_x11_create_vo_window(vinfo, vo_dx, vo_dy, d_width, d_height, flags, XCreateColormap(mDisplay, mRootWin, vinfo->visual, AllocNone), diff --git a/libvo/vo_gl2.c b/libvo/vo_gl2.c index e72f735bcd..d814008f31 100644 --- a/libvo/vo_gl2.c +++ b/libvo/vo_gl2.c @@ -114,7 +114,7 @@ static GLint getInternalFormat(void) { #ifdef GL_WIN32 PIXELFORMATDESCRIPTOR pfd; - HDC vo_hdc = GetDC(vo_w32_window); + HDC vo_hdc = vo_w32_get_dc(vo_w32_window); int pf = GetPixelFormat(vo_hdc); if (!DescribePixelFormat(vo_hdc, pf, sizeof pfd, &pfd)) { r_sz = g_sz = b_sz = a_sz = 0; @@ -124,7 +124,7 @@ static GLint getInternalFormat(void) b_sz = pfd.cBlueBits; a_sz = pfd.cAlphaBits; } - ReleaseDC(vo_w32_window, vo_hdc); + vo_w32_release_dc(vo_w32_window, vo_hdc); #else if (glXGetConfig(mDisplay, gl_vinfo, GLX_RED_SIZE, &r_sz) != 0) r_sz = 0; if (glXGetConfig(mDisplay, gl_vinfo, GLX_GREEN_SIZE, &g_sz) != 0) g_sz = 0; diff --git a/libvo/w32_common.c b/libvo/w32_common.c index 99ebd76979..3b5f97de29 100644 --- a/libvo/w32_common.c +++ b/libvo/w32_common.c @@ -54,6 +54,8 @@ static uint32_t o_dheight; static HINSTANCE hInstance; #define vo_window vo_w32_window HWND vo_window = 0; +/** HDC used when rendering to a device instead of window */ +static HDC dev_hdc; static int event_flags; static int mon_cnt; @@ -331,7 +333,7 @@ static void resetMode(void) { static int createRenderingContext(void) { HWND layer = HWND_NOTOPMOST; PIXELFORMATDESCRIPTOR pfd; - HDC vo_hdc = GetDC(vo_window); + HDC vo_hdc = vo_w32_get_dc(vo_window); RECT r; int pf; if (WinID < 0) { @@ -398,7 +400,7 @@ static int createRenderingContext(void) { mp_msg(MSGT_VO, MSGL_V, "vo: win32: running at %dx%d with depth %d\n", vo_screenwidth, vo_screenheight, depthonscreen); - ReleaseDC(vo_window, vo_hdc); + vo_w32_release_dc(vo_window, vo_hdc); return 1; } @@ -433,6 +435,18 @@ int vo_w32_config(uint32_t width, uint32_t height, uint32_t flags) { } /** + * \brief return the name of the selected device if it is indepedant + */ +static char *get_display_name(void) { + DISPLAY_DEVICE disp; + disp.cb = sizeof(disp); + EnumDisplayDevices(NULL, vo_adapter_num, &disp, 0); + if (disp.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) + return NULL; + return disp.DeviceName; +} + +/** * \brief Initialize w32_common framework. * * The first function that should be called from the w32_common framework. @@ -453,6 +467,7 @@ int vo_w32_init(void) { HICON mplayerIcon = 0; char exedir[MAX_PATH]; HINSTANCE user32; + char *dev; if (vo_window) return 1; @@ -500,6 +515,9 @@ int vo_w32_init(void) { myGetMonitorInfo = GetProcAddress(user32, "GetMonitorInfoA"); myEnumDisplayMonitors = GetProcAddress(user32, "EnumDisplayMonitors"); } + dev_hdc = 0; + dev = get_display_name(); + if (dev) dev_hdc = CreateDC(dev, NULL, NULL, NULL); updateScreenProperties(); return 1; @@ -567,7 +585,29 @@ void vo_w32_uninit(void) { resetMode(); ShowCursor(1); depthonscreen = 0; + if (dev_hdc) DeleteDC(dev_hdc); + dev_hdc = 0; DestroyWindow(vo_window); vo_window = 0; UnregisterClass(classname, 0); } + +/** + * \brief get a device context to draw in + * + * \param wnd window the DC should belong to if it makes sense + */ +HDC vo_w32_get_dc(HWND wnd) { + if (dev_hdc) return dev_hdc; + return GetDC(wnd); +} + +/** + * \brief release a device context + * + * \param wnd window the DC probably belongs to + */ +void vo_w32_release_dc(HWND wnd, HDC dc) { + if (dev_hdc) return; + ReleaseDC(wnd, dc); +} diff --git a/libvo/w32_common.h b/libvo/w32_common.h index 1c7864a249..cb3bbf3504 100644 --- a/libvo/w32_common.h +++ b/libvo/w32_common.h @@ -34,5 +34,7 @@ int vo_w32_check_events(void); int vo_w32_config(uint32_t, uint32_t, uint32_t); void destroyRenderingContext(void); void w32_update_xinerama_info(void); +HDC vo_w32_get_dc(HWND wnd); +void vo_w32_release_dc(HWND wnd, HDC dc); #endif /* MPLAYER_W32_COMMON_H */ |