Commit graph

191 commits

Author SHA1 Message Date
Vlad Zahorodnii
21691fe570 scene: Fix animated software cursor not updating
The Item schedules repaints per scene delegate. Currently, there are no
any attached scene delegates when using software cursor, which results in
it freezing as soon as it stops moving.

The issue is addressed by using SceneDelegate instead of RenderLayerDelegate.

The proposed code is not great, but on the other hand, the plan is to
embed the software cursor in the workspace scene if needed.

BUG: 490440
2024-09-07 08:11:25 +00:00
Vlad Zahorodnii
8443da3083 scene: Fix attempting to scanout empty surfaces
X11 windows might be mapped but temporarily have missing wl_surface or
the wl_surface can be temporarily unmapped.

CCBUG: 491964
2024-09-03 12:44:25 +00:00
Vlad Zahorodnii
b708a93c1e scene: Add an assert to debug crash in BlurEffect::prePaintWindow()
This checks whether a WindowItem is destroyed in the middle of a painting
cycle.

This is meant as short-term means to debug the issue.
2024-08-30 18:54:11 +00:00
Aleix Pol Gonzalez
6c4ded2034 input: Allow different surfaces to be interacted in parallel by touch
While on pointers and keyboards the focus patterns follows rather
naturally, on touch screens it doesn't so much.
This change adapts our touch infrastructure to allow for multiple
surfaces to be issued touch events without forcing all interactions into
the same one.

Signed-off-by: Victoria Fischer <victoria.fischer@mercedes-benz.com>
2024-08-28 09:36:51 +00:00
Vlad Zahorodnii
4bc74d6831 scene: Ignore xwayland window shape
The shape region is used to clip the window contents. But, in practice,
it's used by a few applications. The most notable is xeyes.

The APIs that the shape region requires are manageable, but it would be
much preferred if we had a much simpler design.

In terms of the shape region support on Wayland, it's not widely
supported across all wayland compositors, to my knowledge, only two
support it, some compositors even want to disable XSHAPE extension at all.

This change makes the Xwayland windows ignore the shape region to see if
any real world applications are affected by it. If not, then we could
safely simplify the scene bits later.

The Xorg session is unaffected by this change.
2024-08-21 07:10:42 +00:00
Vlad Zahorodnii
f1eb095a0c opengl: Drop GLTexture::clear()
It's used only by the decoration renderer, but even it doesn't need it
because the atlas parts are padded.

From the API point of view, it's worth looking for alternative solutions,
like integrating the render target clear step in the render passes. And
texture uploading code usually doesn't need to clear the texture because
it is going to overwrite its contents anyway.
2024-08-20 22:38:13 +00:00
Xaver Hugl
874189f11b scene/workspacescene: also check for occlusion of the parent item
Somehow this was dropped in a rebase of def0bde5e9
2024-08-20 21:52:55 +00:00
Xaver Hugl
b8b900891b scene/workspacescene: don't iterate through all child items twice
Instead, use an iterator for the second loop to pick up where the first loop stopped
2024-08-20 14:52:40 +00:00
Vlad Zahorodnii
49b2b0d001 scene: Drop ItemRendererOpenGL::RenderNode::coordinateType
All render nodes have unnormalized texture coordinates now, so this
field is not needed anymore.
2024-08-20 13:26:37 +00:00
Vlad Zahorodnii
d12112b7a5 scene: Make ImageItem provide device texture coordinates
The main motivation behind this change is to make the ItemRendererOpenGL
use a homogeneous coordinate space for texture coordinates in order to
simplify rendering code.

The device pixels have been chosen because they are more agnostic about
the graphics api.
2024-08-20 13:26:37 +00:00
Vlad Zahorodnii
f002e20354 scene: Make SurfaceItem provide device texture coordinates
The main motivation behind this change is to make the ItemRendererOpenGL
use a homogeneous coordinate space for texture coordinates in order to
simplify rendering code.

The device pixels have been chosen because they are more agnostic about
the graphics api.
2024-08-20 13:26:37 +00:00
Xaver Hugl
def0bde5e9 scene/workspacescene: do occlusion testing for direct scanout
Some clients have two or more completely opaque surfaces stacked on top of each other,
optimizing the lower ones out makes direct scanout happen more often and more efficiently
when multiple planes are involved
2024-08-20 13:05:02 +02:00
Xaver Hugl
4ebb8530e6 scene/workspacescene: remove unused function 2024-08-20 11:04:44 +00:00
Vlad Zahorodnii
e504f1a711 scene: Port away from GLTexture::update(QImage, QPoint, QRect) overload 2024-08-16 19:03:48 +03:00
Xaver Hugl
4759ec6089 wayland: implement the alpha-modifier protocol
The alpha modifier protocol allows clients to set a multiplier for the opacity
of a surface, which allows them to offload some operations to KWin, which
in turn may offload them to KMS in the future
2024-08-14 14:26:33 +02:00
Vlad Zahorodnii
94b2c5e50e scene: Fix SurfaceItemWayland::freeze()
When a wl_surface is unmapped, we need to stop updating the buffer
in SurfacePixmapWayland.

