Bug 453229 - New setBlurRegion() API gives blocky/aliased blur region corners on Wayland HiDPI
Summary: New setBlurRegion() API gives blocky/aliased blur region corners on Wayland H...
Status: REOPENED
Alias: None
Product: kwin
Classification: Plasma
Component: decorations (other bugs)
Version First Reported In: git master
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-30 13:01 UTC by Paul McAuley
Modified: 2026-02-07 08:39 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Screenshot of ClassiK window decoration with 20% opacity titlebars/borders and blur on, corner radius=4, shadows disabled to emphasise bug. The corners exhibit very blocky aliasing. (2.55 MB, image/png)
2022-04-30 13:01 UTC, Paul McAuley
Details
X11 by contrast. Screenshot of ClassiK window decoration with 20% opacity titlebars/borders and blur on, corner radius=4, shadows disabled to emphasise bug. The corners are very smooth. (2.62 MB, image/png)
2022-04-30 13:04 UTC, Paul McAuley
Details
floating panel (1.28 KB, image/jpeg)
2022-06-18 18:52 UTC, Mohammad
Details
setBorderRadius applied to all corners when borders are present - Plasma 6.5.4 (678.53 KB, image/png)
2026-02-07 08:38 UTC, Paul McAuley
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paul McAuley 2022-04-30 13:01:25 UTC
Created attachment 148474 [details]
Screenshot of ClassiK window decoration with 20% opacity titlebars/borders and blur on, corner radius=4, shadows disabled to emphasise bug. The corners exhibit very blocky aliasing.

Hello, I have made a first attempt at implementing the new setBlurRegion() API (due to land in Plasma 5.25) in my C++ Window Decoration. This can be found on the branch at: https://github.com/paulmcauley/classik/tree/kornerbug-fix-plasma5.25

I construct my window shape using a QPainterPath (called m_windowPath) and then call setBlurRegion as follows:
setBlurRegion( QRegion( m_windowPath->toFillPolygon().toPolygon() ) ) ;

The results on X11 are excellent and produces very smooth corners when transparency and blur are enabled. However, on Wayland, the corners of the blur region are very blocky/aliased in appearance.


Operating System: openSUSE Tumbleweed 20220421
KDE Plasma Version: 5.24.80
KDE Frameworks Version: 5.94.0
Qt Version: 5.15.2
Kernel Version: 5.17.3-1-default (64-bit)
Graphics Platform: X11
Processors: 8 × Intel® Core™ i7-7700HQ CPU @ 2.80GHz
Memory: 31.2 GiB of RAM
Graphics Processor: Mesa Intel® HD Graphics 630
Manufacturer: Dell Inc.
Product Name: XPS 15 9560
Comment 1 Paul McAuley 2022-04-30 13:04:36 UTC
Created attachment 148475 [details]
X11 by contrast. Screenshot of ClassiK window decoration with 20% opacity titlebars/borders and blur on, corner radius=4, shadows disabled to emphasise bug. The corners are very smooth.

By contrast here is a similar screenshot on X11. It results in very smooth corners to the blur region.
Comment 2 Paul McAuley 2022-06-16 16:42:09 UTC
I should also mention that the above 2 screenshots are at 250% scaling.

I was looking into this more, and guessing this is probably because in Wayland scaled rendering is done relative to a smaller 100% scaled grid (e.g. at 250% scaling with a 2840x2160 display, rendering is done relative to 1536x864), so on Wayland you probably need to use floating point values for more precise shapes on screens with scaling > 100%.

You can, however, only construct a QRegion using integers (QRect and QPolygon; not QRectF and QPolygonF).

In my own window decoration ( https://github.com/paulmcauley/classik/commit/fe48c052f529e889706214c9af3db200fbfdb2a8#diff-1c44374ff8b2c6b8bea9596fe31ea4878a23bea2f62d2ce01dcbdf119dc98474R1319 ) I convert from a QPainterPath (in the shape of the window) to a  QPolygonF to a QPolygon and finally to a QRegion.

If my assumption about the cause of this problem is correct,  I would then propose extending the setBlurRegion() API in the decoration to accept a QPainterPath or a QPolygonF. A QPolygonF can then be easily converted to a QPolygon (just converts qreal to int) and then to a QRegion at the last minute after scaling and directly before the effect is applied to the actual pixels on screen.
Comment 3 Mohammad 2022-06-18 18:52:47 UTC
Created attachment 149902 [details]
floating panel

The problem still exists in the floating panel.
Comment 4 Paul McAuley 2022-06-19 01:19:38 UTC
(In reply to Mohammad from comment #3)
> Created attachment 149902 [details]
> floating panel
> 
> The problem still exists in the floating panel.

The setBlurRegion() function is only for window decorations, so this bug wouldn't cover that.

That said, the KWindowEffects::enableBlurBehind function used for blurring regions in applications only accepts QRegions as well, so I suspect if they were ever used properly, that under Wayland you would not have smooth corners on HiDPI Wayland with KWindowEffects::enableBlurBehind either.
Comment 5 Zamundaaa 2026-02-06 12:12:34 UTC
Blur regions are now clipped more nicely with the new rounded corners code, so this should no longer be an issue.
Comment 6 Paul McAuley 2026-02-06 13:15:54 UTC
(In reply to Zamundaaa from comment #5)
> Blur regions are now clipped more nicely with the new rounded corners code,
> so this should no longer be an issue.

Thanks. On which Plasma version is the new rounded corners code?
Comment 7 Zamundaaa 2026-02-06 17:40:22 UTC
It's supported since 6.5. Note that decorations have to opt into it, it's not a fully automatic thing.
Comment 8 Paul McAuley 2026-02-07 08:38:44 UTC
Created attachment 189320 [details]
setBorderRadius applied to all corners when borders are present - Plasma 6.5.4

(In reply to Zamundaaa from comment #7)
> It's supported since 6.5. Note that decorations have to opt into it, it's
> not a fully automatic thing.

I assume you are referring to the KDecoration3 setBorderRadius() function? On Plasma 6.5.4, if you apply setBorderRadius() to all corners, then the borders are not considered (including the titlebar). It only is useful on Plasma 6.5 to round the bottom corners when there are no borders, or round all  borders when you also hide the titlebar. See the attachment for how this looks with window decoration code from https://github.com/paulmcauley/klassy/tree/setBorderRadius-with-borders.

Unless of course, this has been fixed with Plasma 6.6? (I have not yet tried)