Commit graph

37 commits

Author SHA1 Message Date
Vlad Zahorodnii
48f943bd75 Introduce explicit base render backend type
The main idea behind the render backend is to decouple low level bits
from scenes. The end goal is to make the render backend provide render
targets where the scene can render.

Design-wise, such a split is more flexible than the current state, for
example we could start experimenting with using qtquick (assuming that
the legacy scene is properly encapsulated) or creating multiple scenes,
for example for each output layer, etc.

So far, the RenderBackend class only contains one getter, more stuff will
be moved from the Scene as it makes sense.
2021-11-11 08:55:29 +00:00
Vlad Zahorodnii
1d96b41bb4 build: Move software vsync helpers to libkwin
Compile software vsync helpers into libkwin for the consistency sake
with other helpers.
2021-11-09 18:15:32 +00:00
Vlad Zahorodnii
3485eb6200 cmake: Move base render backend classes to libkwin
This allows using base opengl backends in libkwin, which can be useful
later on for the purpose of moving the ownership of render backends from
the Scene class to the Compositor class.
2021-11-08 18:27:22 +00:00
Vlad Zahorodnii
c5477011ed Add missing KWIN_EXPORT in QPainterBackend 2021-11-08 18:27:22 +00:00
Xaver Hugl
e1942cfa41 qpainter: remove outdated comment 2021-11-08 14:19:05 +00:00
Vlad Zahorodnii
baf05ec4a5 Rename PlatformSurfaceTexture to SurfaceTexture
This is, primarily, to make naming consistent with SurfaceItem,
SurfacePixmap and just "Surface" in the future.
2021-10-21 10:21:56 +03:00
Vlad Zahorodnii
23e5039918 Fix build on Gentoo
AbstractEglBackend includes option.h, which includes main.h, which
includes QApplication. Since SceneOpenGLBackend doesn't link against
Qt::Widgets, kwin fails to build on Gentoo, but not on other distros
for some reason...
2021-10-17 15:49:57 +00:00
Vlad Zahorodnii
bf620fbe04 Move Xkb::LEDs enum to KWin namespace
With the LEDs enum being defined in kwinglobals.h, wayland_server.h
won't need to include keyboard_input.h, which is good for compilation
times and wayland_server.h will drag less stuff, e.g. QtWidgets (input.h
includes QAction)
2021-10-13 17:49:19 +00:00
Martin Flöser
68589fe937 compositor: Merge the OpenGL 2 and 3 backends
This change merges the two OpenGL backends into one making the current
default of GLCore the overall default. It becomes the first context to
try to create. If it fails, it will automatically fall back to the
(previous) OpenGL 2 backend.

Reasoning: the differentiation of OpenGL 2 and 3 is a very technical one
and hard to understand for users. It is not obvious which one is better
or should be used. This results in many user discussions like "Which
backend to use?"

Back when the OpenGL 3 backend was introduced the dedicated feature made
sense. It was a new code base using new driver features. Nowadays the
code base in KWin is robust and mature and so are the drivers. A driver
advertising support for OpenGL 3 will support OpenGL 3. We don't have to
plan for driver breakage in this area any more.

Also our code evolved through the context attribute builder which gives
us the possibility to more easily fall back in case we cannot create the
context. Thus the need to select the backend is not so important as it
used to be when the feature got introduced.

If a user still wants to force OpenGL2, it is still possible by setting
the appropriate environment variables like MESA_GL_VERSION_OVERRIDE.

This change brings the improvement that the backend selection is now
completely removed from the compositing KCM.
2021-10-08 15:26:25 +00:00
Xaver Hugl
1be65e818c Port screenId based rendering methods to AbstractOutput 2021-08-25 13:53:33 +02:00
Vlad Zahorodnii
7f883fa724 Make EGL_KHR_surfaceless_context mandatory
We use surfaceless contexts with internal windows. We also require
the EGL_KHR_surfaceless_context extension for making context current
without outputs.

Arguably, we could use pbuffers, but since mainstream drivers (Mesa and
NVIDIA) support surfaceless contexts, the extra complexity doesn't buy
us anything.
2021-08-16 10:56:46 +00:00
Vlad Zahorodnii
2a04a3d42c Remove Platform::sceneEglContext()
It's unused.
2021-08-16 08:08:31 +00:00
Vlad Zahorodnii
e315b0f9fe Remove Platform::sceneEglConfig()
With per-screen rendering, every output may have different EGLConfig.
Having a single global EGLConfig doesn't work out well.

This change removes Platform::sceneEglConfig(). It's used primarily to
create the global share context. In hindsight, the global share context
can be created without EGLConfig as it's never made current.

EGL_NO_CONFIG_KHR is part of EGL_KHR_no_config_context extension, which
is supported by both Mesa and NVIDIA driver so it should be safe to make
it mandatory.
2021-08-16 08:08:31 +00:00
Vlad Zahorodnii
7e9c6587db Remove scene window traces in scene items
This further decouples scene items from scene windows. The SurfaceItem
still needs to access the underlying window, I would like to re-iterate
over that later.

With this change, it will be possible to introduce WindowItem factory
function in the Toplevel class.
2021-08-12 17:52:24 +00:00
Vlad Zahorodnii
cb219da766 Remove screenGeometryChanged() in OpenGLBackend and QPainterBackend
The screenGeometryChanged() function is very X11-specific. On Wayland,
it's effectively unused.
2021-07-26 14:55:54 +00:00
Vlad Zahorodnii
501298b0e0 Introduce DamageJournal helper 2021-07-24 16:32:13 +03:00
Vlad Zahorodnii
2fe102768a Remove QPainterBackend::needsFullRepaint()
A better alternative is to return the damage region in the beginFrame()
function. This way, the render backend can force full screen repaints or
indicate what parts of the buffer needs to be repainted (for buffer age)
2021-07-24 14:54:17 +03:00
Vlad Zahorodnii
4abbb6f0d6 Make OpenGLBackend and QPainterBackend QObjects
Almost all their subclasses are QObjects. This simplifies the class
hierarchy by making OpenGLBackend and QPainterBackend qobjects.
2021-07-24 11:30:13 +03:00
Vlad Zahorodnii
d543c0dff6 Remove unused mask param in QPainterBackend::endFrame()
It is unused and it is not a good idea to pass Scene's mask to the
render backend as it results in higher coupling between Platform and
Scene.
2021-07-23 20:42:59 +00:00
Vlad Zahorodnii
964c487d4f wayland: Switch to ClientBuffer
The main motivation behind the split is to simplify client buffer code
and allow adding new features easier, for example referencing the shm
pool when a shm buffer is destroyed, or monitoring for readable linux
dmabuf file descriptors, etc.

Also, a referenced ClientBuffer cannot be destroyed, unlike the old
BufferInterface.
2021-07-23 15:33:38 +00:00
Vlad Zahorodnii
f431b6ad96 wayland: Cache last surface-to-buffer matrix
If window quads need to be generated after the wl_surface is destroyed,
the SurfaceItemWayland::mapToBuffer() function will return wrong values.

In order to fix that, we need to store the last surface-to-buffer matrix
in SurfaceItem.
2021-07-22 06:26:00 +00:00
Vlad Zahorodnii
8ed364337b scenes/opengl: Allow setting external global share context
This is needed to initialize global share context on X11.
2021-06-23 17:45:48 +03:00
Vlad Zahorodnii
4206d8bd9c Remove unused include 2021-06-22 11:45:44 +03:00
Vlad Zahorodnii
10769548db kwineffects: Allow creating GLTexture without allocated storage
This allows creating a GLTexture object and attaching a dmabuf to it.
Currently, we can do that by using the foreign GLTexture constructor,
but it makes the deletion of the texture handle more error prone.

In the future, we can add a method that allocates the texture storage,
but there's no need for that yet.
2021-06-22 08:25:50 +00:00
Vlad Zahorodnii
811beb94e0 Remove Xrender backend
The Xrender backend was added at the time when OpenGL drivers were not
particularly stable. Nowadays though, it's a totally different situation.

