background-actor: Render gradient MetaBackground correctly
If you create a MetaBackground
with meta_background_set_gradient
and
then pass it to MetaBackgroundActor
it would be rendered incorrectly
with the gradient only occupying the middle half the actor. The remaining
two quarters would be a solid colour. This is not what anybody wants
from a gradient background.
The problem is that MetaBackground
creates gradients using either a
1x2 or 2x1 texture, and then expects MetaBackgroundActor
to stretch
it out smoothly. However using the typical texture coordinates of (0,0)
and (1,1) would result in the two gradient colours being centred at
25% and 75% respectively; not the top and bottom of the screen. The
remaining two quarters of the screen would CLAMP_TO_EDGE
as solid
colours.
The solution is to handle the tiny gradient textures differently to normal wallpaper. For a vertical gradient (1x2 texels) for example, the texture coordinates to map the centre of each texel to the corners of the screen should be:
(0.5,0.25) -> (0.5,0.75)
and so the gradient now covers the full height of the screen evenly.