From 6bee9a8158eae01baa8f6db3e328e06bb2124e0b Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 24 Apr 2012 01:18:32 +0200 Subject: vo_directx: clear panscan borders in windowed mode The window size is normally clipped against desktop size due to the usage of WM_SIZING in w32_common.c. This is a useful (if accidental) feature, but vo_directx didn't handle it well: the areas not covered by video were filled with the colorkey, which looked ugly. Explicitly clear these borders with black. --- libvo/vo_directx.c | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/libvo/vo_directx.c b/libvo/vo_directx.c index 0a20e5e33a..345ee6e8d4 100644 --- a/libvo/vo_directx.c +++ b/libvo/vo_directx.c @@ -452,6 +452,35 @@ static uint32_t Directx_InitDirectDraw(void) return 0; } +static void clear_border(HDC dc, int x1, int y1, int x2, int y2) +{ + if (x2 <= x1 || y2 <= y1) + return; + FillRect(dc, &(RECT) { x1, y1, x2, y2 }, blackbrush); +} + +static void redraw_window(void) +{ + HDC dc = vo_w32_get_dc(global_vo, vo_w32_window); + RECT r; + GetClientRect(vo_w32_window, &r); + if (vo_fs || vidmode) { + FillRect(dc, &r, blackbrush); + } else { + FillRect(dc, &r, colorbrush); + // clear borders (not needed in fs; fs uses background = colorkey) + RECT rc = rd; + POINT origin = { 0, 0 }; + ClientToScreen(vo_w32_window, &origin); + OffsetRect(&rc, -origin.x, -origin.y); + clear_border(dc, r.left, r.top, r.right, rc.top); // top + clear_border(dc, r.left, rc.bottom, r.right, r.bottom); // bottom + clear_border(dc, r.left, rc.top, rc.left, rc.bottom); // left + clear_border(dc, rc.right, rc.top, r.right, rc.bottom); // right + } + vo_w32_release_dc(global_vo, vo_w32_window, dc); +} + static uint32_t Directx_ManageDisplay(void) { HRESULT ddrval; @@ -460,6 +489,8 @@ static uint32_t Directx_ManageDisplay(void) DWORD dwUpdateFlags = 0; int width, height; + redraw_window(); + POINT origin = { 0, 0 }; ClientToScreen(vo_w32_window, &origin); @@ -613,11 +644,7 @@ static void check_events(void) if (evt & (VO_EVENT_RESIZE | VO_EVENT_MOVE)) Directx_ManageDisplay(); if (evt & (VO_EVENT_RESIZE | VO_EVENT_MOVE | VO_EVENT_EXPOSE)) { - HDC dc = vo_w32_get_dc(global_vo, vo_w32_window); - RECT r; - GetClientRect(vo_w32_window, &r); - FillRect(dc, &r, vo_fs || vidmode ? blackbrush : colorbrush); - vo_w32_release_dc(global_vo, vo_w32_window, dc); + redraw_window(); } } -- cgit v1.2.3