Closed Bug 1520652 Opened 5 years ago Closed 5 years ago

SVG filters in WebRender aren't clipped.

Categories

(Core :: Graphics: WebRender, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla66
Tracking Status
firefox66 --- fixed

People

(Reporter: mattwoodrow, Assigned: mattwoodrow)

References

Details

Attachments

(2 files)

This is partially a regression from bug 1514384, where we went from clipping incorrectly to not clipping at all.

Bug 1477366 contains a lot more notes on this and the surrounding issues.

nsFilterInstance::BuildWebRenderFilters is currently trying to decide if we need to clip to the PrimitiveSubregion of each filter, by checking if the bounds of the filtered content extend outside of the subregion.

This won't work in all cases, since the bounds of the filtered content can change asynchronously (due to APZ, or async animations).

I think we need to switch to only allowing filters with a single primitive, and unconditionally clipping to the PrimitiveSubregion.

WebRender supports clipping the stacking context with a single clip (which is what was removed in bug 1514384), so we should be able to convert the PrimitiveSubregion into the right coords and create a clip for it.

We only want to clip for the SVG filters case (not CSS filters), and have the computed clip only take the PrimitiveSubregion into account (not the current filtered bounds).

The hardest bit is figuring out the right coordinate space transformation to represent the clip in the coords WebRender will be using during drawing.

Priority: -- → P2

I guess we also don't currently have tests for SVG filters on HTML content where the primitive subregion clip matters, so it would be nice to add one of those at the same time.

layout/reftests/svg/filters/feGaussianBlur-4.svg is an SVG test that has this, so could probably be converted to HTML.

This patch changes a few things:

  • Restores clipping to the computed clip, but just for SVG filters.
  • Computes the clip just from the primitive subregion, not the bounds of the filtered content.
  • Unconditionally clips all SVG filters using the primitive subregion
  • Allows clips to be combined, if they will be sharing a coordinate space
  • Fixes coordinate space of the clip region.

Depends on D16940

Assignee: nobody → matt.woodrow
Pushed by mwoodrow@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ebdc9e3d72c4
Add test for clipped SVG filter within HTML content. r=mstange
https://hg.mozilla.org/integration/autoland/rev/b9ca6790fee1
Clip SVG filters to the PrimitiveSubregion when using WebRender. r=mstange
Pushed by mwoodrow@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/eb47c0869f76
Add test for clipped SVG filter within HTML content. r=mstange
https://hg.mozilla.org/integration/autoland/rev/1342b278cd2d
Clip SVG filters to the PrimitiveSubregion when using WebRender. r=mstange
Flags: needinfo?(matt.woodrow)
Pushed by tnikkel@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/af99824dcbcd
Add test for clipped SVG filter within HTML content. r=mstange
https://hg.mozilla.org/integration/mozilla-inbound/rev/f8b877aac56e
Clip SVG filters to the PrimitiveSubregion when using WebRender. r=mstange

(In reply to Pulsebot from comment #7)

Pushed by tnikkel@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/af99824dcbcd
Add test for clipped SVG filter within HTML content. r=mstange
https://hg.mozilla.org/integration/mozilla-inbound/rev/f8b877aac56e
Clip SVG filters to the PrimitiveSubregion when using WebRender. r=mstange

Fixed the build failure and didn't know Matt was around doing the same, I'll backout my push from inbound so it doesn't conflict on merge.

Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla66
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: