Commit graph

62 commits

Author SHA1 Message Date
Vlad Zahorodnii
4dafacc00b kwineffects: Stop linking kwayland-server
As is, libkwineffects doesn't use any specific apis in kwayland-server,
it simply "forwards" wayland display and surfaces from libkwin. Given
that, there is no need to link libkwineffects with kwayland-server. If
an effect needs to access wayland specific stuff, it can link explicitly
against kwayland-server.

The main motivation behind this change is to further loosen up
dependencies between various kwin components and kwayland-server so the
latter can be moved back to kwin.
2021-10-18 16:03:30 +00:00
Vlad Zahorodnii
a5a2deef60 kwineffects: Remove effectively unused surface_interface.h include
SurfaceInterface can be an opaque pointer.
2021-10-18 11:34:15 +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
Aleix Pol
c07182490d pipewire: Fix downloading software-rotated textures
At the moment we'll be setting the YInverted setting, but in practice
that won't have any effect as it only changes the render matrix and
we'll end up streaming inverted textures.
This change addresses it by rendering it into another texture first to
resolve this situation and then download that new texture instead.
2021-10-13 17:16:15 +02:00
Vlad Zahorodnii
21a17c87db libkwineffects: Simplify EffectQuickView constructors
This simplifies EffectQuickView constructors and ensures that there
won't be a crash if compositing is off.
2021-09-23 06:28:29 +00:00
Vlad Zahorodnii
1b215e6c06 libkwineffects: Avoid accessing effects in EffectQuickView
EffectQuickView is used by Aurorae. As long as Aurorae decorations are
rendered by kwin, it's not a problem. However, kde-gtk-config kded
module can also render them. This creates a problem. If effects object
is not created, accessing any of its getters or setters will result in a
segmentation fault.

This change rewrites the share context check so the effects object is
not accessed anymore.

One could argue that kde-gtk-config has to provide a dummy EffectsHandler
but it doesn't use effects and libkwineffects is not a dependency of
KDecoration2. So, providing a dummy EffectsHandler makes no sense.

In hindsight, we need to revisit the usage of EffectQuickView in Aurorae
as accessing the EffectsHandler in EffectQuickView is a totally valid
usecase and integration of QOpenGLContext.

BUG: 441585
2021-09-23 06:28:29 +00:00
Kai Uwe Broulik
8bebf5cee1 Port to function-pointer based QMetaObject::invokeMethod
It's more efficient and compile-time checked
2021-09-07 06:30:39 +00:00
Janet Blackquill
6231699ac1 Lay some groundwork for realtime gestures in Wayland
This lays down some groundwork for realtime gestures in Wayland,
so that gestures that are 1:1 with user motion on a touchpad are
now possible to implement.

Due to earlier commits, this is mostly just glue code to make a
convenient API.

Gestures implemented with this API are four-finger gestures, to
avoid conflicting with apps that may use two or three-finger
gestures.
2021-09-01 19:48:41 -04:00
Vlad Zahorodnii
fff32f64e6 effects: Drop EffectsHandler::screenGeometryChanged()
It's confusing to have two signals (virtualScreenGeometryChanged() and
screenGeometryChanged()) that indicate the same thing.
2021-08-27 09:23:33 +00:00
Aleix Pol
9a4bbdf226 Make it possible for an effect to render a screen
Useful in case it needs the contents of the screen but they can't be
blitted, as the state of the framebuffer is unknown.
2021-08-25 14:44:03 +00:00
Aleix Pol
4d1f30301b Make KWin::TimeLine::progress() public
This way we can have animations that act slightly different in different
parts of the animation
2021-08-25 14:44:03 +00:00
Aleix Pol
24cc93ec5b effects: Allow exposing an EffectScreen::transform
This way an effect can know the transformation that is applied on a
display.
2021-08-25 14:44:03 +00:00
Aleix Pol
34cfc6680b effects: Include signals notifying about outputs changing 2021-08-25 14:44:03 +00:00
Vlad Zahorodnii
c66f38ba7d kwineffects: Add properties to EffectScreen
This allows exposing EffectScreen to effects that use js or qml.
2021-08-19 06:30:55 +00:00
Vlad Zahorodnii
9675da6325 kwineffects: Allow specifying render window for EffectQuickView
QtQuick can use the render window to compute the device pixel ratio for
the managed QQuickWindow.
2021-08-19 06:30:55 +00:00
Vlad Zahorodnii
c79d7f56dd kwineffects: Disable OpenGLContext sharing check in EffectQuickView
On Wayland, QOpenGLContext::shareContext() will always return null even
if the newly created context has a share context.
2021-08-19 06:30:55 +00:00
Vlad Zahorodnii
b32592f54e kwineffects: Allow disabling automatic frame scheduling in EffectQuickView 2021-08-19 06:30:55 +00:00
Manuel Stoeckl
2aa3ed0005 Use texture unpacking for QImage uploads when possible
This change avoids unnecessary copying of QImage data when updating
textures using QImages that have non-ARGB32_Premultiplied formats.

There are three cases where texture unpacking can not be done/is
not worth doing: if GLES is used, and the extension for unpacking
subimages is not supported; if the entire image is being updated;
or if a format conversion needs to be done, in which case only the
region to update will have its format converted, and the resulting
image can be passed directly to glTexSubImage2d without setting
unpacking parameters.
2021-08-16 06:30:59 +00:00
Manuel Stoeckl
51d82fc6e5 Replace an old workaround for alpha-only shadows
SceneOpenGLShadow::prepareBackend used to use QImage::Format_Indexed8,
plus a special code path in GLTexture, to create single-channel OpenGL textures.
Now that Qt supports QImage::Format_Alpha8, this workaround can be removed.
2021-08-11 23:32:18 -04:00
David Edmundson
60255fd7a9 Teardown view before QQuickRenderControl
Deleting QQuickWindow will force any remaining runnables to complete.
This is important for any items (such as our new ThumbnailItem) that
deletes resources in queued cleanups.

We need to invoke this manually whilst we still have an active render
control with a valid context, otherwise remaining runnables will no-op.

We also then want to manually delete our scene contents before the view
so they're not orphaned temporarily.

This fixes a memory leak observed with the new Overview effect.
2021-08-11 07:31:53 +00:00
Manuel Stoeckl
aa386896f1 Rename QImage to GL format conversion table
Also expand the comment describing it.
2021-08-10 14:21:48 +00:00
Manuel Stoeckl
b440be5bd2 Avoid converting images when updating GLTexture
In GLTexture::update, reuse the mechanism from the GLTexture(QImage, ...)
constructor to upload QImage data directly when the QImage format
has compatible GL format and type codes. Before this change, all QImage
formats other than ARGB32_Premultiplied required a format conversion.
2021-08-10 14:21:48 +00:00
Vlad Zahorodnii
1dae29175f kwineffects: Fix potential image detaching
QImage is implicitly shared. However, methods such as QImage::bits() may
detach. In order to avoid the detach, one either needs make the image
const or use QImage::constBits() method.

Currently, the GLTexture class uses QImage::bits() all over the place.
It prevents implicit detaching by storing images in const variables. Such
code is fragile. Adding an intermediate (optional) conversion step may
result in odd performance regressions.
2021-08-06 07:20:54 +00:00
Aleix Pol
475993db70 kscreen effect: Work per screen
Makes it possible to apply the dpms settings per screen instead of
applying it to all of them, which is wrong at many levels.
Will be even more important with other effects like rotation.
2021-07-28 10:57:27 +00:00
Aleix Pol
23129c09ce SceneOpenGL2::paintCursor make sure the OpenGL context is current
Instead of painting right away when Cursors::currentCursorChanged is
emitted, mark as dirty and call again when paintCursor is called.

BUG: 439134
2021-07-12 13:15:29 +00:00
Aleix Pol
eb62dbb9c5 Allow the KScreenEffect to work on Wayland
Makes it possible for wayland systems to show a dimming effect when a
display dpms is off.
2021-07-09 12:39:42 +02:00
Vlad Zahorodnii
c6ffdf4f7f kwineffects: Remove WindowQuad::uvAxisSwapped
Since makeSubQuad() uses bilinear interpolation, the flag to indicate
whether UV-coordinates are swapped is redundant.
2021-07-04 16:12:06 +00:00
Vlad Zahorodnii
172c541cad x11: Use global share context
This is needed to share window thumbnails between kwin's scene graph and
qtquick.
2021-06-23 17:45:48 +03:00
Vlad Zahorodnii
fac33750f9 effects: Remove shape property
It's unused and the advantages of keeping it are outweighed by the
disadvantages - the returned value is dependant on the window type.

If you need to draw a drop-shadow that matches the shape of the window
or something along that line, render the window into an offscreen
texture and sample the alpha channel in a fragment shader.
2021-06-23 11:21:51 +00: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
61159d943c effects: Fix interpolated values for redirected animations
If a redirected animation reaches the end, the timeline value will be 0,
i.e. the interpolated() function has to return the from value, not `to`.

BUG: 438368
2021-06-15 08:46:58 +03:00
Vlad Zahorodnii
f9cf0baead kwineffects: Allocate hidpi textures in DeformEffect
If a window is animated using DeformEffect, allocate an offscreen
texture with the scale factor of the screen where the window is
considered to be on.

