Skip to content

[graphics] Fix storage of subpad into image file#22022

Merged
linev merged 15 commits intoroot-project:masterfrom
linev:save_subpad
Apr 24, 2026
Merged

[graphics] Fix storage of subpad into image file#22022
linev merged 15 commits intoroot-project:masterfrom
linev:save_subpad

Conversation

@linev
Copy link
Copy Markdown
Member

@linev linev commented Apr 23, 2026

When TPad::SaveAs() was called for sub-pad corrupted image was generated or in some case ROOT just crashed.

  1. Correctly compensate graphical coordinates shift when storing sub-pad in the TImageDump
  2. Provide TASImage::DrawTextOnPad() method to correctly mimic fact that TASImage uses pad coordinates and checks pad boundaries when draw text. Method also include optional offset.
  3. Fix segfault when negative coordinate was used in TASImage. Affects most of the methods. Backport provided for 6.40 Backport graphics fixes to 6.40 #22021, one also can backport to older branches.
  4. Provide TTF::CleanupGlyps() method and use it in all relevant places. Try to avoid memory leak after text rendering.
  5. Modernize TImageDump methods to use less static variables and prefer std::vector usage
  6. In TVirtualPS provide OpenStream() and CloseStream() methods to manage file stream centrally

linev added 11 commits April 23, 2026 10:03
Subpad has offset in coordinate system which
can be calculated when new page is started
Specify exactly pad which will be used for text painting
It used to correctly scale text and to check clipping rules.
Extra offset x/y needed when sub-pad is  stored and graphical coordinates of pad differs from absolute pad coordinates in the canvas
Most crucial change is correct clipping rule check
using provided offset.
Important is providing offsets for pad
Index was checked on max value, but not on negative value
It ensure that temporary allocated data removed shortly after string rendering.
Otherwise at the end some part can remain.
Also use it internally in methods like TTF::GetTextExtent
Made TTF::Init() reentrant
Always call TTF::Init() while it is re-entrant now
Always call TTF::Init();
Always call TTF::Init()
Always call TTF::Init() - it is reentrant
Can be easily used in the future from multithreads
@linev linev self-assigned this Apr 23, 2026
@linev linev requested a review from couet as a code owner April 23, 2026 08:19
linev added 4 commits April 23, 2026 11:27
Instead of old style with lot of static variables just use std::vector for points arrays and dash array
Replace static variables by members,
use vector.
Base class holds fStream pointer which used for file output in derived classes. Provide methods to open and close this file stream. For special usecase (PDF) binary stream output need to be configured for Windows.
Do not initialize fStream member in constructors - it belongs to base classes.
Use everywhere `Error()` method to report errors
Small other adjustments
@linev linev requested review from dpiparo and pcanal as code owners April 23, 2026 11:52
@linev linev changed the title Fix storage of subpad into image file [graphics] Fix storage of subpad into image file Apr 23, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 23, 2026

Test Results

    22 files      22 suites   3d 8h 26m 13s ⏱️
 3 846 tests  3 793 ✅  1 💤 52 ❌
76 847 runs  76 777 ✅ 18 💤 52 ❌

For more details on these failures, see this check.

Results for commit 6589bf3.

♻️ This comment has been updated with latest results.

@linev
Copy link
Copy Markdown
Member Author

linev commented Apr 24, 2026

Failure on alma in fitpanel testing - will be fixed extra

@linev linev merged commit 9b0c8da into root-project:master Apr 24, 2026
47 of 53 checks passed
@linev linev deleted the save_subpad branch April 24, 2026 05:31
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.

2 participants