Implement image-rendering: pixelated
Categories
(Core :: CSS Parsing and Computation, enhancement, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox93 | --- | fixed |
People
(Reporter: fryn, Assigned: emilio)
References
(Blocks 3 open bugs, )
Details
(Keywords: dev-doc-needed, Whiteboard: [waiting to land until bug 1072703 is ready][layout:backlog])
Attachments
(4 files, 2 obsolete files)
(deleted),
patch
|
seth
:
review+
|
Details | Diff | Splinter Review |
(deleted),
patch
|
Details | Diff | Splinter Review | |
(deleted),
text/x-phabricator-request
|
Details | |
Bug 856337 - Implement image-rendering: smooth and image-rendering: pixelated. r=jrmuizel!,dholbert!
(deleted),
text/x-phabricator-request
|
Details |
Comment 1•12 years ago
|
||
Comment 2•11 years ago
|
||
Comment 3•11 years ago
|
||
Comment 4•11 years ago
|
||
Comment 5•11 years ago
|
||
Comment 6•11 years ago
|
||
Comment 7•11 years ago
|
||
Comment 8•11 years ago
|
||
Updated•11 years ago
|
Comment 10•10 years ago
|
||
Comment 11•10 years ago
|
||
Comment 12•10 years ago
|
||
Comment 13•10 years ago
|
||
Comment 14•10 years ago
|
||
Updated•10 years ago
|
Comment 15•10 years ago
|
||
Comment 16•10 years ago
|
||
Updated•10 years ago
|
Comment 17•10 years ago
|
||
Comment 18•10 years ago
|
||
Comment 19•10 years ago
|
||
Comment 20•10 years ago
|
||
Comment 21•10 years ago
|
||
Comment 22•10 years ago
|
||
Comment 23•10 years ago
|
||
Comment 24•10 years ago
|
||
Comment 25•10 years ago
|
||
Comment 26•10 years ago
|
||
Comment 27•10 years ago
|
||
Comment 28•10 years ago
|
||
Comment 29•10 years ago
|
||
Updated•10 years ago
|
Comment 30•9 years ago
|
||
Comment 31•9 years ago
|
||
Comment 32•9 years ago
|
||
Comment 33•9 years ago
|
||
Comment 34•8 years ago
|
||
Comment 35•8 years ago
|
||
Updated•8 years ago
|
Comment 37•6 years ago
|
||
An chance this will get some attention? I don't know what the spec used to say but it seems fairly unambiguous now
pixelated: The image must be scaled with the "nearest neighbor" ..., to preserve a "pixelated" look as the image changes in size.
Every dev and question I've seen on this topic wants simple "nearest neighbor" to be what all browsers do when "pixelated" is selected.
The spec also makes it 100% clear that choosing "crisp-edges" is not asking for the same thing as "pixelated" and that at anytime on any browser "crisp-edges" could do something other than "nearest neighbor" and not give the results the dev wants.
Comment 38•6 years ago
|
||
(In reply to Gregg Tavares from comment #37)
choosing "crisp-edges" is not asking for the same thing as "pixelated" and that at anytime on any browser "crisp-edges" could do something other than "nearest neighbor" and not give the results the dev wants.
Indeed, straightforward Nearest Neighbour would be great.
According to the example image in the spec, crisp-edges
may mean pretty much anything including totally non-pixelated things, depending on the browser. I have no idea why we need such broad nonspecific things in the spec in the first place.
My SmartUpscale extension for preventing distortion of integer-ratio-scaled images currently uses -moz-crisp-edges
, but it actually needs Nearest Neighbour with a 100% predictable result. Too bad that even pixelated
is described in the spec not as “nearest neighbor”, but as “"nearest neighbor" or similar algorithm”, so surprises are still possible.
Comment 39•6 years ago
|
||
Since the spec allows a "similar" algorithm, I still think Pixel Mixing is the better choice; you get the nearest-neighbor behavior you expect for integer up-scaling. For all other cases, the look is much more even and less aliased than nearest-neighbor.
Comment 40•6 years ago
|
||
Please, please PLEASE just use nearest neighbor.
Because of other issues with the spec you can't always know exactly how many pixels will be displayed.
You make a 640x480 canvas but it's displayed on a 1.33 dpi screen so actual size is 851x638 or it might be 852x639 depending on the browser. AFAICT the majority of devs that asked for a 640x480 image-rendering: pixelated; canvas don't want it to suddenly get antialiased and blurred out in that condition.
Devs picking pixelated want an aliased image. That's the entire point of pixelated
Comment 41•6 years ago
|
||
I'm a dev picking pixelated and I want pixel mixing. My use case is displaying sprite art optimized for 1x displays which I want to maintain its blocky appearance on 2x displays without looking awful on 1.5x and 2.5x displays. My current approach is to use image-rendering: auto and then have a chain of media queries to turn on crisp-edges at exactly 1x, 2x, 3x, etc. 1.5x displays get the very blurry bilinear scaling which is still better than the awful results of nearest neighbour but significantly worse than pixel mixing.
Favicons--especially 16x16 favicons being displayed on 1.5x and 2.5x displays--are also a very compelling case for pixel mixing.
Nearest neighbour scaling is awful at non-integer scales--especially between 1x and 2x. I can't understand how any web developer would prefer it to anything else. Please check the Image Worsener code for a CPU optimized implementation with some clever performance tweaks.
Please note that pixel mixing and nearest neighbour, by design, will always give the same results for integer scales. At non-integer scales, pixel mixing is a kind of 'perfectly supersampled' version of nearest neighbour.
Comment 42•6 years ago
|
||
If pixel mixing means this
http://entropymine.com/imageworsener/pixelmixing/
Then it is in no way compatible with the definition of "pixelated"
Comment 43•6 years ago
|
||
I would prefer uneven pixel rendering to occur at non-integer scaling than for it to be blurred/smoothed/filtered/blended.
Comment 44•6 years ago
|
||
https://colececil.io/blog/2017/scaling-pixel-art-without-destroying-it/ seems to have a shader implementation of pixel mixing, if I interpret it correctly.
Updated•5 years ago
|
Comment 45•5 years ago
|
||
Unassigning to reflect reality.
(Bug 1072703 is where the real remaining work is here. Note that the attached fix on this bug is no longer applicable, now that we've got the new servo/stylo css implementation.)
Comment 46•5 years ago
|
||
There is an ImageRendering::Pixelated
in Webrender, isn't it just a matter of plugging it to the Stylo pixelated property value?
Comment 47•5 years ago
|
||
Is there precedent for a CSS feature whose support in a given Firefox version depends on whether WebRender is enabled?
Assignee | ||
Comment 48•5 years ago
|
||
Maybe? There are other graphics back-ends other than webrender.
It seems the code in comment 0 changed quite a bit but WR uses ImageRendering::Pixelated
for SamplingFilter::POINT
, which is determined here: https://searchfox.org/mozilla-central/rev/42c2ecdc429115c32e6bcb78bf087a228a051044/layout/base/nsLayoutUtils.cpp#6486
So it seems, yeah, it should just hook into there.
Assignee | ||
Comment 49•5 years ago
|
||
(In reply to Simon Sapin (:SimonSapin) from comment #47)
Is there precedent for a CSS feature whose support in a given Firefox version depends on whether WebRender is enabled?
backdrop-filter
, but we don't ship that for exactly that reason.
Comment 50•4 years ago
|
||
It seems crazy to me that Firefox is the only browser not to support image-rendering: pixelated
. It's even more perplexing because it implements image-rendering: crisp-edges
in a way that is suitable for pixelated
!
So until we decide what the best behaviour is in the long term can we at least implement pixelated
as an alias to the current crisp-edges
implementation? It may not be perfect but it is way better to what auto
is today!
(For what it is worth I think it is best to keep pixelated == nearest neighbour
and if there is desire for fancier options they should be added as different keywords)
Comment 51•3 years ago
|
||
I second the proposal by Kevin Cox (comment #50). A slightly suboptimal implementation of pixelated
is better than no implementation, as it will allow showing pixel art without needing to rely on the current implementation of crisp-edges
being a suitable pixelated
replacement. Not only would adding pixelated
improve cross-browser compatibility, it would also free crisp-edges
to be used for a better algorithm.
Assignee | ||
Comment 52•3 years ago
|
||
It's easier to touch in the future that way, even though the derive list is
massive.
Updated•3 years ago
|
Assignee | ||
Comment 53•3 years ago
|
||
Also, more directly go from StyleImageRendering to wr::ImageRendering.
-
image-rendering: smooth the non-deprecated version of
OptimizeQuality, which maps to SamplingFilter::LINEAR /
wr::ImageRendering::Auto (which uses gl::LINEAR). -
image-rendering: pixelated maps to wr::ImageRendering::Pixelated /
SamplingFilter::POINT which is the same crisp-edges does.
Note that this uncovers that we were mapping image-rendering:
crisp-edges to wr::ImageRendering::Pixelated.
I'm going to preserve behavior on this patch but we should consider
switching that to map to wr::ImageRendering::CrispEdges on a
follow-up (filed bug 1728831 for this).
Depends on D124377
Comment 54•3 years ago
|
||
Comment 55•3 years ago
|
||
Backed out 2 changesets (Bug 856337) for causing xpcshell failures in test_css-properties-db.js CLOSED TREE
Log: https://treeherder.mozilla.org/logviewer?job_id=350392043&repo=autoland&lineNumber=1818
Backout: https://hg.mozilla.org/integration/autoland/rev/0f075e3623194f41326ea04ec5867475392366a2
Assignee | ||
Updated•3 years ago
|
Comment 56•3 years ago
|
||
Comment 57•3 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/7dd1d9e0bc8c
https://hg.mozilla.org/mozilla-central/rev/5099d603c2cb
Description
•