Repository navigation
Conversation
Collaborator
|
Superseded by #1255, thanks regardless! |
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.
Fixes #1185.
With
stitchTiles="stitch"the stitch width, height and wrap values double with every octave, so they leave thei32range after about 20 octaves andstitch.width *= 2panics in a debug build (attempt to multiply with overflow). Release builds wrap silently.Clamping
numOctavesalone would not cover it: the same lattice code overflows innoise2, wheret as i32saturates for large coordinates andbx0 + 1then overflows, whatever the octave count. So this makes the integer lattice arithmetic wrapping instead:wrapping_mul/wrapping_sub;noise2useswrapping_add(1)for the upper lattice point andwrapping_subwhen it applies the stitch.This is what release builds already compute, so rendered output does not change. The lattice indices are masked with
BMafterwards, as before. By the time the values wrap, an octave contributes far less than the color resolution; the new test checks that 25 octaves and 20 octaves give the same sample.Tests: two unit tests in
turbulence.rs(the parameters of the issue, and huge coordinates). Without the fix both panic undercargo test -p resvg --lib turbulence(debug) at the lines above; with it they pass. CI runs tests in release mode, where the overflow does not panic, so the regression is only visible in a debug run. The reproducer from the issue renders with a debug build of the CLI, and the 19feTurbulencerender tests still pass.A clamp of
numOctaves, as suggested in the issue, would still be a reasonable optimisation on top; I left it out to keep output identical.