Open Bug 1573657 Opened 5 years ago Updated 3 months ago

Support SVG filter primitive subregions in WebRender

Categories

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

task

Tracking

()

People

(Reporter: cbrewster, Unassigned)

References

(Depends on 1 open bug, Blocks 3 open bugs)

Details

Attachments

(2 files, 1 obsolete file)

Priority: -- → P3
Blocks: 1573994
Assignee: nobody → connorbrewster

Connor, do you still plan to work on this?

Flags: needinfo?(connorbrewster)

Yes, I am still working on this, but if this is high priority I'm okay if someone wants to steal it.

Flags: needinfo?(connorbrewster)

We don't have anyone available to steal it, so it's all yours :)

Blocks: 1586055

Any news on this? Is the work you've done available anywhere? Looking at the linked spec, it looks like this is just defining another way of adding clip-rects to something, but I'm guessing it's more complicated than that?

Flags: needinfo?(connorbrewster)

Unfortunately, I haven't been able to devote as much time to this as I had hoped. I don't have a patch that got very far on this, but I can share what I had in mind.

I think you could get pretty far with adding clip-rects after each filter operation, but I don't think that alone is sufficient to support all possible SVG filters. Primarily, the issue I hit was that some SVG filter primitives require 2 inputs which allows you to create directed acyclic graphs with filter primitives. I found this difficult to represent in a WR scene since a scene is more of a tree. There currently some SVG filter stuff that I landed in WR (that Gecko doesn't use yet), and it processes the SVG filter in the render task graph instead of the scene since the render task graph can better represent complex SVG filter graphs. Since clip-rects are at the scene-level, I don't think they can be used here. So my plan was to add filter primitive subregion info to the SVG filter render tasks and provide those to the svg filter shaders so they can properly sample their inputs based on the subregion rules in the spec.

When I worked SVG filter support in WR during my internship this summer, I wrote down some notes as I went along: https://paper.dropbox.com/doc/WebRender-SVG-Filters--AuSX4~oBSNemlM0JKMJNebj2AQ-sSQSLopPODYlg7Lqzw9PZ
It is a bit of a brain dump, so it may or may not be very helpful.

Flags: needinfo?(connorbrewster)

Here's a high level view of where SVG filter are at so far:

WR API:
https://searchfox.org/mozilla-central/source/gfx/wr/webrender_api/src/display_item.rs#824-1005

Scene Building:
Create a single picture with an SVG filter composite mode with a list of filter primitives
https://searchfox.org/mozilla-central/source/gfx/wr/webrender/src/scene_building.rs#3544-3612

Render Task Creation:
Picture composite mode handling
https://searchfox.org/mozilla-central/source/gfx/wr/webrender/src/picture.rs#4499-4534

Filter primitive render task creation
https://searchfox.org/mozilla-central/source/gfx/wr/webrender/src/render_task.rs#842-1159

Shader:
https://searchfox.org/mozilla-central/source/gfx/wr/webrender/res/cs_svg_filter.glsl

Like I said, none of this is currently being used by Gecko at the moment, so feel free to take it in a different direction.

This patch adds support for filter primitive subregions within WebRender.
Filter primitive sizing is based off of Gecko's SVG filter implementation.
This patch also includes some modifications to surface filter inflation
and raster root surface scaling.

Try run: https://treeherder.mozilla.org/#/jobs?repo=try&revision=130f1d7de50594632dcdd977d4b44c1471d323d7&selectedJob=296733795

This is getting close to being ready for review, there are a few remaining pieces:

  • Limit the size of SVG filter tasks.
  • Fix a few cases of incorrect clipping within SVG tasks.
  • Provide unrounded subregions to WebRender from Gecko as these shouldn't be rounded until transform scale factors have been applied within WebRender.
  • Write more wrench reftests to exercise more edge cases.

Comment on attachment 9139064 [details]
Bug 1573657: Use nsDisplayFilter child bounds and paint rect when doing WebRender grouping

Revision D70147 was moved to bug 1573994. Setting attachment 9139064 [details] to obsolete.

Attachment #9139064 - Attachment is obsolete: true

WebRender expects subregions as unrounded floating-point values.
Prior to this, Gecko rounded filter primitive subregions immediately.
This change stores filter primitive subregions as unrounded float rects and adds
a helper method to round the subregion or filter region when needed.

There may be some extra overhead due to rounding on demand, if it is significant,
both the rounded and unrounded rects could be stored on the primitive description.

Depends on D70147

Unfortunately, I don't think I'll have time in the near future to bring this to completion. If someone wants to pick up where I left off, feel free to ping me with any questions.

Assignee: connorbrewster → nobody
Severity: normal → S3
Severity: normal → S3

This bug is made largely obsolete by Bug 1824502 where I reimplemented a more complete set of SVG filters with subregion support (and let me tell you, that was hard).

Depends on: 1824502
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: