vlc | branch: master | Steve Lhomme <[email protected]> | Mon Mar 25 13:06:55 2019 +0100| [997fd36589bc10ef554f7d6477a39c9037606ab5] | committer: Steve Lhomme
vout:win32: use the vout_display_place_t instead of RECT rect_dest This way we know we deal with the result of PlacePicture(). We don't need macros anymore to hide the field. Only log when the placement actually changed. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=997fd36589bc10ef554f7d6477a39c9037606ab5 --- modules/video_output/win32/common.c | 55 ++++++++++++++------------------- modules/video_output/win32/common.h | 6 ++-- modules/video_output/win32/direct3d11.c | 32 ++++++++++--------- modules/video_output/win32/direct3d9.c | 23 ++++++++------ modules/video_output/win32/glwin32.c | 4 +-- modules/video_output/win32/wingdi.c | 10 +++--- 6 files changed, 63 insertions(+), 67 deletions(-) diff --git a/modules/video_output/win32/common.c b/modules/video_output/win32/common.c index 303ab5c433..269b471ae1 100644 --- a/modules/video_output/win32/common.c +++ b/modules/video_output/win32/common.c @@ -80,7 +80,7 @@ int CommonInit(vout_display_t *vd, vout_display_sys_win32_t *sys, bool b_windowl sys->hvideownd = NULL; sys->hparent = NULL; sys->hfswnd = NULL; - sys->rect_dest_changed = false; + sys->place_changed = false; sys->b_windowless = b_windowless; sys->is_first_placement = true; sys->is_on_top = false; @@ -184,13 +184,31 @@ void UpdateRects(vout_display_t *vd, vout_display_sys_win32_t *sys, bool is_forc place_cfg.align.vertical = VLC_VIDEO_ALIGN_TOP; #endif - vout_display_place_t place; - vout_display_PlacePicture(&place, source, &place_cfg); + vout_display_place_t before_place = sys->place; + vout_display_PlacePicture(&sys->place, source, &place_cfg); + + /* Signal the change in size/position */ + if (!vout_display_PlaceEquals(&before_place, &sys->place)) + { + sys->place_changed |= true; + +#ifndef NDEBUG + msg_Dbg(vd, "DirectXUpdateRects source" + " offset: %i,%i visible: %ix%i decoded: %ix%i", + source->i_x_offset, source->i_y_offset, + source->i_visible_width, source->i_visible_height, + source->i_width, source->i_height); + msg_Dbg(vd, "DirectXUpdateRects image_dst" + " coords: %i,%i,%i,%i", + sys->place.x, sys->place.y, + sys->place.x + sys->place.width, sys->place.y + sys->place.height); +#endif + } #if !VLC_WINSTORE_APP if (!sys->b_windowless) { - EventThreadUpdateSourceAndPlace(sys->event, source, &place); + EventThreadUpdateSourceAndPlace(sys->event, source, &sys->place); UINT swpFlags = SWP_NOCOPYBITS | SWP_NOZORDER | SWP_ASYNCWINDOWPOS; if (sys->is_first_placement) @@ -199,37 +217,10 @@ void UpdateRects(vout_display_t *vd, vout_display_sys_win32_t *sys, bool is_forc sys->is_first_placement = false; } SetWindowPos(sys->hvideownd, 0, - place.x, place.y, place.width, place.height, + sys->place.x, sys->place.y, sys->place.width, sys->place.height, swpFlags); } -#endif -#define rect_dest sys->rect_dest - RECT before_rect_dest = rect_dest; - /* Destination image position and dimensions */ - rect_dest.left = place.x; - rect_dest.right = place.x + place.width; - rect_dest.top = place.y; - rect_dest.bottom = place.y + place.height; - - /* Signal the change in size/position */ - if (!EqualRect(&before_rect_dest, &rect_dest)) - sys->rect_dest_changed |= true; - -#ifndef NDEBUG - msg_Dbg(vd, "DirectXUpdateRects source" - " offset: %i,%i visible: %ix%i decoded: %ix%i", - source->i_x_offset, source->i_y_offset, - source->i_visible_width, source->i_visible_height, - source->i_width, source->i_height); - msg_Dbg(vd, "DirectXUpdateRects image_dst" - " coords: %li,%li,%li,%li", - rect_dest.left, rect_dest.top, - rect_dest.right, rect_dest.bottom); -#endif -#undef rect_dest - -#if !VLC_WINSTORE_APP CommonChangeThumbnailClip(VLC_OBJECT(vd), sys, true); #endif } diff --git a/modules/video_output/win32/common.h b/modules/video_output/win32/common.h index 025699adb7..e525161b43 100644 --- a/modules/video_output/win32/common.h +++ b/modules/video_output/win32/common.h @@ -60,14 +60,14 @@ typedef struct vout_display_sys_win32_t HINSTANCE dxgidebug_dll; # endif - bool rect_dest_changed; + bool place_changed; /* Misc */ bool is_first_placement; bool is_on_top; - /* Coordinates of src and dest images (used when blitting to display) */ - RECT rect_dest; + /* Coordinates of dest images (used when blitting to display) */ + vout_display_place_t place; vout_display_cfg_t vdcfg; diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c index ac12897a06..d710cce8b7 100644 --- a/modules/video_output/win32/direct3d11.c +++ b/modules/video_output/win32/direct3d11.c @@ -188,8 +188,8 @@ static HRESULT UpdateBackBuffer(vout_display_t *vd) { vout_display_sys_t *sys = vd->sys; UINT i_width, i_height; - i_width = RECTWidth(sys->sys.rect_dest); - i_height = RECTHeight(sys->sys.rect_dest); + i_width = sys->sys.place.width; + i_height = sys->sys.place.height; if (!sys->resizeCb(sys->outside_opaque, i_width, i_height)) return E_FAIL; @@ -200,8 +200,8 @@ static HRESULT UpdateBackBuffer(vout_display_t *vd) static void UpdateSize(vout_display_t *vd) { vout_display_sys_t *sys = vd->sys; - msg_Dbg(vd, "Detected size change %dx%d", RECTWidth(sys->sys.rect_dest), - RECTHeight(sys->sys.rect_dest)); + msg_Dbg(vd, "Detected size change %dx%d", sys->sys.place.width, + sys->sys.place.height); UpdateBackBuffer(vd); @@ -285,10 +285,10 @@ static bool StartRendering(void *opaque) CommonManage(vd, &sys->sys); - if ( sys->sys.rect_dest_changed ) + if ( sys->sys.place_changed ) { UpdateSize(vd); - sys->sys.rect_dest_changed =false; + sys->sys.place_changed =false; } D3D11_ClearRenderTargets( &sys->d3d_dev, sys->display.pixelFormat, sys->swapchainTargetView ); @@ -750,10 +750,10 @@ static int Control(vout_display_t *vd, int query, va_list args) } } - if ( sys->sys.rect_dest_changed ) + if ( sys->sys.place_changed ) { UpdateSize(vd); - sys->sys.rect_dest_changed =false; + sys->sys.place_changed =false; } return res; @@ -1357,8 +1357,12 @@ static void UpdatePicQuadPosition(vout_display_t *vd) { vout_display_sys_t *sys = vd->sys; - RECT rect_dst = sys->sys.rect_dest; - OffsetRect(&rect_dst, -rect_dst.left, -rect_dst.top); + RECT rect_dst = { + .left = 0, + .right = sys->sys.place.width, + .top = 0, + .bottom = sys->sys.place.height + }; D3D11_UpdateViewport( &sys->picQuad, &rect_dst, sys->display.pixelFormat ); @@ -1802,10 +1806,10 @@ static int Direct3D11MapSubpicture(vout_display_t *vd, int *subpicture_region_co d3d_quad_t *quad = (d3d_quad_t *) quad_picture->p_sys; RECT spuViewport; - spuViewport.left = (FLOAT) r->i_x * RECTWidth(sys->sys.rect_dest) / subpicture->i_original_picture_width; - spuViewport.top = (FLOAT) r->i_y * RECTHeight(sys->sys.rect_dest) / subpicture->i_original_picture_height; - spuViewport.right = (FLOAT) (r->i_x + r->fmt.i_visible_width) * RECTWidth(sys->sys.rect_dest) / subpicture->i_original_picture_width; - spuViewport.bottom = (FLOAT) (r->i_y + r->fmt.i_visible_height) * RECTHeight(sys->sys.rect_dest) / subpicture->i_original_picture_height; + spuViewport.left = (FLOAT) r->i_x * sys->sys.place.width / subpicture->i_original_picture_width; + spuViewport.top = (FLOAT) r->i_y * sys->sys.place.height / subpicture->i_original_picture_height; + spuViewport.right = (FLOAT) (r->i_x + r->fmt.i_visible_width) * sys->sys.place.width / subpicture->i_original_picture_width; + spuViewport.bottom = (FLOAT) (r->i_y + r->fmt.i_visible_height) * sys->sys.place.height / subpicture->i_original_picture_height; if (r->zoom_h.num != 0 && r->zoom_h.den != 0) { diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c index 90c06797b5..a64593844c 100644 --- a/modules/video_output/win32/direct3d9.c +++ b/modules/video_output/win32/direct3d9.c @@ -485,9 +485,9 @@ static int Direct3D9ImportPicture(vout_display_t *vd, }; RECT rect_dst = { .left = 0, - .right = RECTWidth(sys->sys.rect_dest), + .right = vd->sys->sys.place.width, .top = 0, - .bottom = RECTHeight(sys->sys.rect_dest), + .bottom = vd->sys->sys.place.height, }; Direct3D9SetupVertices(region->vertex, &rect_src, ©_rect, &rect_dst, 255, vd->source.orientation); @@ -945,7 +945,7 @@ static void Manage (vout_display_t *vd) UpdateDesktopMode(vd); /* Position Change */ - if (sys->sys.rect_dest_changed) { + if (sys->sys.place_changed) { #if 0 /* need that when bicubic filter is available */ RECT rect; UINT width, height; @@ -963,7 +963,7 @@ static void Manage (vout_display_t *vd) } #endif sys->clear_scene = true; - sys->sys.rect_dest_changed = false; + sys->sys.place_changed = false; } } @@ -1060,10 +1060,9 @@ static void Direct3D9ImportSubpicture(vout_display_t *vd, msg_Err(vd, "Failed to lock the texture"); } - /* Map the subpicture to sys->sys.rect_dest */ - const RECT video = sys->sys.rect_dest; - const float scale_w = (float)(RECTWidth(video)) / subpicture->i_original_picture_width; - const float scale_h = (float)(RECTHeight(video)) / subpicture->i_original_picture_height; + /* Map the subpicture to sys->sys.sys.place */ + const float scale_w = (float)(sys->sys.place.width) / subpicture->i_original_picture_width; + const float scale_h = (float)(sys->sys.place.height) / subpicture->i_original_picture_height; RECT dst; dst.left = scale_w * r->i_x, @@ -1337,8 +1336,12 @@ static void Swap(void *opaque) // Present the back buffer contents to the display // No stretching should happen here ! - RECT src = sys->sys.rect_dest; - OffsetRect(&src, -src.left, -src.top); + RECT src = { + .left = 0, + .right = sys->sys.place.width, + .top = 0, + .bottom = sys->sys.place.height + }; HRESULT hr; if (sys->hd3d.use_ex) { diff --git a/modules/video_output/win32/glwin32.c b/modules/video_output/win32/glwin32.c index 838f27cc22..6bc321e717 100644 --- a/modules/video_output/win32/glwin32.c +++ b/modules/video_output/win32/glwin32.c @@ -247,8 +247,8 @@ static void Manage (vout_display_t *vd) CommonManage(vd, &sys->sys); - const int width = RECTWidth(sys->sys.rect_dest); - const int height = RECTHeight(sys->sys.rect_dest); + const int width = sys->sys.place.width; + const int height = sys->sys.place.height; vlc_gl_Resize (sys->gl, width, height); if (vlc_gl_MakeCurrent (sys->gl) != VLC_SUCCESS) return; diff --git a/modules/video_output/win32/wingdi.c b/modules/video_output/win32/wingdi.c index 734d0e8084..5c8e6de7ed 100644 --- a/modules/video_output/win32/wingdi.c +++ b/modules/video_output/win32/wingdi.c @@ -151,15 +151,14 @@ static void Display(vout_display_t *vd, picture_t *picture) vout_display_sys_t *sys = vd->sys; VLC_UNUSED(picture); -#define rect_dest sys->sys.rect_dest HDC hdc = GetDC(sys->sys.hvideownd); SelectObject(sys->off_dc, sys->off_bitmap); - if (RECTWidth(rect_dest) != vd->source.i_visible_width || - RECTHeight(rect_dest) != vd->source.i_visible_height) { + if (sys->sys.place.width != vd->source.i_visible_width || + sys->sys.place.height != vd->source.i_visible_height) { StretchBlt(hdc, 0, 0, - RECTWidth(rect_dest), RECTHeight(rect_dest), + sys->sys.place.width, sys->sys.place.height, sys->off_dc, vd->source.i_x_offset, vd->source.i_y_offset, vd->source.i_x_offset + vd->source.i_visible_width, @@ -167,14 +166,13 @@ static void Display(vout_display_t *vd, picture_t *picture) SRCCOPY); } else { BitBlt(hdc, 0, 0, - RECTWidth(rect_dest), RECTHeight(rect_dest), + sys->sys.place.width, sys->sys.place.height, sys->off_dc, vd->source.i_x_offset, vd->source.i_y_offset, SRCCOPY); } ReleaseDC(sys->sys.hvideownd, hdc); -#undef rect_dest CommonManage(vd, &sys->sys); } _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
