Commit graph

122 commits

Author SHA1 Message Date
Vlad Zahorodnii
4faad8bd49 effects.h -> effecthandler.h 2023-11-20 15:47:36 +00:00
Vlad Zahorodnii
25ab2b53dd Extract EffectWindow into its own header 2023-11-20 15:47:36 +00:00
Vlad Zahorodnii
961bd00919 Move WindowVertex,WindowQuad,RenderGeometry out of effects.h
These are core scene abstractions and don't belong in effects.h.
2023-11-20 14:05:52 +02:00
Vlad Zahorodnii
86084d118c libkwineffects/ -> effect/ 2023-11-20 11:32:43 +00:00
Vlad Zahorodnii
75f9fda962 Clean up workspacescene.h includes 2023-11-20 11:32:43 +00:00
Huang-Huang Bao
3d4036210d
scene: use fractionalGeometry() as input of RenderViewport renderRect
Fixes mismatches between renderTarget.size() and deivce geometry calculated using viewport.renderRect() * viewport.scale() .

BUG: 475325
2023-11-20 06:14:55 +08:00
Vlad Zahorodnii
36021b12a7 Drop redundant "kwin" prefix in some filenames 2023-11-16 13:37:50 +00:00
Aleix Pol Gonzalez
3568829216 opengl: Add support for NV12 on Wayland dmabufs
Offers wayland clients the possibility to send us their contents using
an NV12 texture.
It implements it by rendering into scene using a shader.
2023-11-15 21:32:25 +01:00
Vlad Zahorodnii
15b47ce7fc Merge EffectsHandlerImpl and EffectsHandler 2023-11-15 15:21:50 +02:00
Xaver Hugl
ee146d33b9 libkwineffects: move files out to more fitting places 2023-11-14 17:03:40 +01:00
Vlad Zahorodnii
79d5a70c01 wayland: Make SurfaceInterface::{frameRendered,takePresentationFeedback} not touch subsurface tree
This gives us greater flexibility and in general more cleaner code.
2023-11-14 14:58:40 +00:00
Xaver Hugl
7bf38e54bf wayland: implement presentation time 2023-11-13 14:25:26 +01:00
Vlad Zahorodnii
0b8b9b70bb Merge EffectWindowImpl with EffectWindow
The indirection no longer required because libkwineffects has been
merged with libkwin. EffectWindow will be eventually dropped in favor
of apis provided by Window and WindowItem.
2023-11-13 11:24:04 +00:00
Xaver Hugl
9d4fe3adf1 implement the frog color management protocol 2023-11-07 20:23:06 +01:00
Xaver Hugl
21d8b58e82 scene/surfaceitemwayland: set initial color description 2023-11-01 21:02:38 +01:00
Vlad Zahorodnii
b3b2e96148 libkwineffects: Replace EffectScreen with Output 2023-10-25 15:13:14 +00:00
Xaver Hugl
0391b65628 scene/itemrenderer_opengl: switch shaders depending on the input
This allows using more expensive shaders where needed, and less expensive ones
where possible
2023-10-25 14:19:12 +00:00
Xaver Hugl
09278caf48 add colorspace metadata to surfaces and items, and use it in the OpenGL renderer 2023-10-25 14:19:12 +00:00
Xaver Hugl
7ad1c163a3 scene/cursordelegate_opengl: recreate texture if the format is wrong 2023-10-24 14:16:39 +00:00
Vlad Zahorodnii
0f7369ed1b Fix scheduling repaints in Effect::prePaintScreen()
If a repaint is scheduled in the prePaintScreen() function, we want
it to be applied in the next frame, not the current one.

Currently, it doesn't work like this because prePaintScreen() runs first
then the Compositor gathers repaints and resets them.

This is important to qtquick effects that use qtquick3d as some items in
qtquick3d schedule repaints for the next frame after synchronizing, i.e.
in OffscreenQuickView::update() which is called in prePaintScreen() by
QuickSceneEffect.
2023-10-23 12:53:20 +00:00
Laurent Montel
bc6116c5a7 There's no QVector anymore, QList is the QVector in Qt6 2023-10-19 13:43:53 +00:00
Vlad Zahorodnii
6974f54149 Move EffectWindowImpl ownership to WindowItem
EffectWindowImpl affects rather the WindowItem, so move its ownership to
it. This encapsulates compositing setup so it's effectively same as
creating a window item, except some annoyances on X11.
2023-10-09 07:50:05 +00:00
Xaver Hugl
1e6f46eb0c scene/imageitem: don't crash if uploading a texture fails
BUG: 474952
2023-09-28 12:59:53 +02:00
Vlad Zahorodnii
7c43f56665 Drop scene initialization functions
They are not needed anymore since the scenes are created when workspace
exists.
2023-09-22 14:06:24 +00:00
Xaver Hugl
f223362ddf scene/cursordelegate_opengl: fix projection matrix with rotated screens 2023-09-19 13:41:00 +02:00
Vlad Zahorodnii
de36fe82e8 wayland: Integrate KWaylandServer classes into KWin namespace 2023-09-15 16:31:15 +03:00
Vlad Zahorodnii
8bf2318800 wayland: Drop "_interface" from filenames
The cpp files in the wayland directory are named after protocol names.
"_interface" does not contribute anything new.
2023-09-15 13:13:43 +00:00
Vlad Zahorodnii
6dd6e176e3 Move X11Compositor and WaylandCompositor in their own files 2023-09-08 09:49:40 +03:00
Vlad Zahorodnii
14ab38b596 composite.h -> compositor.h 2023-09-08 09:48:59 +03:00
Xaver Hugl
27f90476b4 libkwineffects: rename kwingl* files to gl* 2023-09-07 16:41:22 +02:00
Kai Uwe Broulik
dc2965efad scene: Set preferred output scale for DND icon
Otherwise the icon will have a scale of 1, leading to blurry
drag pixmaps on Wayland.
2023-09-05 18:41:29 +00:00
Xaver Hugl
ab3e517d8a libkwineffects/glvertexbuffer: simplify setAttribLayout 2023-09-05 13:23:36 +00:00
David Edmundson
10ed34bc9d Avoid painting unchanged scene layers
Currently when we move the mouse the one render loop triggers a repaint.
When the cursor layer needs a new update we end up in the compositor
repainting the main content.

Even though painting should mostly no-op it still goes through all
existing items and effects to collect damage, still potentially making
the GL context current which could stall. A waste when we know we
haven't got anything to do. It's enough to cause noticable mouse lag on
some hardware.

Co-authored-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2023-08-28 11:38:18 +00:00
Vlad Zahorodnii
adf8ed8f34 scene: Port qpainter rendering away from surface-to-buffer matrix
This fixes rendering of surfaces with transformed buffers in qpainter
renderer.
2023-08-21 13:12:23 +00:00
Xaver Hugl
267dd543f2 scene: port away from manual memory management 2023-08-11 15:47:36 +02:00
Vlad Zahorodnii
1687183d4d qpa: Port OpenGL code path to GraphicsBuffer
This allows us to unify graphics buffer handling for normal wayland
windows and internal windows.
2023-08-07 13:17:18 +00:00
Vlad Zahorodnii
c2dfb55c59 wayland: Implement xdg-shell v6
This change adds support for xdg_wm_base v6, which introduces
xdg_toplevel suspended state.

The suspended state is tied to the visibility of the window item so the
effects could possibily "resume" window content updates.
2023-08-07 12:21:28 +00:00
Vlad Zahorodnii
b25e7a849b scene: Make ImageItem use linear filter and clamp-to-edges wrap mode
Use the linear filter to ensure that the cursor doesn't look blocky with
some scale factors and use the clamp-to-edge wrap mode to avoid
potential artifacts when the image is scaled.
2023-07-31 07:02:00 +00:00
Vlad Zahorodnii
50bc9bb1f1 scene,wayland: Make tracking of the buffer source box less error prone
At the moment, the SurfaceItem needs to track individual properties that
may contribute to the buffer source box. That's error prone.

To fix that, this change makes the SurfaceInterface indicate when the
source box has changed and the SurfaceItem should sync its source box,
discard quads, etc.
2023-07-27 10:55:14 +00:00
Vlad Zahorodnii
762254c354 qpa: Port BackingStore to shared memory graphics buffer allocator
At the moment, graphics buffers coming from wayland and internal windows
use different code paths to update textures. However, they don't have
to.

If the internal windows are ported to GraphicsBuffer, it will be
possible to unify SurfacePixmapInternal and SurfacePixmapWayland to make
pixmap logic a bit simpler.
2023-07-26 07:29:27 +00:00
Vlad Zahorodnii
29229c5aff scene: Fix syncing buffer source box with 100% scale
The buffer source box is synchronized when the surface-to-buffer matrix
changes. However, when using 100% scaling, it's likely that the
surface-to-buffer matrix will be identity and therefore no corresponding
signal to indicate the change will be emitted.

To fix that, we need to update the buffer source box also when the
buffer size changes.
2023-07-25 14:28:01 +03:00
Vlad Zahorodnii
9a2355339c core: Rework OutputTransform type
In some cases, it's desired to know what the inverse transform of a
given output transform is. It's possible to make it work by providing
helper functions, but we tend to avoid doing so.

This change converts the OutputTransform from an enum to a class so it's
possible to have both data + methods in the same type. Unfortunately,
unlike Rust, C++ provides no way to attach methods to enums, classes and
structs is the only way to go.
2023-07-25 12:09:19 +03:00
Vlad Zahorodnii
637e3a6389 core: Move Output::Transform enum to KWin namespace
Being in the KWin namespace has a couple of advantages: the enum can be
forward declared, and the transform can be replaced with a slightly more
complex but useful type.
2023-07-25 12:09:01 +03:00
Vlad Zahorodnii
9e898c0e68 scene: Expand surface damage if the surface is scaled
If the surface item's contents is scaled, i.e. its scale factor doesn't
match the output's scale, GL_LINEAR will be applied to smooth the
contents. The unfortunate thing is that it's possible some of the
changed pixels will bleed to the neighbor ones.

In order to handle that scenario better, this change makes the
SurfaceItem expand the damage if there's scale factor mismatch.

bufferSourceBox and bufferTransform properties were introduced to detect
if the surface contents is going to be scaled. bufferSourceBox covers
both crop transform from wp_viewport and scale factor from wl_surface.
bufferTransform is same as wl_surface's buffer transform property.
2023-07-25 12:09:01 +03:00
Vlad Zahorodnii
bad25bd5c7 Revert "scene: Pad damage if scale factor is fractional"
This reverts commit 56f6bab0c3.
2023-07-25 12:09:00 +03:00
Laurent Montel
b823747c3b Add explicit moc includes to sources for moc-covered headers
* speeds up incremental builds as changes to a header will not always
  need the full mocs_compilation.cpp for all the target's headers rebuild,
  while having a moc file sourced into a source file only adds minor
  extra costs, due to small own code and the used headers usually
  already covered by the source file, being for the same class/struct
* seems to not slow down clean builds, due to empty mocs_compilation.cpp
  resulting in those quickly processed, while the minor extra cost of the
  sourced moc files does not outweigh that in summary.
  Measured times actually improved by some percent points.
  (ideally CMake would just skip empty mocs_compilation.cpp & its object
  file one day)
* enables compiler to see all methods of a class in same compilation unit
  to do some sanity checks
* potentially more inlining in general, due to more in the compilation unit
* allows to keep using more forward declarations in the header, as with the
  moc code being sourced into the cpp file there definitions can be ensured
  and often are already for the needs of the normal class methods
2023-07-15 08:40:49 +00:00
Vlad Zahorodnii
df8cb7df3c wayland: Make surface damage buffer local
This allows us to avoid losing precision when updating surface pixmaps.
Surface damage needs special handling either way.

Another advantage from switching to buffer damage is that it lets us to
decouple surface textures from surface items, which is useful for making
surface helpers more reusable.
2023-06-20 08:27:18 +00:00
Matthias Dahl
56f6bab0c3 scene: Pad damage if scale factor is fractional
Floating point arithmetic and/or the use of GL_LINEAR in the pipeline,
may result in visual glitches due to rounding (errors). As a short-term
fix until a proper (more involved) solution is in place for Plasma 6,
pad the damage slightly in all directions to alleviate those effects.
2023-06-09 15:05:06 +02:00
Vlad Zahorodnii
eea8200479 scene: Don't hide closed windows
If a closed window is kept alive, it means that somebody needs to
animate it and therefore it should be visible. Otherwise the window
would be destroyed and its item would be removed from the scene.

This change makes the WindowItem not change its visibility if the
associated window is closed. If the window had been invisible before
it was closed, the item would be invisible; if the window had been
visible before it was closed, the item would be visible.
2023-06-06 14:13:57 +00:00
Vlad Zahorodnii
b90ae2f8fc Move window hiding logic to Window
The window hiding logic is mostly the same both in X11 and Wayland
windows, so let's move it in Window to share the same code.
2023-06-06 13:58:44 +00:00