Skip to content

[css-color-hdr] Add interpolation between multiple values of dynamic-range-limit #10271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ccameron-chromium opened this issue Apr 30, 2024 · 13 comments

Comments

@ccameron-chromium
Copy link
Contributor

This came up when writing WPT tests for dynamic-range-limit.

The dynamic-range-limit specification allows for interpolation between two dynamic-range-limit values by the dynamic-range-limit-mix function. It was pointed out that interpolation between multiple different values may happen implicitly during animation.

The syntax chosen in the spec lends itself to fixing this issue fairly simply. The current syntax is

  dynamic-range-limit-mix() = dynamic-range-limit-mix( [ <ident> && <percentage [0,100]>? ]#{2})

The suggestion that I was given was to change this to

  dynamic-range-limit-mix() = dynamic-range-limit-mix( [ <ident> && <percentage [0,100]> ]+)

Example: Halfway between standard and high.

  dynamic-range-limit-mix(standard 50%, high 50%)

This is the same as the existing syntax.

Example: One-fifth between constrained-high and dynamic-range-limit-mix(standard 40%, high 60%):

  dynamic-range-limit-mix(constrained-high 20%,  dynamic-range-limit-mix(standard 40%, high 60%) 80%)

this simplifies to

  dynamic-range-limit-mix(standard 32%, high 48%, constrained-high 20%)

Notes

In the syntax we didn't allow percentages to be omitted (cause it can get a bit difficult to define more than one unspecified value, unlike color-mix which has natural definitions).

If the sum of the arguments' percentages is 0%, then the function fails.

The arguments' percentages are normalized so that they add to 100%.

The percent for standard, high, and constrained-high is computed as the of the weighted sum of its percents in each argument.

I'll try to put together a patch that does this.

@tabatkins
Copy link
Member

Actually, I think it would be preferable to switch the dynamic-range-limit-mix() function's grammar to match that of the mix-*() family of functions (and ideally switch the name order as well, to mix-dynamic-range-limit()).

In other words:

mix-dynamic-range-limit( <progress>, <'dynamic-range-limit'>, <'dynamic-range-limit'> )

@tabatkins tabatkins added the css-color-hdr CSS HDR extension label Apr 30, 2024
@sboukortt
Copy link

Actually, I think it would be preferable to switch the dynamic-range-limit-mix() function's grammar to match that of the mix-*() family of functions (and ideally switch the name order as well, to mix-dynamic-range-limit()).

In other words:

mix-dynamic-range-limit( <progress>, <'dynamic-range-limit'>, <'dynamic-range-limit'> )

Thank you for the feedback. Out of curiosity, may I ask about the name change? calc-mix, color-mix, etc. seem to have the -mix at the end – would we change those as well?

@ccameron-chromium
Copy link
Contributor Author

I think the hard part is is defining what is the computed value for this sort of thing:

    mix-dynamic-range-limit(
        40%,
        mix-dynamic-range-limit(20%, standard, high),
        mix-dynamic-range-limit(30%, standard, constrained-high));

The math of this is: 0.6*(0.8*standard + 0.2*high) + 0.4*(0.7*standard + 0.3*constrained-high)). If we have a two-argument functional, then we need to somehow nest these together, and it starts to feel a bit messy.

The syntax that @svgeesus suggested extends well to handle this, by just allowing one to say that that evaluates to:

    mix-dynamic-range(standard 76%, high 12%, constrained-high 12%)

@gregbenz
Copy link

Is there a way this might be implemented to allow absolute HDR headroom limits which would affect the rendering, yet still keep the source site blind to the output in order to ensure anti-fingerprinting objectives are met?

For example, it may be ideal to allow up to 2 stops of headroom for HDR content alongside SDR. The other proposed mechanisms would either cause unnecessary limitations below that target, or may allow brighter results if the display has an unusually large amount of headroom (which could apply now with certain Windows SDR brightness slider settings, or with future brighter displays).

@svgeesus
Copy link
Contributor

Thank you for the feedback. Out of curiosity, may I ask about the name change? calc-mix, color-mix, etc. seem to have the -mix at the end – would we change those as well?

No, color-mix() is widely implemented and changing the name would be a pointless waste of time at this stage

it would be preferable to switch the dynamic-range-limit-mix() function's grammar to match that of the mix-*() family of functions (and ideally switch the name order as well, to mix-dynamic-range-limit()).

I note that, following the link, this is still called calc-mix() so I guess we do have consistency again.

@tabatkins
Copy link
Member

Yes, the current naming convention is indeed *-mix(). I guess I'd just misremembered when I made that comment.

@ccameron-chromium
Copy link
Contributor Author

ccameron-chromium commented Oct 18, 2024

Returning to the issue of interpolation between more than 2 enums, is there any objection to updating the functional to support the form:

    mix-dynamic-range(standard 76%, high 12%, constrained-high 12%)

This would mean the syntax would be updated to be:

    dynamic-range-limit-mix() = dynamic-range-limit-mix( [ <ident> && <percentage [0,100]> ]+)

The changes here are that the percentage is no longer optional, and there may be more than two parameters.

Some of the options for interpolating using color-mix (in particular the use of alpha in step 7) can't quite apply to this, so we'll want to list the normalization explicitly.

  • If all percentages are specified and sum to zero, then the function is invalid.
  • Scale all percentages so that they add to 100%

I'll put out a patch to update this.

@ccameron-chromium
Copy link
Contributor Author

Added PR for spec changes here: #11086
Added WPT tests for the behavior here: https://chromium-review.googlesource.com/c/chromium/src/+/5501416

@svgeesus
Copy link
Contributor

I merged the PR.

We should really get a WG resolution on this, before the spec goes to FPWD.

@svgeesus
Copy link
Contributor

svgeesus commented Oct 29, 2024

The change can now be seen in the spec:

2.5. Computed Value for dynamic-range-limit

so the proposed resolution is "Accept these edits" or alternatively, revert the PR.

The proposed WPT tests not yet merged

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Oct 29, 2024
Update the behavior of dynamic-range-limit to reflect the spec changes
in the issue w3c/csswg-drafts#10271 and the
PR w3c/csswg-drafts#11086.

Add assorted unit tests.

Add WPT tests for computed value, parsing, inheritance, and
interpolation.

Bug: 40277822
Change-Id: I0fcd81538546a7428080dc691ba91ccc7803f59d
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Oct 29, 2024
Update the behavior of dynamic-range-limit to reflect the spec changes
in the issue w3c/csswg-drafts#10271 and the
PR w3c/csswg-drafts#11086.

Add assorted unit tests.

Add WPT tests for computed value, parsing, inheritance, and
interpolation.

Bug: 40277822
Change-Id: I0fcd81538546a7428080dc691ba91ccc7803f59d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5501416
Commit-Queue: ccameron chromium <ccameron@chromium.org>
Reviewed-by: Kevin Babbitt <kbabbitt@microsoft.com>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1375223}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Oct 29, 2024
Update the behavior of dynamic-range-limit to reflect the spec changes
in the issue w3c/csswg-drafts#10271 and the
PR w3c/csswg-drafts#11086.

Add assorted unit tests.

Add WPT tests for computed value, parsing, inheritance, and
interpolation.

Bug: 40277822
Change-Id: I0fcd81538546a7428080dc691ba91ccc7803f59d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5501416
Commit-Queue: ccameron chromium <ccameron@chromium.org>
Reviewed-by: Kevin Babbitt <kbabbitt@microsoft.com>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1375223}
@svgeesus
Copy link
Contributor

The WPT tests are merged, results here

@css-meeting-bot
Copy link
Member

The CSS Working Group just discussed [css-color-hdr] Add interpolation between multiple values of dynamic-range-limit, and agreed to the following:

  • RESOLVED: Accept the PR
The full IRC log of that discussion <noamr> Chris: we have this dynamic range value. but you might have more than value, e.g. in animation, need to decide what happens
<noamr> ChrisL: we have a PR, we either should merge it or revert. I think it's a good syntax
<noamr> astearns: inclined to accept the PR
<noamr> ChrisL: I prefer to review things in place
<noamr> astearns: objections?
<TabAtkins> RESOLVED: Accept the PR

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Oct 30, 2024
…range-limit-mix, add WPT tests, a=testonly

Automatic update from web-platform-tests
CSS dynamic-range-limit: Update dynamic-range-limit-mix, add WPT tests

Update the behavior of dynamic-range-limit to reflect the spec changes
in the issue w3c/csswg-drafts#10271 and the
PR w3c/csswg-drafts#11086.

Add assorted unit tests.

Add WPT tests for computed value, parsing, inheritance, and
interpolation.

Bug: 40277822
Change-Id: I0fcd81538546a7428080dc691ba91ccc7803f59d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5501416
Commit-Queue: ccameron chromium <ccameron@chromium.org>
Reviewed-by: Kevin Babbitt <kbabbitt@microsoft.com>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1375223}

--

wpt-commits: 56e4ec631d6402082905a3f61ad2c6c507e25ff6
wpt-pr: 45982
@svgeesus
Copy link
Contributor

PR merged, WPT added to spec.

jamienicol pushed a commit to jamienicol/gecko that referenced this issue Oct 31, 2024
…range-limit-mix, add WPT tests, a=testonly

Automatic update from web-platform-tests
CSS dynamic-range-limit: Update dynamic-range-limit-mix, add WPT tests

Update the behavior of dynamic-range-limit to reflect the spec changes
in the issue w3c/csswg-drafts#10271 and the
PR w3c/csswg-drafts#11086.

Add assorted unit tests.

Add WPT tests for computed value, parsing, inheritance, and
interpolation.

Bug: 40277822
Change-Id: I0fcd81538546a7428080dc691ba91ccc7803f59d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5501416
Commit-Queue: ccameron chromium <ccameron@chromium.org>
Reviewed-by: Kevin Babbitt <kbabbitt@microsoft.com>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1375223}

--

wpt-commits: 56e4ec631d6402082905a3f61ad2c6c507e25ff6
wpt-pr: 45982
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Nov 1, 2024
…range-limit-mix, add WPT tests, a=testonly

Automatic update from web-platform-tests
CSS dynamic-range-limit: Update dynamic-range-limit-mix, add WPT tests

Update the behavior of dynamic-range-limit to reflect the spec changes
in the issue w3c/csswg-drafts#10271 and the
PR w3c/csswg-drafts#11086.

Add assorted unit tests.

Add WPT tests for computed value, parsing, inheritance, and
interpolation.

Bug: 40277822
Change-Id: I0fcd81538546a7428080dc691ba91ccc7803f59d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5501416
Commit-Queue: ccameron chromium <ccameronchromium.org>
Reviewed-by: Kevin Babbitt <kbabbittmicrosoft.com>
Reviewed-by: Rune Lillesveen <futharkchromium.org>
Cr-Commit-Position: refs/heads/main{#1375223}

--

wpt-commits: 56e4ec631d6402082905a3f61ad2c6c507e25ff6
wpt-pr: 45982

UltraBlame original commit: 5cafbcdaa670bbb57218487e1211031ef76a7acf
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Nov 1, 2024
…range-limit-mix, add WPT tests, a=testonly

Automatic update from web-platform-tests
CSS dynamic-range-limit: Update dynamic-range-limit-mix, add WPT tests

Update the behavior of dynamic-range-limit to reflect the spec changes
in the issue w3c/csswg-drafts#10271 and the
PR w3c/csswg-drafts#11086.

Add assorted unit tests.

Add WPT tests for computed value, parsing, inheritance, and
interpolation.

Bug: 40277822
Change-Id: I0fcd81538546a7428080dc691ba91ccc7803f59d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5501416
Commit-Queue: ccameron chromium <ccameronchromium.org>
Reviewed-by: Kevin Babbitt <kbabbittmicrosoft.com>
Reviewed-by: Rune Lillesveen <futharkchromium.org>
Cr-Commit-Position: refs/heads/main{#1375223}

--

wpt-commits: 56e4ec631d6402082905a3f61ad2c6c507e25ff6
wpt-pr: 45982

UltraBlame original commit: 5cafbcdaa670bbb57218487e1211031ef76a7acf
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Nov 1, 2024
…range-limit-mix, add WPT tests, a=testonly

Automatic update from web-platform-tests
CSS dynamic-range-limit: Update dynamic-range-limit-mix, add WPT tests

Update the behavior of dynamic-range-limit to reflect the spec changes
in the issue w3c/csswg-drafts#10271 and the
PR w3c/csswg-drafts#11086.

Add assorted unit tests.

Add WPT tests for computed value, parsing, inheritance, and
interpolation.

Bug: 40277822
Change-Id: I0fcd81538546a7428080dc691ba91ccc7803f59d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5501416
Commit-Queue: ccameron chromium <ccameronchromium.org>
Reviewed-by: Kevin Babbitt <kbabbittmicrosoft.com>
Reviewed-by: Rune Lillesveen <futharkchromium.org>
Cr-Commit-Position: refs/heads/main{#1375223}

--

wpt-commits: 56e4ec631d6402082905a3f61ad2c6c507e25ff6
wpt-pr: 45982

UltraBlame original commit: 5cafbcdaa670bbb57218487e1211031ef76a7acf
i3roly pushed a commit to i3roly/firefox-dynasty that referenced this issue Nov 1, 2024
…range-limit-mix, add WPT tests, a=testonly

Automatic update from web-platform-tests
CSS dynamic-range-limit: Update dynamic-range-limit-mix, add WPT tests

Update the behavior of dynamic-range-limit to reflect the spec changes
in the issue w3c/csswg-drafts#10271 and the
PR w3c/csswg-drafts#11086.

Add assorted unit tests.

Add WPT tests for computed value, parsing, inheritance, and
interpolation.

Bug: 40277822
Change-Id: I0fcd81538546a7428080dc691ba91ccc7803f59d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5501416
Commit-Queue: ccameron chromium <ccameron@chromium.org>
Reviewed-by: Kevin Babbitt <kbabbitt@microsoft.com>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1375223}

--

wpt-commits: 56e4ec631d6402082905a3f61ad2c6c507e25ff6
wpt-pr: 45982
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants