rendernode: Fix Cairo rendering of repeating gradients
authorBenjamin Otte <otte@redhat.com>
Thu, 7 Sep 2023 14:02:09 +0000 (16:02 +0200)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 19 Sep 2023 19:23:24 +0000 (15:23 -0400)
commit552a7dc3080acdf1ad3b6eed96f2af984bd9715f
treed55aa0956aa2ed5322c3b6a208cf9572c06eef09
parent6ffbaa6bb0f28cdced408a8b6cd3ea81cf73771c
rendernode: Fix Cairo rendering of repeating gradients

Cairo and the GL renderer have a different idea of how to handle
transitioning of colors outside the defined range.

Consider these stops:
  black 50%, white 50%

What color is at 0%?

Cairo would transition between the last and first stop, ie it'd do a
white-to-black transition and end up at rgb(0.5,0.5,0.5) at 0%.
GL would behave as it would for non-repeating gradients and use black
for the range [0%..50%] and white for [50%..100%].
The web would rescale the range so the first stop would be at 0% and
the last stop would be at 100%, so this gradient would be illegal.

Considering that it's possible for code to transition between the
different behaviors by adding explicit stops at 0%/100%, I could choose
any method.
So I chose the simplest one, which is what the GL renderer does and
which treats repeating and non-repeating gradients the same.

Tests attached.
gsk/gskrendernodeimpl.c
testsuite/gsk/compare/repeating-linear-gradient-edge-colors.node [new file with mode: 0644]
testsuite/gsk/compare/repeating-linear-gradient-edge-colors.png [new file with mode: 0644]
testsuite/gsk/compare/repeating-radial-gradient-edge-colors.node [new file with mode: 0644]
testsuite/gsk/compare/repeating-radial-gradient-edge-colors.png [new file with mode: 0644]
testsuite/gsk/meson.build