diff options
author | wm4 <wm4@nowhere> | 2015-12-19 14:17:06 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-12-19 14:19:08 +0100 |
commit | 575965a91c65544f10f9b5a2c9181f0bddc81f7a (patch) | |
tree | b6b7938504f875b6fef5418b97a98846b725e146 | |
parent | a0519f1d188e3d3be8f0e78a71868d7cbf1cc11d (diff) | |
download | mpv-575965a91c65544f10f9b5a2c9181f0bddc81f7a.tar.bz2 mpv-575965a91c65544f10f9b5a2c9181f0bddc81f7a.tar.xz |
half-working alpha on windowswin32-alpha
doesn't redraw the "background" properly - compositor bug?
http://stackoverflow.com/questions/4052940/how-to-make-an-opengl-
rendering-context-with-transparent-background
-rw-r--r-- | video/out/opengl/context_w32.c | 21 | ||||
-rw-r--r-- | video/out/w32_common.c | 7 |
2 files changed, 25 insertions, 3 deletions
diff --git a/video/out/opengl/context_w32.c b/video/out/opengl/context_w32.c index 5157cd97a5..02b748db42 100644 --- a/video/out/opengl/context_w32.c +++ b/video/out/opengl/context_w32.c @@ -49,6 +49,22 @@ static int GLAPIENTRY w32_swap_interval(int interval) return 0; } +static void enable_transparency(struct MPGLContext *ctx, + PIXELFORMATDESCRIPTOR *pfd) +{ + HWND win = vo_w32_hwnd(ctx->vo); + pfd->dwFlags |= PFD_SUPPORT_COMPOSITION; + pfd->cAlphaBits = 8; + pfd->cColorBits += pfd->cAlphaBits; + + DWM_BLURBEHIND bb = { + .hRgnBlur = CreateRectRgn(0, 0, -1, -1), + .dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION, + .fEnable = TRUE, + }; + DwmEnableBlurBehindWindow(win, &bb); +} + static bool create_dc(struct MPGLContext *ctx, int flags) { struct w32_context *w32_ctx = ctx->priv; @@ -70,6 +86,10 @@ static bool create_dc(struct MPGLContext *ctx, int flags) pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = 24; pfd.iLayerType = PFD_MAIN_PLANE; + + if (flags & VOFLAG_ALPHA) + enable_transparency(ctx, &pfd); + int pf = ChoosePixelFormat(hdc, &pfd); if (!pf) { @@ -221,6 +241,7 @@ static void create_ctx(void *ptr) ctx->gl->fb_g = pfd.cGreenBits; ctx->gl->fb_b = pfd.cBlueBits; } + ctx->gl->fb_premultiplied = true; wglMakeCurrent(w32_ctx->hdc, NULL); } diff --git a/video/out/w32_common.c b/video/out/w32_common.c index 025b744838..463696cc8a 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -688,8 +688,8 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, // This message is used to wakeup the GUI thread, see wakeup_gui_thread. mp_dispatch_queue_process(w32->dispatch, 0); break; - case WM_ERASEBKGND: // no need to erase background separately - return 1; + //case WM_ERASEBKGND: // no need to erase background separately + // return 1; case WM_PAINT: signal_events(w32, VO_EVENT_EXPOSE); break; @@ -1192,6 +1192,7 @@ static void *gui_thread(void *ptr) .hIcon = LoadIconW(hInstance, L"IDI_ICON1"), .hCursor = LoadCursor(NULL, IDC_ARROW), .lpszClassName = classname, + .hbrBackground = CreateSolidBrush(0x00000000), }; RegisterClassExW(&wcex); @@ -1209,7 +1210,7 @@ static void *gui_thread(void *ptr) 0, 0, r.right, r.bottom, w32->parent, 0, hInstance, NULL); } else { - w32->window = CreateWindowExW(0, classname, + w32->window = CreateWindowExW(WS_EX_APPWINDOW, classname, classname, update_style(w32, 0), CW_USEDEFAULT, SW_HIDE, 100, 100, |