F2F/Auckland 2011/Luma-mask

From SVG
Jump to: navigation, search


SVG 1.1 seemingly contradicts the 'color-interpolation' property for 'mask' elements. More specifically, the bit of the spec this concerns:

   A linear luminance value is computed from the color channel values. This
   can be done, for example, by first converting the original image color
   values (potentially in the sRGB color space) to the linear RGB color space
   (see Rendering properties). Then, using non-premultiplied linear RGB color
   values, apply the luminance-to-alpha coefficients (as defined in the
   ‘feColorMatrix’ filter primitive)...

Why do masks need this kind of special treatment? If one wants a linearRGB colorspace why not just use color-interpolation="linearRGB" explicitly? The color-interpolation property has an initial value of 'sRGB', and it applies to container elements (including 'mask'). This looks like a contradiction in the spec.


For performance and spec consistency reasons the default behaviour should be changed so that it respects the 'color-interpolation' property, effectively making 'sRGB' the default colorspace for the luma calculation but still maintaining the linearRGB luma behaviour via "color-interpolation=linearRGB".


  • Converting the rendering (which most often is in the sRGB colorspace) to linearRGB to create the mask has a performance penalty
  • The difference is rather subtle (the result can look slightly darker if using transparent masks due to the linearRGB conversion)
  • Currently the conversion in 'mask' clashes with 'color-interpolation' such that you cannot get the sRGB behavior