plugins/zoom: Skip processing low-contrast pixels
After the update to Plasma 6.7 (I believe?), the setting for text sharpening was enabled by default. Since I sometimes use the zoom function, this hurt the performance of my laptop suddenly very badly. And it got worse when an external monitor is plugged-in.
I didn't know if the calculations could be improved, but I know that the amount of pixels processed by this shader could be decreased.
So this skips all low-contrast pixels from doing all the calculations, like flat or solid areas.
The second change was skipping the blending maths for quadrants that the fragment can't be inside. The respective scaledFillRatio would return 0.0 anyway for those corners, so we can save the whole calculation, color-distance-checks, etc.
Some evidence:
(If a pixel was processed by the blending it was turned green. The more blending was calculated, the redder it becomes.)
| Pre-Patch | After early exit | ||
|---|---|---|---|
| Konsole | ![]() |
![]() |
![]() |
| Dragon Player with Big Buck Bunny at 00:00:16 | ![]() |
![]() |
![]() |
Performance (Shader time)
| Samples | Mean (ms) | Std Dev (ms) | Median (ms) | Min (ms) | Max (ms) | |
|---|---|---|---|---|---|---|
|
Idle Desktop (many equal colors, like on flat surfaces) |
||||||
| Pre-Patch | 338 | 6.077 | 0.817 | 6.279 | 4.551 | 8.251 |
| After early-exit | 339 | 4.805 | 1.139 | 4.887 | 2.974 | 7.544 |
|
|
|
|
|
|
|
|
|
Video Playback (few equal colors, but many similar colors, like gradients) |
||||||
| Pre-Patch | 344 | 13.069 | 4.793 | 13.572 | 4.563 | 19.411 |
| After early-exit | 358 | 5.092 | 1.341 | 5.480 | 2.971 | 7.048 |
|
|
|
|
|
|
|
|
Tested on my laptop (AMD Ryzen 5 7535HS, Radeon 660M) with 1080p output.
This results in a 20% improvement on shader time on an idle desktop and about a 60% improvement on shader time under heavy load. Also, it doesn't max out my Texture addresser and Graphics Pipeline anymore. And it doesn't sacrifice the output quality:
| Pre-Patch | Post-Patch |
|---|---|
![]() |
![]() |







