Repository navigation
Fix feDisplacementMap applying scale twice - #1157
Open
bhaskargurram-ai wants to merge 1 commit into
Open
bhaskargurram-ai wants to merge 1 commit into
bhaskargurram-ai wants to merge 1 commit into
Conversation
…d map `apply_displacement_map` converts `scale` into pixels via `scale_coordinates(fe.scale(), fe.scale(), ts)` and then `displacement_map::apply` multiplied the offset by `fe.scale()` again, so the effective displacement was `scale^2`. For `scale="30"` that is a ±450px offset, which samples outside the filter region for almost every pixel and leaves only scattered specks of the source. The map is now read with non-premultiplied color values, as the spec and the kernel's own contract require. Fixes linebender#1019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
apply_displacement_mapconvertsscaleinto pixels withscale_coordinates(fe.scale(), fe.scale(), ts), and thendisplacement_map::applymultiplied the offset byfe.scale()a second time, so the effective displacement wasscale². Forscale="30"that is a ±450 px offset: almost every sample lands outside the filter region and only a few specks of the source survive, which is what #1019 (and Figma/Illustrator "distort" exports) show.This PR:
scaleonce (P'(x,y) = P(x + scale·(XC − ½), y + scale·(YC − ½)), withscaleconverted from user units to pixels as before);in2are performed using non-premultiplied color values") and which the kernel's own doc comment already asked for; Skia does the same (unpremulinsk_displacement);scale/2), the same map at 50% opacity (must render identically),primitiveUnits="objectBoundingBox",scale="0", and the fractal-noise reproducer from the issue.With the issue's reproducer, the rect goes from 11 opaque pixels to 10,753 (unfiltered: 10,800), i.e. a solid interior with eroded edges, matching what Chrome/Firefox/Safari produce.
Not changed here:
inis still converted to thecolor-interpolation-filtersspace like the other primitives (Chrome does this too), andobjectBoundingBoxstill averages the bbox width/height into one scalar (Chrome only uses the horizontal scale, so there is no clear per-axis reference).Fixes #1019