Color Matrix filter: 'adjust constant component RGB values' (last column) has no effect when applied to source alpha

Migrated from: https://bugs.launchpad.net/inkscape/+bug/897236

Steps to reproduce:

What happened?

The two rectangles look different:

  • top: gradient from black to transparent
  • bottom: gradient from red to transparent

What should have happened?

The two gradients are identical.

The top rectangle has a gradient of gray to transparent (#808080FF -> #80808000) with a color matrix filter of

1 0 0 0 1
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0

applied to source alpha. Source alpha is #000000FF->#00000000, so the gradient should become #FF0000FF->#FF000000 (a constant value of 1 is added to the red channel). Instead, the gradient is #000000FF->#00000000, so black to transparent.

The values of the last column are always ignored when in=Source Alpha.

Inkscape Version and Operating System:

  • Inkscape Version: 1.1-dev (12e2a09, 2020-02-19)
  • Operating System: Windows 10
  • Operating System version: 10.0.18362

Migration info:

  • Not reproduced with Inkscape 0.48.2 and 0.48+devel r10325 (before the merge of cairo-rendering) on Mac OS X 10.5.8 (i386)
  • Reproduced with 0.48+devel r10330 and later revisions (up to current r10752).
  • Reproduced on Windows XP, Inkscape trunk revision 11652.

Also affects filters applied to background alpha.

Something wrong with ink_cairo_extract_alpha(), in src/display/cairo-utils.cpp?