[vlc-devel] [PATCH] win32/drawable: process the WM_SIZE asynchronously

Alexandre Janniaux ajanni at videolabs.io
Mon Mar 1 11:07:55 UTC 2021


Hi,

After some thoughts on it, isn't Thomas's suggestion more
adequate than Steve's one? Though less elegant, it actually
does not break the synchronicity of the resize, right?

Regards,
--
Alexandre Janniaux
Videolabs

On Mon, Mar 01, 2021 at 11:57:16AM +0100, Thomas Guillem wrote:
> I tested it, no more deadlock and better than my proposal.
>
> LGTM.
>
> On Mon, Feb 22, 2021, at 15:29, Steve Lhomme wrote:
> > On 2021-02-22 14:20, Alexandre Janniaux wrote:
> > > Hi,
> > >
> > > How does resizing work with asynchronous posting? I had the
> > > feeling that win32 API needed synchronous resizing to be able
> > > to achieve smooth resizing, is it wrong or unrelated here?
> >
> > Technically our underlying HWND is still there but possibly not matching
> > the parent. If it's too small the area may not be looking too good. If
> > it's too big it's clipped in the parent so no artefacts, just not
> > displayed at the right size. There is nothing in Windows that says our
> > HWND needs to fit exactly in its parent, so a lag here won't cause
> > troubles, just possibly some visual oddness.
> >
> > In practice I have not seen such things. But on my system I can hardly
> > get the original reentrant issue anyway, so the resizing is applied
> > quickly.
> > > Regards,
> > > --
> > > Alexandre Janniaux
> > > Videolabs
> > >
> > > On Mon, Feb 22, 2021 at 08:25:30AM +0100, Steve Lhomme wrote:
> > >> The vout_window_ReportSize call may make changes in underlying HWND's which in
> > >> turn might make reentrant calls to WinVoutEventProc, which might in turn call
> > >> WM_SIZE in the same stack (when resizing quickly).
> > >>
> > >> vout_window_ReportSize() is not reentrant so we should avoid calling it in
> > >> calls that might be reentrant (WM_SIZE in this case).
> > >>
> > >> We keep the latest WM_SIZE so when the asynchronous call is done, we already
> > >> have the most up to date value.
> > >> ---
> > >>   modules/video_output/win32/drawable.c | 10 +++++++++-
> > >>   1 file changed, 9 insertions(+), 1 deletion(-)
> > >>
> > >> diff --git a/modules/video_output/win32/drawable.c b/modules/video_output/win32/drawable.c
> > >> index 90106558848..c6f2f573a2f 100644
> > >> --- a/modules/video_output/win32/drawable.c
> > >> +++ b/modules/video_output/win32/drawable.c
> > >> @@ -77,6 +77,8 @@ struct drawable_sys
> > >>       HWND hWnd;
> > >>       HWND embed_hwnd;
> > >>       RECT rect_parent;
> > >> +
> > >> +    unsigned int width, height;
> > >>   };
> > >>
> > >>   static LRESULT CALLBACK WinVoutEventProc(HWND hwnd, UINT message,
> > >> @@ -131,7 +133,13 @@ static LRESULT CALLBACK WinVoutEventProc(HWND hwnd, UINT message,
> > >>           return 0;
> > >>
> > >>       case WM_SIZE:
> > >> -        vout_window_ReportSize(wnd, LOWORD(lParam), HIWORD(lParam));
> > >> +        sys->width  = LOWORD(lParam);
> > >> +        sys->height = HIWORD(lParam);
> > >> +        PostMessage(hwnd, WM_USER, 0, lParam);
> > >> +        return 0;
> > >> +
> > >> +    case WM_USER:
> > >> +        vout_window_ReportSize(wnd, sys->width, sys->height);
> > >>           return 0;
> > >>
> > >>       default:
> > >> --
> > >> 2.29.2
> > >>
> > >> _______________________________________________
> > >> vlc-devel mailing list
> > >> To unsubscribe or modify your subscription options:
> > >> https://mailman.videolan.org/listinfo/vlc-devel
> > > _______________________________________________
> > > vlc-devel mailing list
> > > To unsubscribe or modify your subscription options:
> > > https://mailman.videolan.org/listinfo/vlc-devel
> > >
> > _______________________________________________
> > vlc-devel mailing list
> > To unsubscribe or modify your subscription options:
> > https://mailman.videolan.org/listinfo/vlc-devel
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list