Normalize and Sanitize invalid linewidth inputs #30923
Open
+17
−3
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.
PR summary
Closes #29439, adopting the no line policy as described in this comment, we force all infinite, NaN and negative values of linewidths to 0.0.
For uniformity, ideally all linewidths(like hatch linewidths) should be sanitized in a similar way
Previous Behavior when passing NaN
Renderer::Agg_draw_path,mpl_roundis called on linewidth which successfully casts a nan value to an int (throughmpl_round_to_int) which becomes INT_MIN (-2,147,483,648). Now the linewidth is a very large negative number.render_scanlines()in agg_renderer_scanline.h callsrewind_scanlineswherem_scan_yis set to -8,320,836 (An overflow safe version of INT_MIN used inrasterizer_cells_aa<Cell>::line). INT_MIN is shifted by 8 bits essentially dividingm_scan_yvalue is incremented in thesweep_scanline()function slowly until it hits 0sweep_scanlineis calledCurrent Behavior when passing NaN
All backends draw no line
PR checklist