Skip to content

[filter-effects] Poor interop of <feComposite operator="arithmetic"> with large k values #1046

@smfr

Description

@smfr

Mozilla's ref test analyzer uses SVG filters to highlight differences between two images. One filter primitive is:

<feComposite result="c" in="c1" in2="c2" operator="arithmetic" k2="255" k3="255"/>

The arithmetic operator has poor interop, possibly because of rounding issues. Test case:

        <filter id="filter" filterUnits="objectBoundingBox" x="0" y="0" width="100%" height="100%">
            <feFlood x="10" y="10" width="200" height="200" flood-color="rgb(128, 10, 0)" flood-opacity="0.5" result="first" />
            <feFlood x="100" y="100" width="200" height="200" flood-color="rgb(10, 128, 0)" flood-opacity="1" result="second" />
            <feComposite in="first" in2="second" operator="arithmetic" k2="255" k3="255" />
        </filter>

This gives different results in each major browser:

Image

Chrome's results even change based on the screen color profile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions