[vlc-commits] vout/caopengllayer: rewrite most of the module
Marvin Scholz
git at videolan.org
Mon Feb 24 17:34:29 CET 2020
vlc/vlc-3.0 | branch: master | Marvin Scholz <epirat07 at gmail.com> | Wed Feb 19 12:47:49 2020 +0100| [879ca61f8c25af9f95da72ee0fc3366c2ffd1d47] | committer: Marvin Scholz
vout/caopengllayer: rewrite most of the module
Rewrites most of the layer vout code to have the same features as the
view based vout. Additionally fixes laggy resizing, fixes CGL context
creation bugs, adds support for CI filters and fixes various memory
management errors.
The CAOpenGLLayer based API is special and different from all other APIs
provided on other OSes as it is not a push-model API but a pull one,
where the OS calls a specific method when a new frame should be rendered.
This makes integration into VLC relatively tricky and the code a bit
harder to follow.
While the API is a pull-model, we can kind of trick it by just forcing
a re-display of the layer in the vouts display function. With views this
would be forbidden as views are supposed to be accessed from the main
thread only, but with layers this is possible if some care is taken.
When forcing the layer to render from a different thread, the implicitly
created CATransaction has to be flushed explicitly, as we do not have a
main loop at the end of which it would be flushed.
We do not force rendering all the time though, as doing that would break
resize animations given that VLC can not know the right time when display
refresh will happen, so resizing would look laggy and have glitches, as
during a resize both the OS and VLC would drive the rendering of the
layer, resulting in unexpected result.
To prevent that, when live resizing starts (the user resizing by dragging
a windows corner), the layer is set into asynchronous rendering mode
which makes the OS drive the rendering loop completely not only for
drawing the resize change. While the layer is in asynchronous mode, we
ignore all update requests from the core, as the layer is anyway updated
continuously by the OS and forcing rendering from another thread would
lead to artifacts. Additionally while in live resize, we do not report
the size changes to the core, as the event takes too long to reach the
vout Control() function, resulting in the layer content being displayed
at the wrong (old) size. Instead we take the current viewport size
as the size and display using that.
Another unusual thing compared to other vouts is that the VLC OpenGL
display functions to update the viewport and aspect ratio are not
called in the Control event handling callback, thats because before
the render callback is called, the OS sets the OpenGL viewport to match
the layer backing store size. So setting it in the Control callback
is useless as it does not make any difference.
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=879ca61f8c25af9f95da72ee0fc3366c2ffd1d47
---
modules/video_output/caopengllayer.m | 919 ++++++++++++++++++++++++-----------
1 file changed, 625 insertions(+), 294 deletions(-)
Diff: http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commitdiff;h=879ca61f8c25af9f95da72ee0fc3366c2ffd1d47
More information about the vlc-commits
mailing list