This changes how we synchronize through vsync. We use a mutex and a
wait condition to synchronize the threads. When presenting the frame
our main gui thread blocks and will be woken up by the vsync event
(or a timeout of max 1 frame time slot). In order to minimize the
blocked time we use the blocksForRetrace functionality from the GLX
compositor.
Given this change we no longer need to tell the compositor that we
are swapping the frame, it's blocked anyway. Also we don't need the
failsafe QTimer anymore.
With this change applied on a Nexus 5 it's succeeding the "Martin
tortures phone test". It doesn't tear anymore and has a smooth
experience.
I'm rather disappointed by the fact that we need to block in order
to get vsync. This means Android/hwcomposer is as bad as GLX. So
much for the "Android stack is so awesome", in fact it's not. Anybody
thinking it's awesome should compare to DRM/KMS and especially atomic
modesetting. Yes it's possible to present frames without tearing and
without having to block the rendering thread.
Reviewed-By: Marco Martin and Bhushan Shah
The newer API is designed for the case that outputs are disabled and
makes sure that we don't have to abuse the aboutToSwapBuffers. This
also prevents possible conflicts between blocking during rendering and
screens being off.
Reviewed-By: Bhushan Shah
According to the hwcomposer documentation:
"It is a (silent) error to have HWC_EVENT_VSYNC enabled when calling
hwc_composer_device.set(..., 0, 0, 0) (screen off)".
Because of that we may not enable vsync directly after toggling the
output, but need to wait till after calling the set call.
Reviewed-by: Bhushan Shah
Apparently we don't get a vsync event for the first frame during startup
which blocks the compositor till the end of days. Thus a timer is added
which calls vsync after 1 sec if we didn't get an event.
Note: qt5-qpa-hwcomposer-plugin does the vsync in a different way:
it uses a wait condition to truly block in present till the vsync.
Maybe we need to do that as well.
Based on a previous patch done by David Edmundson and heavily
inspired by qt5-qpa-hwcomposer-plugin [1].
The change requires a newer libhybris than the one used by Ubuntu. In
fact it allows to build against current master (at the day of writing [2]).
REVIEW: 125606
[1] https://github.com/mer-hybris/qt5-qpa-hwcomposer-plugin
[2] bd6df6a306
Libinput does work on libhybris enabled devices. There is no need to
use Android's input stack. This simplifies our code a lot and increases
sharing with normal Linux systems.
What's tricky is to convince the system to use libinput through with our
logind helper. Logind fails to open the files for us if we start KWin
over either ssh or adb shell. We need to get it into a proper session, so
only a kwin started through a helper like simplelogin will be able to use
libinput.
REVIEW: 125608
Libhybris input events are generated in a different thread, but we want
them in the main thread (InputRedirection and KWayland are not (yet)
thread safe). Thus all events need to be send to the main thread using
QMetaObject::invokeMethod.
Unfortunately on libhybris enabled systems libinput doesn't work, thus
the backend needs to handle input events which can be read from hybris.
So far the backend only handles touch events properly, though some
aspects look wrong. E.g. motion gives only for one touch contact point.
Unfortunately the documentation is quite weak, so there might be
something important missing.
Allows to read the DPI information and export the physical display
size from it. DPI is scaled by 1000 in hwcomposer, split by X and Y,
which allows to calculate size in mm from pixel size.
This backend interacts with libhybris to create a hwcomposer which is
used for creating the egl context and surface. The initial version of
this backend is based on test_hwcomposer.cpp provided by libhybris.
Please note that using the hwcomposer backend requires a newer libepoxy,
the latest stable release is not able to bring up OpenGLES, so one needs
a master build of libepoxy.
Notes on licensing:
libhybris is Apache 2.0 licensed, which is not compatile with GPLv2.
But it is compatible with GPLv3. Thus the source files in the hwcomposer
backend are licensed GPLv3+ and not GPLv2+ as the rest of KWin. If one
uses KWin without the hwcomposer backend (which is obviously the default)
the licence doesn't change. But if the hwcomposer backend is used the
overall license of KWin changes to GPLv3+.