Skip to content

X11 segments#21399

Open
linev wants to merge 19 commits intoroot-project:masterfrom
linev:x11_segments
Open

X11 segments#21399
linev wants to merge 19 commits intoroot-project:masterfrom
linev:x11_segments

Conversation

@linev
Copy link
Member

@linev linev commented Feb 26, 2026

Introduce methods to provide meaningful access to X11 XDrawSegments functionality

This should reduce total number of X11 calls and improve performance of slow remote X11 displays
But for that one really need to use such functionality in the code

As first exercise try to modify TGaxis painter where many ticks were drawn with separate calls.
Now they collected together in temporary buffer and gPad->DrawSegments at the end.

Provide specific implementation for TGX11::DrawLinesSegments - using current device and line attributes.
If there are too many segments (>500K) - operation splitted on several - same like for poly-line

Provide specific TSVG::DrawSegments() implementation to create single svg:path element.

At the same time in TVirtualX::DrawLinesSegments() and in TVirtualPS::DrawSegments() provide
default implementation which just call N times DrawLine method. So any derived classes - internal and external - not need to be modified at all.

Ref files for stressGraphics are changed while svg for axis ticks is now more compact.
Also PS and PDF files can be smaller while dummy segments (zero length) are not drawn at all

After the PR several other places can be significantly improved minimizing total number of X11 calls

linev added 10 commits February 26, 2026 14:52
Idea to have interface which handle painting of many segments at once. On platforms like X11 drawing of many lines at once can be performed with single call
Apply clip condition, draw on virtualx and virtualps
Here no clipping is required,
for VirtualPS coordinates need to be recalculated
Make lambda to paint ticks at specified index/position
So reduce code duplication when painting extra ticks
on left and right sides.
Prepare code to fill buffers for segments painting
First collect all ticks and grids positions in the vector
and then call function at the end
In SVG files all grids lines drawn together after all ticks so
order is changed.
But produced image will not change while grids always drawn on the top of the ticks

PS image can reduce in size while now attributes not switched between ticks and grids all the time
Provide default implementation to ensure that
all possible derived classes will work with new code
So first recalculate/clip buffers and then call methods
@linev linev self-assigned this Feb 26, 2026
@linev linev marked this pull request as draft February 26, 2026 20:53
@github-actions
Copy link

github-actions bot commented Feb 27, 2026

Test Results

    21 files      21 suites   3d 0h 16m 41s ⏱️
 3 806 tests  3 756 ✅ 1 💤 49 ❌
73 128 runs  73 070 ✅ 9 💤 49 ❌

For more details on these failures, see this check.

Results for commit 12e657b.

♻️ This comment has been updated with latest results.

Provide default implementation which makes simple
drawing of N individual lines.
While method `DrawSegments` with low-level API is already exist use name `DrawLinesSegments`
Like with TGX11::DrawPolyLine,
split drawing on smaller portions if more than 500000
 segments provide at a time.

 Use direct cast from `TPoint *` to `XSegment *` while
 segment is just two points one after another
Now native graphics can use faster X11 routine
It should allow to optimize drawing of the segments on SVG/PDF outputs
Recalculate buffer when using NDC -
while PS always used only user coordinates
Many segments of similar line style combined now
together in same svg:path element
stressGraphics.ref changed while dummy segments (zero-size length)
not drawn at all. So ticks of zero size not appear in PS and PDF files
as well.

In svg_ref now axis ticks drawn as segments so now is
the only svg:path for all axis ticks are placed.

Main content of SVG files did not change so
it is minimal amount of data commited into repository
@linev linev marked this pull request as ready for review February 27, 2026 12:50
While labels and grid/ticks painting was mixed,
move produced labels in intermediate buffer to paint
them between ticks and grids
After change in TGaxis segments for log scale are used.
This makes more compact SVG and also PS can be shorter while all ticks drawn before all grids
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant