Commit graph

792 commits

Author SHA1 Message Date
Vlad Zahorodnii
9f2cb0ae1b Provide expected presentation time to effects
Effects are given the interval between two consecutive frames. The main
flaw of this approach is that if the Compositor transitions from the idle
state to "active" state, i.e. when there is something to repaint,
effects may see a very large interval between the last painted frame and
the current. In order to address this issue, the Scene invalidates the
timer that is used to measure time between consecutive frames before the
Compositor is about to become idle.

While this works perfectly fine with Xinerama-style rendering, with per
screen rendering, determining whether the compositor is about to idle is
rather a tedious task mostly because a single output can't be used for
the test.

Furthermore, since the Compositor schedules pointless repaints just to
ensure that it's idle, it might take several attempts to figure out
whether the scene timer must be invalidated if you use (true) per screen
rendering.

Ideally, all effects should use a timeline helper that is aware of the
underlying render loop and its timings. However, this option is off the
table because it will involve a lot of work to implement it.

Alternative and much simpler option is to pass the expected presentation
time to effects rather than time between consecutive frames. This means
that effects are responsible for determining how much animation timelines
have to be advanced. Typically, an effect would have to store the
presentation timestamp provided in either prePaint{Screen,Window} and
use it in the subsequent prePaint{Screen,Window} call to estimate the
amount of time passed between the next and the last frames.

Unfortunately, this is an API incompatible change. However, it shouldn't
take a lot of work to port third-party binary effects, which don't use the
AnimationEffect class, to the new API. On the bright side, we no longer
need to be concerned about the Compositor getting idle.

We do still try to determine whether the Compositor is about to idle,
primarily, because the OpenGL render backend swaps buffers on present,
but that will change with the ongoing compositing timing rework.
2020-12-10 07:14:42 +00:00
Vlad Zahorodnii
2a8395c7dd Trim trailing whitespace 2020-11-28 11:01:47 +00:00
Aleix Pol
4f484180cd Add emit to signal calls
To signify they're emitting.
2020-11-19 22:32:08 +01:00
Nicolas Fella
fe6c296073 [libkwineffects] Add windowId to EffectWindow
My use case is integrating with a system that tracks window properties based on the windowId. This allows the effect to do window-specific things.
2020-11-17 21:56:17 +00:00
David Edmundson
3d43f8ad93 Drop QGraphicsView classes in PaintData
QGraphicsRotation and Scale are QObject wrappers. It's not useful in
data structures where we're creating mulitple of these every frame. It's
large enough to appear in hotspot as taking over 1% of a regular frame.

We don't even use the QGraphicsRotation mapping inside scene for a
reason, so it's not giving us much.

It's technically an API break in libkwineffects. Pragamatically no-one
would use these. We also lose QGraphicsScale's origin, but we never
exposed this in PaintData's public header.
2020-11-03 13:19:47 +00:00
Nicolas Fella
6b34b90635 Revert "[libkwineffects] Add windowId to EffectWindow"
This reverts commit 251bbbb5b5
2020-11-01 14:29:16 +00:00
Nicolas Fella
251bbbb5b5 [libkwineffects] Add windowId to EffectWindow
My use case is integrating with a system that tracks window properties based on the windowId. This allows the effect to do window-specific things.
2020-11-01 15:25:15 +01:00
Laurent Montel
2ac8611523 If include is define in .h remove it if it's defined in .cpp too (scripted) 2020-10-23 21:37:16 +02:00
Vlad Zahorodnii
7301564e4f Use bilinear interpolation to compute texture coords of subquads
On Wayland, a surface must be displayed the same way no matter how the
attached buffer is transformed. In order to guarantee that, we build the
surface-to-buffer matrix, which is used to compute the texture coords.

The surface-to-buffer matrix represents an affine transformation. Thus,
performing linear interpolation between texture coordinates won't end up
in corrupted rendered results. This is the main assumption that we make
during generation of contents window quads. After creating a sub-quad,
the new quad's texture coordinates are computed by interpolating between
the source quad's texture coords.

However, WindowQuad::makeSubQuad() makes a concrete assumption about the
order of texture coords, which might be false if the attached wayland
buffer is rotated 90 or 270 degrees.

This issue went unnoticed after merging the viewporter patches because
the developer who was working on it had been using primarily nested
kwin_wayland for testing purposes. And it appears like kwin schedules
full screen repaints even though it supports buffer age. It still needs
some investigation why that happens.

BUG: 428003
2020-10-20 15:41:00 +00:00
Fabian Vogt
96635ea29c Detect softpipe and llvmpipe on Mesa 20.2+
It seems like the vendor string changed from "VMware Inc." to "Mesa/X.org".
2020-10-19 14:53:38 +00:00
Vlad Zahorodnii
37ffba8b0f libkwineffects: Specify more dependencies 2020-10-14 13:03:57 +00:00
Vlad Zahorodnii
ffeebc4c2f libkwineffects: Specify valid min Qt version in KWinEffects.config.in
REQUIRED_QT_VERSION is used primarily in KF projects, not in Plasma
projects.
2020-10-14 13:03:57 +00:00
Nicolas Fella
cc763e063c [libkwineffects] Clean up link targets
Some can be private, some are in the wrong place, some are not needed at all.
2020-10-14 00:04:28 +00:00
Nicolas Fella
3669ca2083 [libkwineffects] Remove KWIN4_ADD_GLUTILS_BACKEND cmake macro
Defining a macro and then using it only once is a bit strange.
2020-10-14 01:45:34 +02:00
Nicolas Fella
6edffc688d Add proper cmake config files for kwineffects
This makes it easier for out-of-tree effects to find and link against the required libs, including correct dependency propagation.
2020-10-13 23:53:48 +02:00
Nicolas Fella
968b57fe2f Fix KWIN_EFFECT_FACTORY macros
The macros don't work because of the mismatching capitalization.
2020-10-12 20:28:22 +00:00
Nicolas Fella
aa9475e64e [effects] Fix documention sentence
It makes more sense this way to me
2020-10-12 19:36:32 +02:00
Aleix Pol
13dcb46888 Remove unnecessary allocation in GLShader::setUniform(int, const QMatrix4x4 &)
We were creating a vector just to copy it over. We can pass the original
vector just as well.
2020-09-23 10:05:29 +00:00
Aleix Pol
26950a65a6 Have Toplevel::damage emit a QRegion
Instead of looping through the rects in the region, emit the region at
bulk. It reduces the amount of emissions we do and allows us to pack the
response accordingly.
2020-09-22 14:45:08 +02:00
Vlad Zahorodnii
79c667ea67 libkwineffects: Bump API version
The API version must be bumped because a new virtual method in the
EffectWindow class had been introduced that breaks BC.
2020-09-18 12:02:46 +03:00
Aleix Pol
651b0df30c Make WindowQuadList a QVector
In my last profiling session I did see a lot of WindowQuadList creation
cost. We know QList is a bit more expensive, so let's just use QVector.
2020-09-15 16:01:14 +00:00
Aleix Pol
474060a456 Improve loop implementations in WindowQuadList
Prefer for() to foreach(), as the latter is deprecated.
Prefer iterating QList using the iteration_expression for() loops,
rather than doing it by index.
2020-09-14 02:19:18 +00:00
Adrien Faveraux
788c65d260 Fix Build Warning 2020-08-26 19:24:02 +02:00
Vlad Zahorodnii
0dda9dc7d0 Use namespace kwin only in autotests
In kwin core, we prefer not to put `using namespace KWin` because it
makes defining forward declared classes more trickier.
2020-08-21 22:06:36 +00:00
David Redondo
2a9971fa08 Disable AnimationEffects when the screen is locked
BUG:425157
2020-08-10 09:34:15 +00:00
Vlad Zahorodnii
4ce853e8e4 Prettify license headers 2020-08-07 19:57:56 +00:00
Vlad Zahorodnii
1fb9f6f13a Switch to SPDX license markers
The main advantage of SPDX license identifiers over the traditional
license headers is that it's more difficult to overlook inappropriate
licenses for kwin, for example GPL 3. We also don't have to copy a
lot of boilerplate text.

In order to create this change, I ran licensedigger -r -c from the
toplevel source directory.
2020-08-07 19:57:56 +00:00
Vlad Zahorodnii
e7d02ad355 Introduce X11 default screen property in Application
This spares unnecessary looping through all available X11 screens.
2020-08-05 08:48:00 +00:00
Vlad Zahorodnii
19ad172584 Survive Xwayland crashes
If the Xwayland process crashes, it will bring down the entire session
together with itself. Obviously, we don't want that. At least, Wayland
clients should survive the crash.

This change refactors relevant X11 parts to handle Xwayland crashes in a
less fatal way.

In order to handle Xwayland crashes better, a pair of start() and stop()
methods had been introduced in the Xwayland class to allow starting and
stopping the Xwayland process at any moment.

If we detect that the Xwayland process has crashed, we will immediately
stop the Xwayland server, which in its turn will deactivate the socket
notifier and destroy all connected X11 clients. Unfortunately, a couple
of subtle changes in X11Client::releaseWindow() and Unmanaged::release()
had to be made to ensure that we are left with a valid state after the
Xwayland server has been stopped.
2020-08-05 08:48:00 +00:00
Niccolò Venerandi
e41c5af676 Expose transientFor and only blur underneath when transientParent is dock 2020-08-02 10:25:28 +00:00
Aleix Pol
38eb72efe3 screencasting: integrate zkde_screencast_unstable_v1
Includes a PipeWire implementation that will send the relevant streams
to the processes that need them.
2020-07-23 13:14:22 +02:00
Aleix Pol
29a2b2a355 Make it possible to specify KWin::GLTexture mutability
Some features will rely on it and complain that GLTexture decided to use
glTexStorage
2020-07-23 13:14:22 +02:00
Aleix Pol
ff65bec92c Introduce a GLTexture::toImage helper class 2020-07-23 13:14:22 +02:00
Aleix Pol
e459c8bf54 No need to recalculate the matrix if yInverted doesn't change 2020-06-23 14:58:48 +02:00
Vlad Zahorodnii
cb7a9456c0 [wayland] Rework Xcursor theme loading code
Currently in order to load an Xcursor theme, kwin uses libwayland api,
which looks really awkward because of the way how the compositor talks
to itself via the internal connection.

The main motivation behind this change is to limit the usage of kwayland
client api in kwin.
2020-06-18 07:14:58 +00:00
Aleix Pol
3a9d7a6e9d Port KWin to KWaylandServer
Summary: Away from KWayland::Server and KF5WaylandServer.

Test Plan: Builds, ran nested session

Reviewers: #kwin, #plasma, #frameworks, davidedmundson, zzag

Reviewed By: #kwin, #plasma, davidedmundson, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D29278
2020-04-30 12:56:08 +02:00
Vlad Zahorodnii
a848490cae Revert "More for Qt 5.12"
This reverts commit 3e9f33bb3e.

Differential Revision: https://phabricator.kde.org/D29147
2020-04-24 10:19:17 +03:00
Méven Car
66898e7f46 Wayland: Allow to take single screen screenshots using scale factor without loss
Summary:
The screenshot made on screens with scale factor were downscaled by their scale factor making them blurry.
It prevents taking screenshots of missing Hidpi related bugs showing the issues under Wayland.

This fix the case of a single screenshot, but not the rest:
Multiscreen screenshot downscales the screen using scale factor.
Spectacle rectangular selection screenshot is broken as soon as some scale factor different than 1 is used on any screen.

Test Plan:
Under Wayland with a scale factor on a screen, take a screenshot using spectacle.
The output image is not downscaled and has the same size as the screen resolution.

No other change to any other screenshot mode, or under X.

Reviewers: davidedmundson, #kwin

Reviewed By: davidedmundson, #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D29010
2020-04-20 16:12:26 +02:00
Vlad Zahorodnii
9755ef20e5 [kwineffects] Port GLPlatform to QRegularExpression
Test Plan: kwinglplatformtest still passes.

Reviewers: #kwin, apol

Reviewed By: apol

Subscribers: apol, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D28320
2020-03-30 16:00:46 +03:00
Vlad Zahorodnii
bdd6882767 [kwineffects] Drop KWIN_GL_DEBUG
Summary:
It has been broken for many years and no one has filed bug
reports about it (besides me).

BUG: 419285

Test Plan: Ran kwin with KWIN_GL_DEBUG and it still works.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D28332
2020-03-27 12:29:24 +02:00
Aleix Pol
3e9f33bb3e More for Qt 5.12 2020-03-17 15:37:01 +01:00
Aleix Pol
cca0e15b45 Fix compiler warnings
Summary: No need to keep them around for no reason.

Test Plan: Tested the plugins I thought could be affected. Have been using it for a couple of days without problems

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D28062
2020-03-17 15:07:52 +01:00
Niccol Venerandi
f9394d83f7 Move from Quad to Cubic
Summary: See https://invent.kde.org/websites/hig-kde-org/-/merge_requests/70

Reviewers: #kwin, ngraham

Reviewed By: ngraham

Subscribers: ngraham, zzag, apol, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D27827
2020-03-04 19:40:35 +01:00
Roman Gilg
9c398de683 [libkwineffects] Set original backend framebuffer for render targets
Summary:
KWin only renders into the default framebuffer, which is for example an EGL
surface.

To prepare a post-processing step with a different framebuffer allow the
framebuffer to be changable. For that KWin's current framebuffer must be
communicated to the GLRenderTarget class, which otherwise does not set it back
to KWin's current one when a render target is disabled again.

Test Plan: Compiles, with other patches for Gl based screen rotation

Reviewers: #kwin

Subscribers: fredrik, zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D25904
2020-02-28 12:22:42 +00:00
Vlad Zahorodnii
00f4f88f65 Expose frameGeometryChanged signal to effects
Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D26864
2020-02-12 10:52:26 +02:00
Vlad Zahorodnii
dd96e444dd Merge branch 'Plasma/5.18' 2020-02-11 19:56:29 +02:00
Vlad Zahorodnii
b94a78c47d [libkwineffects] Detect more AMD GPUs with GFX9 (Vega) chips
Summary: ASIC family names are taken from Mesa's source code.

Test Plan: Compiles.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, romangg, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D27176
2020-02-11 19:56:18 +02:00
Vlad Zahorodnii
90489bde27 Merge branch 'Plasma/5.18' 2020-02-05 22:28:40 +02:00
Vlad Zahorodnii
ab9a9c8428 [libkwineffects] Detect AMD Navi GPUs
Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D27168
2020-02-05 22:27:15 +02:00
David Edmundson
8cedb797f9 Port DesktopGrid QtQuickWindow to EffectQuickView
Summary:
Lots of red, does the same thing in a simplified way avoiding creating a
real window and having to hack round it.

Test Plan: Click add and remove, remove button disables appropriately

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: meven, zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D26381
2020-01-22 13:16:45 +00:00