Also, resize the offscreen texture on demand in order to make resource
handling more efficient.
2021-06-14 09:02:44 +00:00
Vlad Zahorodnii
4af9d6c234 kwineffects: Remove unused WindowVertex and WindowQuad props
Since window quads are no longer passed in prePaintWindow(), we don't
need to track original vertex coords. This results in smaller memory
footprint.
2021-06-14 07:56:02 +00:00
Vlad Zahorodnii
49744cfc53 scene: Improve window quad management
At the moment, we handle window quads inefficiently. Window quads from
all items are merged into a single list just to be broken up again.

This change removes window quads from libkwineffects. This allows us to
handle window quads efficiently. Furthermore, we could optimize methods
such as WindowVertex::left() and so on. KWin spends reasonable amount
of time in those methods when many windows have to be composited.

It's a necessary prerequisite for making wl_surface painting code role
agnostic.
2021-06-14 07:56:02 +00:00
Vlad Zahorodnii
29cc319455 kwineffects: Remove WindowQuadType
The window quad type has become irrelevant.
2021-06-14 07:56:02 +00:00
Vlad Zahorodnii
86bb4e68ef Refactor window quad handling
The scene items depend on the scene windows for caching window quads.
The goal of this change is to move window quads management to item.

Merging window quads in one list and then splitting them is inefficient,
it will be highly desirable if window quads are removed from the public
api so we can optimize window quad management.

With this change, the window quad type becomes irrelevant to render
backends for the most part. Note that the Xrender backend is a bit
nitpicky about window quads, so the shadow item doesn't create generic
"WindowQuadShadow" quads anymore.
2021-06-11 06:03:08 +00:00
Vlad Zahorodnii
30d0dbbaf0 Remove EffectsHandler::buildQuads()
It's currently unused and it doesn't fit the item based scene design.
2021-06-11 06:03:08 +00:00
Vlad Zahorodnii
f280423b92 kwineffects: Remove PaintClipper
PaintClipper worked only with the XRender backend, which is gone now.
2021-06-10 15:58:33 +00:00
Vlad Zahorodnii
3ae400772b kwineffects: Remove dead code
AnimationEffect sets the clip region to clip windows, so this code can
be safely removed.
2021-06-10 15:58:05 +00:00
Aleix Pol
bec50eaec0 deform effect: Use the provided matrix instead of creating a new one 2021-06-10 10:06:35 +02:00
Vlad Zahorodnii
a06690021d Remove OpenGL2Compositing enum
OpenGLCompositing and OpenGL2Compositing enums mean de-facto the same
thing, it's confusing to have them both.
2021-06-09 15:24:22 +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
Alexander Lohnau
9c689d7ddb plugins: Port away from deprecated version checks
Task: https://phabricator.kde.org/T14302
2021-06-07 15:01:19 +00:00
Vlad Zahorodnii
048c732a4e scenes/opengl: Remove half-pixel correction workaround
It was needed to work around visual glitches in the wobbly windows
effect. Since the wobbly windows effect renders the animated window into
an offscreen texture, we don't need this workaround anymore.

Furthermore, rather than using half-pixel correction, it is more
desirable to use an offscreen texture as it results in simpler design.
Performance-wise, it's not that bad that we need to start looking for
other ways to get rid of the seams between window contents and deco.
2021-05-31 05:27:22 +00:00
Vlad Zahorodnii
5255ebf8d0 kwineffects: Introduce DeformEffect
DeformEffect is the base class for effects that transform the window
quad grid, e.g. wobbly windows or magic lamp. The main difference
between normal effects and offscreen effects is that the latter renders
animated windows into offscreen textures which are later deformed.

The offscreen texture approach is superior to the half-pixel correction
approach as it produces more visually appealing results. Even with
half-pixel correction, you're still going to see jagged lines between
the main surface and the server-side decoration or drop-shadow.

It is also needed to reduce the number of usages of WindowPaintData::quads
which is needed to move forward with the scene redesign goal.
2021-05-31 05:27:22 +00:00
Vlad Zahorodnii
d4ade78aac kwineffects: Add parent argument to Effect 2021-05-31 05:27:22 +00:00
Vlad Zahorodnii
b814b3c985 kwineffects: Add client geometry property
This property can be useful for the screenshot effect.
2021-05-28 11:05:38 +03:00
Aleix Pol
3c7290b722 Abstract startup semantics in the startupfeedback effect 2021-05-24 17:19:08 +02:00
David Edmundson
af66f39f19 Support High DPI Aurorae decorations
With high DPI we can't use the image size as a logical size directly.

The other change is use of QPainter::drawImage(QRect target, QImage
image, QRect source)

This slightly confusing method uses logical pixels for the target, but
the source rect is in native pixels of the source.

BUG: 422342
2021-05-21 11:26:53 +00:00