The OpenGL render backend has been the default one for many years. It's
quite stable, and it allows implementing many advanced features that
other render backends don't.

Many features are not tested with it during the development cycle; the
only time when it is noticed is when changes in other parts of kwin break
the build in the xrender backend. Effectively, the xrender backend is
unmaintained nowadays.

Given that the xrender backend is effectively unmaintained and our focus
being shifted towards wayland, this change drops the xrender backend in
favor of the opengl backend.

Besides being de-facto unmaintained, another issue is that QtQuick does
not support and most likely will never support the Xrender API. This
poses a problem as we want thumbnail items to be natively integrated in
the qtquick scene graph.
2021-06-09 11:21:57 +03:00
Vlad Zahorodnii
1b2c7b248b Run clazy with qt-keywords fixit
In C++20, there will be emit() class member, which can conflict with the
emit keyword. Given that, there are plans to enable QT_NO_KEYWORDS by
default in the future.

See also
https://lists.qt-project.org/pipermail/development/2020-February/038812.html
2021-06-08 10:49:42 +03:00
Xaver Hugl
c5ea99cbe5 AbstractEglBackend: only clean up OpenGL context if primary 2021-06-03 14:44:14 +02:00
Vlad Zahorodnii
bd4650482e Remove unused class forward declarations in scene.h 2021-05-18 12:24:56 +03:00
Vlad Zahorodnii
0f2f69ad7c Decouple window pixmaps from scene windows
One of the scene redesign goals is to make wayland surface items
re-usable. So we have the same rendering path for drag-and-drop icons,
software cursors, and window surfaces.

The biggest issue at the moment is that window pixmaps are tightly
coupled with scene windows.

This change de-couples window pixmaps from scene windows. In order to
achieve that, some architecture changes were made.

The WindowPixmap class was replaced with the SurfacePixmap class. A
surface pixmap is created by a surface item.

Under the hood, a SurfacePixmap will create a PlatformSurfaceTexture
object, which contains all the information necessary for the renderer.

The SceneOpenGLTexture class was removed. However, the GLX and the EGL
on X11 backends still mess with GLTexture's internals.
2021-05-18 09:11:24 +00:00
Aleix Pol
f4adff66cc Do not detach when getting a readonly reference 2021-05-14 01:35:33 +02:00
Aleix Pol
035ea75ab7 Use qAsConst in fors when there's a risk for it to detach 2021-05-14 01:35:33 +02:00
Aleix Pol
50dd08531e Make sure we do not get references on temporary objects 2021-05-14 01:35:33 +02:00
Vlad Zahorodnii
326d211691 platform: Use damage tracked by SurfaceItem
There is no need for both kwin and kwaylandserver track damage.
2021-03-31 13:56:55 +00:00
Vlad Zahorodnii
2ade92d69b platform: Make OpenGLBackend::scanout take SurfaceItem
This allows removing SurfaceInterface::trackedDamage().
2021-03-31 13:56:55 +00:00
Vlad Zahorodnii
0f1afdbdc0 scene: Pass dirty region to SceneOpenGLTexture::updateTexture 2021-03-31 13:56:55 +00:00
Xaver Hugl
c1635c1179 Explicitly preserve buffer contents in EglDmabuf 2021-03-23 20:00:00 +00:00
Vlad Zahorodnii
93e0265e4e Move source code to src/ directory
Once in a while, we receive complaints from other fellow KDE developers
about the file organization of kwin. This change addresses some of those
complaints by moving all of source code in a separate directory, src/,
thus making the project structure more traditional. Things such as tests
are kept in their own toplevel directories.

This change may wreak havoc on merge requests that add new files to kwin,
but if a patch modifies an already existing file, git should be smart
enough to figure out that the file has been relocated.

We may potentially split the src/ directory further to make navigating
the source code easier, but hopefully this is good enough already.
2021-02-10 15:31:43 +00:00