Closed Bug 2078306 Opened 1 month ago Closed 14 days ago

Add support for filling paths in WebRender

Categories

(Core :: Graphics: WebRender, task, P3)

task

Tracking

()

RESOLVED FIXED

People

(Reporter: nical, Assigned: nical)

References

Details

Attachments

(15 external files, 1 obsolete file)

The idea is to integrate the tiling algorithm I developed in https://codeberg.org/nical/misc/src/branch/main/path_renderer/renderers/tiling

At first it will only be used for CSS clip paths, we'll then extend it to support more common fills like SVG fills.

It contains only curve flattening implementations for cubic and quadratic bézier curves for now.

clip.rs is a pretty large file and polygon.rs is the only place where it is used. Also move the related tests that were in util.rs.

Port of the tiling path renderer from https://codeberg.org/nical/misc/src/branch/main/path_renderer/renderers/tiling without occlusion culling, opaque batches and the point buffer. Curves are flattened with the bezier module, and segments are clipped to the region that affects the target before binning so that huge coordinates cannot cause the binning to walk across millions of tiles.

This is not used yet.

Path tile edges are stored in a dedicated RGBA8 texture, one edge per texel, so that the fragment shader gets them unpacked by the texture unit. It is shared by all of the paths of the frame and is empty until path clips are rasterized.

Port of the tiling path renderer's shader, with area coverage anti-aliasing only. The tile rasterization code lives in path_tile.glsl so that it can later be included by other shaders.

Path tiles are drawn at the end of the clip masks, with the premultiplied dest-out blend mode in color targets. In alpha targets they use the multiply blend mode instead, because SWGL's R8 targets have no fragment alpha to blend with. No path tiles are produced yet.

Path clips on quad render tasks and clip masks push a path clip sub-task. The path is tiled when the task is added to its render target, so that the tiles can be positioned relative to the task and their edges go straight into the frame's edge buffer.

When the clip's transform to the raster space can't be computed, the clip falls back to the bounds of the path.

Wrench yaml clips get a path property with a rect, a fill rule and path data in a subset of the SVG path syntax.

Instead of rasterizing a mask image on the CPU, the path is built with SVGPathData and sent to WebRender as a path clip. This is behind the gfx.webrender.path-clips pref.

Analytical anti-aliasing has conflation artifacts where edges overlap, so path
tiles are rasterized with 8 samples per pixel by default, and 4 on Android.
The gfx.webrender.path-aa.samples pref selects the mode. Software WebRender
only builds the ssaa4 variant.

clip-path: path() and shape() are rendered with WebRender path clips, which
anti-alias differently from the mask images, so the fuzziness of the affected
tests is adjusted. corner-shape-superellipse-concave is affected through its
reference, which uses clip-path: path().

Pushed by nsilva@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/46d168cea747 https://hg.mozilla.org/integration/autoland/rev/c9d59b1e78d5 Add a path data structure to webrender_api. r=gfx-reviewers,gw https://github.com/mozilla-firefox/firefox/commit/05f2613ccb48 https://hg.mozilla.org/integration/autoland/rev/93cf1f719b05 Add a bezier module. r=gfx-reviewers,gw https://github.com/mozilla-firefox/firefox/commit/d20727a123a4 https://hg.mozilla.org/integration/autoland/rev/9cd02d6f14a9 Intern paths in the display list builder. r=gfx-reviewers,gw https://github.com/mozilla-firefox/firefox/commit/c17fc3da8458 https://hg.mozilla.org/integration/autoland/rev/58bd592ce776 Path clip item plumbing. r=gfx-reviewers,gw https://github.com/mozilla-firefox/firefox/commit/c693d7de60a1 https://hg.mozilla.org/integration/autoland/rev/400a700d5717 Move polygon_contains_point from clip.rs to hit_test.rs. r=gfx-reviewers,gw https://github.com/mozilla-firefox/firefox/commit/77942bf5af95 https://hg.mozilla.org/integration/autoland/rev/c19a920d971d Integrate paths with hit testing. r=gfx-reviewers,gw https://github.com/mozilla-firefox/firefox/commit/f4de15fe2259 https://hg.mozilla.org/integration/autoland/rev/2f2282f22bf8 Add a sparse tiling path rasterizer. r=gfx-reviewers,gw https://github.com/mozilla-firefox/firefox/commit/661f889e5074 https://hg.mozilla.org/integration/autoland/rev/fdc0e6b0ab87 Add a frame-wide path edge buffer. r=gfx-reviewers,gw https://github.com/mozilla-firefox/firefox/commit/aec6250961b0 https://hg.mozilla.org/integration/autoland/rev/899478b1c4ca Add the cs_path_tile shader. r=gfx-reviewers,gw https://github.com/mozilla-firefox/firefox/commit/76e96edb8862 https://hg.mozilla.org/integration/autoland/rev/59fb78e9ee14 Rasterize path clips with the path tiler. r=gfx-reviewers,gw https://github.com/mozilla-firefox/firefox/commit/525d17637509 https://hg.mozilla.org/integration/autoland/rev/2b971316ffca Add path clip reftests. r=gfx-reviewers,gw https://github.com/mozilla-firefox/firefox/commit/f1aed8e4987f https://hg.mozilla.org/integration/autoland/rev/97126e10f622 Render clip-path path() and shape() with WebRender path clips. r=layout-reviewers,emilio https://github.com/mozilla-firefox/firefox/commit/565e627c068f https://hg.mozilla.org/integration/autoland/rev/a565e28fa1a0 Add ssaa4 and ssaa8 anti-aliasing modes to the path tile shader. r=gfx-reviewers,gw https://github.com/mozilla-firefox/firefox/commit/be9b0db3cba9 https://hg.mozilla.org/integration/autoland/rev/1d9b407392d2 Add the polygon and box-shadow counters to the Interners profiler preset. r=gfx-reviewers,gw
Pushed by sstanca@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/658d48232bff https://hg.mozilla.org/integration/autoland/rev/a3e33634aaf9 Revert "Bug 2078306 - Add the polygon and box-shadow counters to the Interners profiler preset. r=gfx-reviewers,gw" for causing multiple failures.

Reverted this because it was causing multiple failures.

Flags: needinfo?(nical.bugzilla)

Looks like a recent bug in the DL interners my last try push was green. It's the same reason bug 2078462 got backed out. Since Glenn is working on that I'll re-land the interner-related parts of the stack after he manages to land bug 2078462.

Depends on: 2078462
Flags: needinfo?(nical.bugzilla)
Keywords: leave-open

Fixes use of deprecated constant std::u16::MAX: replaced by the MAX
associated constant on this type

Blocks: 2088007
Blocks: 2088010

Comment on attachment 9653662 [details]
Bug 2078306 - Enable WebRender path rendering by default. r=#gfx-reviewers

Revision D331231 was moved to bug 2088007. Setting attachment 9653662 [details] to obsolete.

Attachment #9653662 - Attachment is obsolete: true

Moved the rest to other bugs.

Status: NEW → RESOLVED
Closed: 14 days ago
Resolution: --- → FIXED
Blocks: 2088160
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: