Commit graph

185 commits

Author SHA1 Message Date
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
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
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
Aleix Pol
6abd23ed02 Make it possible to have a separate cursor for the tablet
Summary:
As is KWin only had 1 Cursor which was a singleton. This made it impossible for
us to properly implement the tablet (as in drawing tablets) support and show where
we're drawing.
This patch makes it possible to have different Cursors in KWin, it makes all the
current code still follow the mouse but the tablet can still render a cursor.

Test Plan: Tests pass, been using it and works as well as before but with beautiful tablet cursors.

Reviewers: #kwin, cblack, davidedmundson

Reviewed By: #kwin, cblack, davidedmundson

Subscribers: davidedmundson, cblack, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D28155
2020-04-03 01:16:45 +02:00
Vlad Zahorodnii
c0c693efb3 Merge branch 'Plasma/5.18' 2020-03-19 16:41:09 +02:00
Vlad Zahorodnii
348e72c56e [scenes/opengl] Print a debug message when viewport limits aren't met
Summary:
This may help with debugging why compositing is suspended.

CCBUG: 418951

Test Plan: Compiles.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D28139
2020-03-19 16:40:54 +02: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
Aleix Pol
e8efa83444 scene: Pass non-trivial classes by const&
Summary:
This will save the copy of some objects, especially PaintData classes that are
not copy-on-write.
It also follows the practice on other parts of the system.

Test Plan: Running it right now

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D28031
2020-03-14 01:15:04 +01:00