Lower CSS brightness/contrast/invert/opacity filters to ColorMatrix - #104
Merged
Merged
Conversation
|
I'll fix CI failures and address comments from users with write access that start with 'Devin'.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FilterEffect::{opacity, invert, brightness, contrast}now buildFilterEffect::ColorMatrix(via newColorMatrix::{opacity, invert, brightness, contrast}constructors) instead ofFilterEffect::ComponentTransfer.hue_rotate/saturate/sepia/grayscalealready work this way, so now every non-spatial CSS filter function lowers to the same primitive kind.Why:
ComponentTransferinto 8-bit lookup tables.ColorMatrixprimitive (sparse_strips: AddColorMatrixfilter linebender/vello#1765) but have noComponentTransfer, so this unblocks CSS filters on the vello backends.Matrices (row-major 4x5, straight-alpha input
[r, g, b, a, 1]):brightness(a)a, offset0contrast(a)a, offset0.5 - 0.5ainvert(a)1 - 2a, offsetaopacity(a)[0,0,0,a,0]ComponentTransferFilter::{opacity, invert, brightness, contrast}and theComponentTransfervariant are left alone because SVGfeComponentTransferstill needs them. Backends are unchanged.Tests: I added unit tests that apply each matrix to sample RGBA colors and compare the output with the spec formulas. They also check that the identity values (
brightness(1),contrast(1),invert(0),opacity(1)) produce exactlyColorMatrix::IDENTITY.Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/d07362412f074435869c2e434653070f
Open in Devin Desktop: https://dioxus.staging.devinenterprise.com/desktop/session/d07362412f074435869c2e434653070f?variant=devin-insiders
Requested by: @nicoburns