Skip to content
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

[filter-effects-1] Add edgemode=reflect #527

Closed
flackr opened this issue Aug 28, 2023 · 5 comments
Closed

[filter-effects-1] Add edgemode=reflect #527

flackr opened this issue Aug 28, 2023 · 5 comments

Comments

@flackr
Copy link
Contributor

flackr commented Aug 28, 2023

A reflect edgemode in filter-effects-1 would be very useful as the behavior for the backdrop-filter blur behavior (See #374) as it avoids a discontinuity when moving the filter over new content.

The behavior of this mode would be that pixels outside mirror the pixels inside, e.g. it would be as follows:
Original N-by-M image, where m=M-1 and n=N-1:

 11  12 ...  1m  1M
 21  22 ...  2m  2M
... ... ... ... ...
 n1  n2 ...  nm  nM
 N1  N2 ...  Nm  NM

Extended by two pixels in each direction using reflect:

 22  21  21  22 ...  2m  2M  2M  2m
 12  11  11  12 ...  1m  1M  1M  1m
 12  11  11  12 ...  1m  1M  1M  1m
 22  21  21  22 ...  2m  2M  2M  2m
... ... ... ... ... ... ... ... ...
 n2  n1  n1  n2 ...  nm  nM  nM  nm
 N2  N1  N1  N2 ...  Nm  NM  NM  Nm
 N2  N1  N1  N2 ...  Nm  NM  NM  Nm
 n2  n1  n1  n2 ...  nm  nM  nM  nm

We can debate whether the border pixels should repeat in reflect mode, but doing so has the nice property that a 2N by 2M sampling is exactly one additional copy of the image worth of pixels.

@mstange
Copy link

mstange commented Aug 28, 2023

Thanks for filing! For some parts of the current Firefox implementation (specifically Canvas2D filters on Windows) it would be convenient if the reflection worked the same as in D2D1_BORDER_EDGE_MODE_MIRROR.

@tabatkins
Copy link
Member

I don't know anything about the impl concerns of this, but is there a particular reason we're reflecting solely on the right/bottom edges? Or was this just an artifact of a simplified example, and a "real" reflect would also have reflected pixels along the top/left edges?

@flackr
Copy link
Contributor Author

flackr commented Aug 28, 2023

It would of course be mirrored / reflected on all edges, I was just following the conventions at https://drafts.fxtf.org/filter-effects-1/#element-attrdef-feconvolvematrix-edgemode where they've only illustrated extending further down and to the right even though the existing edge modes also can extend up and to the left.

@flackr flackr added the Agenda+ label Oct 24, 2023
@flackr
Copy link
Contributor Author

flackr commented Oct 24, 2023

Thanks for filing! For some parts of the current Firefox implementation (specifically Canvas2D filters on Windows) it would be convenient if the reflection worked the same as in D2D1_BORDER_EDGE_MODE_MIRROR.

I'm not sure where it is defined, but looking at https://learn.microsoft.com/en-us/windows/win32/direct2d/border#mirror it does look like the mirroring is equivalent to the proposal here - repeating the border pixels - such that you can draw an image 2x the original size and have exactly one mirrored copy.

@css-meeting-bot
Copy link
Member

The CSS Working Group just discussed [filter-effects-1] Add edgemode=reflect, and agreed to the following:

  • RESOLVED: add mirror value to edgemode attribute
The full IRC log of that discussion <bramus> flackr: last week we agreed to use reflect mode as backdrop filter but in the filter effects spec devs can specifyt from one of several edge modes and this issue is if we should expose reflect edge-mode. I think its reasonable to add. do we call it reflect or mirror? details in the issue.
<bramus> astearns: generally in favor of exposing things we use under the covers, so makes sense to me
<ydaniv> +1 on exposing
<bramus> astearns: so PROPOSED RESOLUTION is add reflect or mirror value?
<bramus> emilio: so only expose in the attr of the element right?
<bramus> flackr: yeah
<bramus> emilio: there is no way to specify this in css right now
<bramus> emilio: not opposed to expose it where we already expose the same switch
<schenney> q+
<astearns> ack schenney
<bramus> flackr: might make sense to expose which edgemode to use in a backdrop filter, but could be future extension
<bramus> schenney: standards in graphics textures is to use “mirrored”
<bramus> flackr: i’m good with mirror, as its what i originally proposed
<bramus> chris: probably spec text should reflect what ??? we pick as the name
<bramus> astearns: as long as there is no case where there is a future extension that does both mirror and reflect but slightly different
<bramus> astearns: can always fix up spec text
<bramus> astearns: so we agree on mirror to add
<chris> s/should reflect what ??? we pick as the name/should mention both terms, regardless what we pick as the name
<bramus> emilio: in the edgemode attribute
<bramus> flackr: will point out attributes are not past tense, so should be mirror not mirrored
<bramus> PROPOSED RESOLUTION: add mirror value to edgemode attribute
<bramus> astearns: objections?
<bramus> RESOLVED: add mirror value to edgemode attribute

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

5 participants