However, SurfaceItemWayland::freeze() doesn't unset m_surface, so
the SurfacePixmapWayland keeps updating the buffer even after the
surface is unmapped. This results in some closed windows losing their
contents when playing a window closing animation.
2024-08-14 12:36:06 +03:00
Xaver Hugl
18f1092728 scene/item: add ItemEffect
Right now it's just a helper to mark items as being affected by some effect,
to prevent direct scanout of the relevant item without needing to block direct
scanout for the whole screen
2024-08-12 12:13:31 +00:00
Xaver Hugl
833476a111 core/colorspace: add rendering intents
Rendering intents describe how to handle mapping between different colorspaces,
what to do with out of gamut values and what to do if the whitepoint doesn't match.
This way, clients can choose which behavior their content should get.
2024-08-12 11:46:32 +00:00
Xaver Hugl
70ceed51fc scene/workspacescene: extend direct scanout candidate search to include multiple subsurfaces
This way, for example subsurfaces for black bars behind videos can be scanned out
2024-08-02 15:56:47 +02:00
Xaver Hugl
d12a93f9fb scene/itemrenderer_opengl: reset OpenGL state for YUV conversion back to RGB
Otherwise, effects or other OpenGL code that doesn't explicitly set those will get
wrong results
2024-07-26 10:59:31 +00:00
Xaver Hugl
bdc24ff8c7 core/colorspace: add mastering display colorimetry
The mastering display colorimetry describes what part of the colorspace
is actually used, which is important when we're sending desired metadata
about a screen using the rec.2020 container colorspace, or when the client
uses an "infinite" / extended colorspace like scRGB
2024-06-26 15:41:38 +02:00
Vlad Zahorodnii
c958a75e2b scene: Drop ItemRendererOpenGL::RenderNode::scale
It's unused.
2024-06-25 06:56:56 +00:00
David Redondo
cefcdf7db5 Unset suspended state of windows that are marked for offscreen rendering
Otherwise some clients will not render anything even though we are
sending frame callbacks.
BUG:487702
FIXED-IN:6.1
2024-05-29 12:02:01 +00:00
Xaver Hugl
77cf49aa72 backends: refactor direct scanout and dmabuf feedback
This moves some of the responsbilities up in the stack, which simplifies
the backends and opens up some future possibilities like making direct scanout
work for non-surface items
2024-04-27 18:39:23 +00:00
Xaver Hugl
fba948b39f scene/workspacescene: don't check direct scanout candidates for a pixmap
We don't need a pixmap for direct scanout, and the drm backend destroys the pixmap
when direct scanout is successful... so this check created a loop of direct scanout
working and not working, and worse, the client reallocating its buffers each time.

BUG: 485639
BUG: 485730
BUG: 485712
CCBUG: 477016
2024-04-19 23:06:56 +02:00
Xaver Hugl
4c6000b3e1 core/syncobjtimeline: make explicit sync use SYNC_IOC_MERGE instead of waiting on the CPU side
This brings some performance benefits, because the application can potentially reuse
the buffer earlier, and it simplifies the code a bit
2024-04-10 19:06:01 +02:00
Xaver Hugl
32addf4d59 wayland: implement linux-drm-syncobj-v1
linux-drm-syncobj-v1 allows drivers and apps to synchronize KWin's buffer access
to their rendering, and synchronize their rendering to KWin's buffer release. This
fixes severe glitches with the proprietary NVidia driver and allows for some
performance improvements with Mesa too.
2024-04-10 19:06:00 +02:00
Xaver Hugl
9c2035ca63 scene/workspacescene: fix direct scanout checks with subsurfaces
The check ignored that subsurfaces could be not visible, not mapped, and also below
the parent surface
2024-04-04 15:07:22 +00:00
Vlad Zahorodnii
883acb1f58 scene: Update surface texture in preprocess()
If two items display image data, the item renderer needs to special case
each item. It's not an extensible design, and my long term goal is to
introduce a separate tree specifically to solve this problem and also
help with computing the repaint damage automatically, instead of issuing
scheduleRepaint()s manually.

The first step is to refactor the item renderer so it merely takes the
input data and renders it. At the moment, it's not exactly the case
because surface textures are updated while painting the items, which
inherently requires special casing. This change moves surface texture
update code to the surface item so it's easier to refactor rendering code
in the item renderer.
2024-04-03 11:45:28 +00:00
Marco Martin
609833e880 Properly intersect the shape with clipRect
That for loop in the end didn't have any effect,
actually compute the final region and return that one
2024-03-11 11:56:21 +00:00
Vlad Zahorodnii
277701e99f scene: Inherit scene from the parent item
It makes Item API more ergonomic.
2024-03-09 11:18:21 +00:00
Xaver Hugl
b19426879f opengl/openglcontext: fix capitalization of isOpenGLES 2024-03-08 17:26:54 +00:00
Xaver Hugl
7618be3697 opengl/glplatform: remove dependency on OpenGlContext 2024-03-08 17:26:54 +00:00
Xaver Hugl
c5cd8d1318 port most uses of GLPlatform::isGLES to use OpenGlContext directly 2024-03-08 17:26:54 +00:00
Xaver Hugl
f98477e05b opengl/glframebuffer: move static variables to OpenGlContext 2024-03-08 17:26:54 +00:00
Aleix Pol Gonzalez
bf1ce85474 Make it possible to build KWin without libxcb
Now that we have Wayland around, there's a whole branch of dependencies
that shouldn't be necessary anymore.
This allows to build KWin without all of it, allowing us to have a much
more compact alignment for cases where all the legacy software isn't
necessary anymore.

Bundle KWindowSystem X11-specific headers into it too, since it's part
of the same process.

Signed-off-by: Victoria Fischer <victoria.fischer@mbition.io>
2024-02-28 16:03:50 +00:00
Vlad Zahorodnii
bcba59a7f5 scene: Use hardware clipping when painting overlay items
It's needed to properly render transformed overlay items. Ideally, the
ItemRenderer would split items that can be rendered with and without the
scissor test on its own. But we are not there yet, so pass the
PAINT_SCREEN_TRANSFORMED flag to force the ItemRendererOpenGL to use
hardware clipping.
2024-02-27 20:14:05 +00:00
Vlad Zahorodnii
916710ea01 scene: Export CursorItem 2024-02-27 20:14:05 +00:00
Vlad Zahorodnii
207bc1d9e6 scene: Introduce WorkspaceScene::overlayItem
The overlay item is the parent for all overlay contents above windows.
2024-02-27 20:14:05 +00:00
Vlad Zahorodnii
c153fc719a scene: Make top left corner of CursorItem match the hotspot
It's more convenient if one wants to paint cursor at the specified
location. For example, when drawing the cursor on your own.
2024-02-27 20:14:05 +00:00
Vlad Zahorodnii
f6b605daf2 scene: Add support for item transformations 2024-02-27 20:14:05 +00:00
Vlad Zahorodnii
693cd16b12 effect: Drop WindowPaintData::projectionMatrix() 2024-02-27 17:47:39 +00:00
David Edmundson
c6a3d76b92 decorations: Avoid opaque areas of decorations being larger than the rendered contents
Opaque is a QRegion in logical pixels, using .toRect will round to the
nearest integer in either direction. This can mean an area is considered
opaque outside the rendered area, leading to glitchy contents on
shadows.

This is most noticable on on X11 windows when fractional scaling is
used.

Long term I hope to move Item::opaque to QList<QRectF> and
WindowPrePaintData::opaque to device pixels.
2024-02-15 11:10:19 +00:00
Vlad Zahorodnii
857766eb74 scene: Fix DecorationItem reacting to new geometry
Window::layoutDecorationRects() uses KDecoration2::Decoration::rect() to
get the bounding decoration rect.

While Decoration::rect() should normally match Window::rect(), they can
diverge for a brief moment during async geometry updates. The worst
possible case is that the cached item quads may not be invalidated when
the geometry updates saddle.

To fix that, make DecorationItem monitor decorated client size changes
instead of window frame geometry changes. The reason for that is that
Decoration::size() is effectively decorated client size with added border
margins.
2024-02-12 13:16:58 +00:00
Xaver Hugl
31ebdb73a0 scene/surfaceitem: change refresh rate estimation to frame time estimation
This is both more direct and avoids divisions by durations that can potentially
be zero

BUG: 480971
2024-02-08 19:36:15 +01:00
Xaver Hugl
41aeecbb2a scene/surfaceitem: prevent division by zero
If the steady_clock's resolution is very limited, now - m_lastDamage might be zero,
so enforce a minimum time of 10us (or 100'000 fps)
2024-02-05 16:32:04 +00:00
Vlad Zahorodnii
66a491bda6 wayland: Remove extra space around the wrapper window in X11 windows
This way no extra buffer space is going to be wasted for a decoration
that isn't there, and it might be nicer for fractional scaling as kwin
won't need to deal with border size voodoo cases.
2024-02-05 08:30:40 +00:00
Xaver Hugl
896a57d3be opengl/glshader: make uniform enums type safe 2024-01-31 13:24:48 +01:00
Vlad Zahorodnii
e23cb52a16 wayland: Add windows when readyForPainting changes
A window is added to the workspace when it's mapped. It's assumed that
the first Window::windowShown signal indicates that. But it's not
entirely true. For example, if setHidden(false); setHidden(true); are
called in succession, the window will be marked as ready for painting
even though it isn't.

The Window::readyForPaintingChanged() signal fixes that. It's emitted
when the window is actually mapped.
2024-01-29 12:35:10 +02:00
Akseli Lahtinen
91974b7794 Set correct opaqueRegion for Xwayland apps 2024-01-29 09:34:57 +00:00