Commit 7d73e2a
committed
Agg: Use 32-bit scan line classes
When rendering objects, Agg rasterizes them into scan line objects (an
x/y point, horizontal length, and colour), and the renderer class writes
those to the pixels in the final buffer. Though we have determined that
Agg buffers cannot be larger than 2**16, the scan line classes that we
use contain 16-bit _signed_ integers internally, cutting off positive
values at half the maximum.
Since the renderer uses 32-bit integers, this can cause odd behaviour
where any horizontal span that _starts_ before 2**15 (such as a
horizontal spine) is rendered correctly even if it cross that point,
but those that start after (such as a vertical spine or any portion of
an angled line) end up clipped. For example, see how the spines and
lines break in matplotlib#28893.
A similar problem occurs for resampled images, which also uses Agg
scanlines internally. See the breakage in matplotlib#26368 for an example. The
example in that issue also contains horizontal spines that are wider
than 2**15, which also exhibit strange behaviour.
By moving to 32-bit scan lines, positions and lengths of the lines will
no longer be clipped, and this fixes rendering on very large figures.
Fixes matplotlib#23826
Fixes matplotlib#26368
Fixes matplotlib#288931 parent 54d718e commit 7d73e2a
2 files changed
+5
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
121 | | - | |
| 120 | + | |
| 121 | + | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
712 | 712 | | |
713 | 713 | | |
714 | 714 | | |
| 715 | + | |
715 | 716 | | |
716 | 717 | | |
717 | 718 | | |
| |||
739 | 740 | | |
740 | 741 | | |
741 | 742 | | |
742 | | - | |
| 743 | + | |
743 | 744 | | |
744 | 745 | | |
745 | 746 | | |
| |||
0 commit comments