Commit graph

192 commits

Author SHA1 Message Date
Vlad Zahorodnii
3b1c143881 scene: Fix window pixmap traversal order
Since the last child window pixmap is the top-most one, it needs to be
pushed on the stack first. This may fix KMail rendering issues.
2020-12-14 12:55:55 +00:00
Aleix Pol
3f66aabd48 Use variables instead of macros for local variables 2020-12-11 17:51:27 +00:00
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
d99e6b5d2a platforms/x11: Move XRenderBackend to platformsupport directory
This change moves the XRender backend to platformsupport directory,
similar to the OpenGL and the QPainter backend. This allows to put
platform-specific logic in XRenderBackend.
2020-12-08 08:50:19 +00:00
Vlad Zahorodnii
017528956b Move Scene::isPerScreenRenderingEnabled() to Platform
This way the Compositor can know if per screen rendering is enabled
before creating the Scene.
2020-12-02 15:32:30 +00:00
Vlad Zahorodnii
2a8395c7dd Trim trailing whitespace 2020-11-28 11:01:47 +00:00
Vlad Zahorodnii
e298caaa7a wayland: Fix clipped thumbnails of client-side decorated apps
The buffer offset for client-side decorated windows is not 0, this plus
mixing the frame position and the client size may result in clipped
thumbnails of client-side decorated applications, such as gedit, etc.

BUG: 428595
2020-11-27 15:34:32 +00:00
Vlad Zahorodnii
f26eeb9706 Use consistent naming for begin/end frame hooks
Currently, the OpenGLBackend and the QPainterBackend have hooks to
indicate the start and the end of compositing cycle, but in both cases,
the hooks have different names. This change fixes that inconsistency.
2020-11-12 09:14:57 +02:00
Vlad Zahorodnii
76303888ab Unify begin/end frame hooks in OpenGLBackend 2020-11-12 09:14:54 +02:00
Vlad Zahorodnii
755dd81e49 Refactor how per screen rendering is handled
In order to allow per screen rendering, we need the Compositor to be
able to drive rendering on each screen. Currently, it's not possible
because Scene::paint() paints all screen.

With this change, the Compositor will be able to ask the Scene to paint
only a screen with the specific id.
2020-11-11 22:03:45 +02:00
Vlad Zahorodnii
7cab8cf8bb Make Scene::qpainterRenderBuffer() take a screen id 2020-11-11 07:22:10 +00:00
Vlad Zahorodnii
94b731c196 Prepare QPainter render backend for per screen rendering 2020-11-11 07:22:10 +00:00
Vlad Zahorodnii
edfb0a3fd9 Drop support for X11 overlay windows in QPainter render backend
It's unused.
2020-11-11 07:22:10 +00:00
Vlad Zahorodnii
e4861c28a7 scenes/qpainter: Drop support for Xinerama-style rendering
All platforms that provide support for the QPainter render backend use
per screen rendering. Since there is no any way to test Xinerama-style
rendering, it's better to drop the dead code.
2020-11-11 07:22:10 +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
Vlad Zahorodnii
c3eba1e41c scenes/opengl: Do not process window thumbnails with lanczos filter
If window thumbnails have to be downscaled, it's up to the application
what filter must be used. Also, we don't really use the lanczos filter
because both x and y scale factors are 1.
2020-11-02 11:00:49 +02:00
Vlad Zahorodnii
b9cbf3647e wayland: Adapt to subsurface changes in kwayland-server 2020-11-02 08:47:18 +00:00
Vlad Zahorodnii
d5203c79a0 Report partial updates on all outputs
Previously, we couldn't do it because repaints weren't tracked per each
output.
2020-10-30 20:47:05 +00:00
Vlad Zahorodnii
74391e250e Store repaint regions per individual screen
AnimationEffect schedules repaints in postPaintWindow() and performs
cleanup in preScreenPaint(). With the X11-style rendering, this doesn't
have any issues, scheduled repaints will be reset during the next
compositing cycle.

But with per screen rendering, we might hit the following case

    - Paint screen 0
    - Reset scheduled repaints
    - AnimationEffect::prePaintScreen(): update the timeline
    - AnimationEffect::postPaintScreen(): schedule a repaint

    - Paint screen 1
    - Reset scheduled repaints
    - AnimationEffect::prePaintScreen(): destroy the animation
    - AnimationEffect::postPaintScreen(): no repaint is scheduled

    - Return to the event loop

In this scenario, the repaint region scheduled by AnimationEffect will
be lost when compositing is performed on screen 1.

There is no any other way to fix this issue but maintain repaint regions
per each individual screen if per screen rendering is enabled.

BUG: 428439
2020-10-30 07:24:01 +00:00
Vlad Zahorodnii
e5b2fca409 scenes/opengl: Use GL_CLAMP_TO_EDGE wrap mode with sw cursor
We use the GL_LINEAR magnification filter. This means that GL_REPEAT
wrap mode cannot be used for the software cursor because sampling texels
beyond the right texture edge is the same as sampling texels on the
left edge. This may produce undesired visual artifacts.
2020-10-28 19:20:46 +02:00
Vlad Zahorodnii
c8eeefbd7d platform/drm: Fix clipped HiDPI hardware cursors
If an output is rotated, we will compute a transform matrix for the
cursor plane to rotate its contents.

In order to compute that matrix we need the rect of the cursor in the
device-independent pixels, the scale factor and the output transform.

The problem is that we provide a rect of the cursor in the native
pixels. This may result in the cursor being partially or fully clipped.

CCBUG: 424589
2020-10-27 06:04:17 +00:00
Vlad Zahorodnii
4a0128cac1 Clip software cursors
If you play some video and the software cursor doesn't hover it, then
the shadow cast by the cursor will be getting darker and darker with
every frame.

The main reason for that is that kwin paints the software cursor even
if the rect behind it hasn't been damaged or repainted.
2020-10-26 13:45:55 +02:00
Vlad Zahorodnii
9b09f0399f Mark the cursor as rendered after performing compositing
If a cursor animation is driven purely by frame callbacks and kwin
uses hardware cursors, the cpu usage may spike to 100%.

This change addresses that issue by sending frame callbacks after a
compositing cycle has been performed.
2020-10-26 10:02:17 +02:00
Vlad Zahorodnii
6b940c1280 scenes/opengl: Properly render cursors with hidpi
GLTexture::width() and GLTexture::height() return the size of the cursor
texture in native pixels, but we need a size in device independent pixels.

CCBUG: 424589
2020-10-25 08:57:13 +00:00
Vlad Zahorodnii
9c20df5030 screencast: Use fences to avoid stalling the graphics pipeline
Currently, we use glFinish() to ensure that stream consumers don't see
corrupted or rather incomplete buffers. This is a serious issue because
glFinish() not only prevents the gpu from processing new GL commands,
but it also blocks the compositor.

This change addresses the blocking issue by using native fences. With
the proposed change, after finishing recording a frame, a fence is
inserted in the command stream. When the native fence is signaled, the
pending pipewire buffer will be enqueued.

If the EGL_ANDROID_native_fence_sync extension is not supported, we'll
fall back to using glFinish().
2020-10-19 14:23:06 +00:00
Vlad Zahorodnii
b7bd8472f2 scene: Reduce the call cost of Platform::supportsQpaContext()
Every time Platform::supportsQpaContext() is called, we go through the
list of supported extensions and perform a string comparison op. This is
not really cheap.
2020-10-13 05:32:48 +00:00
l10n daemon script
30b516eceb SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2020-09-30 06:16:48 +02:00
Aleix Pol
61e655f7f7 Centralize WindowPixmap buffer updating code
Uses a setter and clear method pattern rather than having the code
repeated.
Instead of keeping a QPointer, now we are a QObject and we get notified
about destruction intention directly, so we can clear the pointer when
necessary.
2020-09-22 13:04:35 +00:00
Aleix Pol
6f1e72886a simple for -> foreach on a hot path 2020-09-17 03:12:59 +02:00
Aleix Pol
eafe23b27c Hopefully fix the build on BSD
At the moment it complains about std::array being unknown.
2020-09-10 01:06:41 +02:00
Vlad Zahorodnii
53cb4207ea scenes/opengl: Use std::array to store lanczos kernel data
This fixes a compiler warning (-Wclass-memaccess) and makes code a bit
cleaner.
2020-09-09 19:36:26 +00:00
Aleix Pol
76fbb43798 Reduce repeated Screens::scale(int) 2020-09-09 17:46:56 +00:00
David Edmundson
8303a4cdf8 Make GL Context current when deleting lanczos textures in timer hander.
A timer could have fired at any time. We process mulitple QtQuickViews
on timers which change the GL context.

Deleting a kwin GLTexture calls glDeleteTextures/glDeleteFramebuffers.

Surprisingly I haven't seen a crash report from this, but it doesn't
look right.
2020-09-01 09:13:00 +00:00
Adrien Faveraux
788c65d260 Fix Build Warning 2020-08-26 19:24:02 +02:00
Aleix Pol
eeeac04974 Implement EGL_KHR_partial_update and EGL_EXT_swap_buffers_with_damage
Summary:
Notify the driver about the parts of the screen that will be repainted.
In some cases this can be benefitial. This is especially useful on lima
and panfrost devices (e.g. pinephone, pinebook, pinebook pro).

Test Plan:
Tested on a pinebook pro with a late mesa version.
Basically I implemented it, then it didn't work and I fixed it.
Maybe next step we want to look into our damage algorithm.
2020-08-19 14:51:42 +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
Andreas Haratzis
159fbc5ec4 Fix clipped shadows on useraction menus, when wayland and desktop scaling is enabled. 2020-08-05 11:54:54 +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
Aleix Pol
d4cd2b5a6a Account for OpenGLWindow::windowPixmap returning nullptr sometimes 2020-07-31 19:49:15 +02:00
Vlad Zahorodnii
2103b999e7 screencast: Address minor issues 2020-07-28 18:38:49 +00:00
Aleix Pol
27ea1b9527 screencasting: Expose necessary information to implement efficient screencasting 2020-07-23 13:14:22 +02:00
l10n daemon script
c10fe06d06 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2020-06-18 05:44:57 +02:00
l10n daemon script
0e117c49a1 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2020-06-17 14:12:29 +02:00
Vlad Zahorodnii
cb4dc0ff9d [scene] Make the scene window a qobject
Since the scene window is not a QObject, we cannot connect toplevel's
signals directly to the scene window's slots.
2020-06-10 09:13:35 +03:00
l10n daemon script
29915632df SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2020-06-04 05:12:36 +02:00
Vlad Zahorodnii
9e797cf943 [scene] Introduce helpers for mapping between different coordinate spaces
We currently deal with three distinct coordinate spaces - the window
pixmap coordinate space, the window coordinate space, and the buffer
pixel coordinate space.

This change introduces a couple of helper methods to make it easier
to map points from the window pixmap space to the other two spaces.

The main motivation behind the new helpers is to break the direct
relationship between the surface-local coordinates and buffer pixel
coordinates for wayland surfaces.
2020-06-03 10:00:48 +03:00
Aleix Pol
da81b0f86c Improve opengl debug messages
Summary: Don't include the \n at the end of the debug messages

Test Plan: Now I can see the debug errors without an empty line below

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D29684
2020-05-15 12:27:58 +02:00
Vlad Zahorodnii
f2c8981f7e [scene] Generate window quads for sub-surfaces
No window quads are generated for sub-surfaces right now. This leads to
issues with effects that operate on window quads, e.g. magic lamp and
wobbly windows. Furthermore, the OpenGL scene needs window quads to
properly clip windows during the rendering process.

The best way to render sub-surfaces would be with a little help from a
scene graph. Contrary to GNOME, KDE hasn't developed any scene graph
implementation that we could use in kwin. As a short term solution, this
change adjusts the scene to generate window quads.

Window quads are generated as we traverse the current window pixmap tree
in the depth-first search manner. In order to match a list of quads with
a particular WindowPixmap, we assign an id to each quad.

BUG: 387313
FIXED-IN: 5.19.0

Differential Revision: https://phabricator.kde.org/D29131
2020-05-04 15:36:30 +03:00
Vlad Zahorodnii
e4b598ca86 [scene] Build window pixmap trees before starting rendering
In order to generate window quads for sub-surfaces, we need a valid
window pixmap tree. The problem is that the window pixmap tree is
created too late in the rendering process. This change adjusts the
scene so it creates window pixmap trees before buildQuads().

Differential Revision: https://phabricator.kde.org/D29131
2020-05-04 15:36:03 +03:00