[Image Wallpaper] Avoid cross-fading which reveals black background behind images
ClosedPublic

Authored by broulik on Aug 18 2016, 3:06 PM.

Details

Summary

When simultaneously fading two items (one from fully opaque to transparent and the other one vice-versa) you can briefly see the black background through the images leading to an ugly flicker.

By only doing this when the old image could be seen (when the new one has a smaller size) we avoid this in the common case of full-size wallpapers.

Test Plan

Added a large and tiny wallpaper, randomly switched between them, also played around with various scale modes. It no longer flickers everytime the wallpaper is changed.

This obviously breaks (as in you can see the old image which then suddenly disapperas once the animation finishes) images with alpha channel but I don't think we actively support/encourge that? It's just a corner-case anyway imho.

I noticed that because kscreenlocker greeter sets the image size after the wallpaper has loaded causing it to reload (source size changed) and this flickered when the lock screen showed up. This issue needs to be addressed separately but this patch still gives us a more polished look, especially when using a slideshow wallpaper.

Diff Detail

Repository
R120 Plasma Workspace
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
broulik updated this revision to Diff 6036.Aug 18 2016, 3:06 PM
broulik retitled this revision from to [Image Wallpaper] Avoid cross-fading which reveals black background behind images.
broulik updated this object.
broulik edited the test plan for this revision. (Show Details)
broulik added a reviewer: Plasma.
broulik set the repository for this revision to R120 Plasma Workspace.
Restricted Application added a project: Plasma. · View Herald TranscriptAug 18 2016, 3:06 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
mart added a subscriber: mart.Aug 18 2016, 3:23 PM

hmm, it shouldn't cause flicker, fading between 2 different sized wallpapers should be just fine

mart accepted this revision.Aug 18 2016, 4:07 PM
mart added a reviewer: mart.
This revision is now accepted and ready to land.Aug 18 2016, 4:07 PM

The correct way to fix this is to use a custom shader that does approximately this:

uniform sampler2D texture1;
uniform sampler2D texture2;
uniform float fadeProgress;
varying vec2 texcoord1;
varying vec2 texcoord2;

void main(void) {
    vec4 texel1 = texture2D(texture1, texcoord1);
    vec4 texel2 = texture2D(texture2, texcoord2);
    gl_FragColor = mix(texel1, texel2, fadeProgress);
}

As an added bonus you only render each pixel once, and you don't need blending to be enabled, so it's much faster. Especially on tiled renderers.

This revision was automatically updated to reflect the committed changes.