Skip to content

[asimage] move TVirtualX and X11 specific methods to extra library - #23732

Open
linev wants to merge 21 commits into
root-project:masterfrom
linev:image_lessx
Open

linev wants to merge 21 commits into
root-project:masterfrom
linev:image_lessx

Conversation

@linev

@linev linev commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

This is final step to prepare TASImage and TCanvas classes to be free from gVirtualX in ROOT7

Currently there are several methods which require X11 and gVirtualX in TASImage
Copy such methods to extra library with TASUtils class.
Link libGui with this library.
All respective TASImage methods mark as deprecated for removal in ROOT7.

While TPadPainter need to use functionality from TASUtils class - create special library for
TPadPainter. This was planned from very beginning, but realized only now!
Thus one removes major gVirtualX-dependend code from Gpad library.
Provide special "native" plugin to create instance of TPadPainter.
Classical TRootCanvas returns instance of TPadPainter as well - so in most of the cases plugin not necessary.

Macro galaxy_image.C shows user case when plugin is required.
In this macro ASImage palette editor is shown, which uses TPad without canvas implementation.

@linev linev self-assigned this Oct 16, 2026
@linev
linev requested a review from bellenot as a code owner October 16, 2026 08:59
@linev
linev requested a review from silverweed as a code owner October 16, 2026 08:59
@linev linev added the in:GUI label Oct 16, 2026
@linev
linev marked this pull request as draft October 16, 2026 08:59
@linev
linev force-pushed the image_lessx branch 3 times, most recently from 5c8e9cb to 17383a6 Compare October 16, 2026 15:14
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Test Results

    22 files      22 suites   3d 23h 39m 47s ⏱️
 3 888 tests  3 887 ✅ 0 💤 1 ❌
78 298 runs  78 296 ✅ 0 💤 2 ❌

For more details on these failures, see this check.

Results for commit fff8ed9.

♻️ This comment has been updated with latest results.

@linev
linev force-pushed the image_lessx branch 5 times, most recently from cbe1456 to fff8ed9 Compare October 20, 2026 08:07

@bellenot bellenot left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, I tested the changes locally on Windows and it seems to work fine with the few tests I ran...

@linev
linev marked this pull request as ready for review October 20, 2026 11:16
@linev
linev requested review from dpiparo and pcanal as code owners October 20, 2026 11:16
@linev linev added the clean build Ask CI to do non-incremental build on PR label Oct 20, 2026
Comment thread graf2d/asimage/inc/TASImage.h Outdated
Comment thread graf2d/asimage/src/TASImage.cxx
Comment thread graf2d/asimage/inc/TASUtils.h Outdated
Comment thread graf2d/asimage/inc/TASUtils.h
Comment thread graf2d/asimage/src/TASUtils.cxx Outdated
Comment thread graf2d/asimage/inc/TASUtils.h Outdated
Comment thread graf2d/padpainter/src/TPadPainter.cxx
Comment thread gui/guihtml/src/TGHtmlDraw.cxx
Comment thread graf3d/gl/src/TGLPadPainter.cxx
Comment thread graf2d/asimage/src/TASImage.cxx Outdated
linev added 8 commits October 22, 2026 16:25
Used by TASPaletteEditor to display gradient palette
One then can use directly TASImage::Paint to paint created palette
This let avoid direct usage of special methods
Let return selected ASVisual as return value of TASImage::InitVisual(). Use batch for first time in Mirror method
It will be place for special TASImage methods which require
X11 and gVirtualX functionality.

In ROOT7 old deprecated methods will be removed from TASImage itself.
These are TASImage methods which require gVirtualX and X11, therefore they are extracted
Main reason that it uses ASImage and TVirtualX and is main source of
gVirtualX dependency in Gpad. Plus new ASImageUtils library now implement
extra X11-related and gVirtualX-related methods which need to be used by pad painter.

Register plugin "native" for pad painter - as it was forseen from the very beginning.

TRootCanvas now links to new library and returns instance of TPadPainter.
Default canvas no longer created automatically but only when obj->Draw() is invoked
These methods were introduced recently and replaced by
special TASUtils methods. Only there X11 and gVirtualX should be used
Create TASImage and fill content with gVirtualX pixmap data
Use also speicalized X11 method - when runs on correspondent platform
Replacement for TASImage::SetImage() functionality
linev added 13 commits October 22, 2026 16:25
Typically used generate different icons.
Adjust methods where pic->SetImage(pixmap, mask) was used.
Use std::unique_ptr<TImage> in all touched methods to ensure ownership
Functionality provided in TASUtils and TGWindow classes
Method will be removed in ROOT7
It should replace TASImage::PaintImage(),
but without selection of paint region.
Therefore only full image can be painted

Use holder object to preserve created GC context,
will be deleted at the end
Also use unique_ptr to avoid memory leaks
Do not call img->PaintImage() when no any part of image
visible in currently drawing region.
Use Image::Crop to extract visible part of image.
Avoid usage of complex and error-prone img->Paint with too many arguments
Direct method in TImage will be deprectaed
It uses X11 functionality and was replaced by TASUtils::PaintImage() method
Instead calling DrawPixels just implement
method,
deprecate DrawPixels in gl painter
Functionality everywhere replaced by DrawImage,
method will be removed in ROOT7
With start_image_decoding in the TASImage::Crop() created decorder
was released wrongly. Instaed `delete[] imdec` one have to use
`stop_image_decoding(&imdec);`

Also check input parameters - if x or y larger than width or height
large negative values converted to unsigned causing segfault or
memory allocation problems.

Adjust also GetScanline where array not need to be created
It was intermediate solution to avoid creation of extra library
Now ASUtils library is exists, therefore all specialized methods
used in GUI can be moved there.
@silverweed

Copy link
Copy Markdown
Contributor

In principle lgtm but I'm thinking we might want to wait until after the branching to merge this (I don't think it's critical that this lands in 6.42)

@linev

linev commented Oct 22, 2026

Copy link
Copy Markdown
Member Author

In principle lgtm but I'm thinking we might want to wait until after the branching to merge this

I start deprecating methods of TImage/TASImage classes.
And this is important to have in the next release

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clean build Ask CI to do non-incremental build on PR in:Graphics in:GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants