Extending TVirtualX interface, avoid gVirtualX in painters#21586
Open
linev wants to merge 37 commits intoroot-project:masterfrom
Open
Extending TVirtualX interface, avoid gVirtualX in painters#21586linev wants to merge 37 commits intoroot-project:masterfrom
linev wants to merge 37 commits intoroot-project:masterfrom
Conversation
Test Results 21 files 21 suites 3d 0h 19m 49s ⏱️ Results for commit 71398df. ♻️ This comment has been updated with latest results. |
dc8ec78 to
b9748a6
Compare
Move from plain array to unordered_map. So pointer on XWindow_t will not change if new window will be created later. Idea to use this pointer later as main handle for graphics operation - while using window id will costs locking of the mutex which need to be introduced later for threads safety
First provide window context for each active window. Window context should allow access per-window functionality fully independent from each other As a first interfaces declare methods to change attributes.
So one can set different drawing attributes independently for each window.
Allows to use native X11 types without casting. List of windows now defined as: ``` std::unordered_map<Int_t,std::unique_ptr<XWindow_t>> fWindows ```
In TCanvas::Feedback() method first select fCanvasID before changing draw mode. Only becase of global GC attributes it was possible before. If GC allocated per window - one should do it correctly
Only window-specific contexts are used Remove unused method CopyWindowtoPixmap
So setting line/fill style to TGX11 will change attributes for currently selected window. Comment out most of members
Allocate marker attributes per window, comment aout global gMarker structures
Where it make sense - use XDrawSegments for markerS
Without TTF support X11 fonts are used. Move text attributes handling to XWindow_t structure, keep only global gTextFont for text size handling.
One can add hook there to allocate and initialize there TTF structures. For now keep global members
Last place was PutImage method - used either special window GC or just temporary created GC PutImage is not used at all
Now only window-special contexts are used
Use when TGX11TTF instance must be created. Copy constructor it too complicated.
So one can specify window where drawing operation is performed
Old signatures redirects to new methods
Remember context of selected window and use this context when performing drawing on the pad
Provide protected methods to return window, GC and textAlign for selected window context. And use context in TTF rendering methods. So now TGX11TTF also correctly implementes API, but not yet thread-safe because of TTF global states.
Instead set individiual line or fill attributes use new methods with TAtt... object as instance. In TPadPainter it is redirected to selected window context So even if there are several canvases displayed - attributes will be modified in the correct window context.
While some objects painters analyze attributes like gVirtualX->GetLineWidth(), provide such getters. But only for transition phase - later one can dismiss methods again
line width and fill style used in drawing. While attributes set anyway via pad painter interface, just remember them to avoid need provide getters from TVirtualX
To avoid complication with derived classes
b9748a6 to
e9c0a76
Compare
For some special applications like TASImage provide access to PS instance from pad painter. So one do not need to duplicate interface several times.
Instead of gVirtualX or gVirtualPS use pad painter instance
Use pad painter for exclusive text drawing on screen or on PS device. In rare cases provide special handling of PS output (like tilde).
One cannot use TGX11 itself while one access attributes via getter methods which already redefined in TGX11. So make copy of stored attributes
Replace usage of gVirtualX
While both TPad and TWbox uses same code, put it together in TWbox::PaintBorderOn method. So fully avoid usage of PaintBorderPS method, can be removed in the future
Now border decorations of the sub-pad drawn slightly different using TWbox method. So ref file size is slightly changed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Current
TVirtualXapi is not thread safe.There is no way to create several canvases and update them individually from different threads.
Main reason - several global X11 objects which are modified all the time during painting.
But already in the current implementation there is array of
XWindow_tstructures which is used to managewidget-related data.
So idea to extend
XWindow_tstructure and put there all data which are relevant for widgets painting.And then provide API methods where window id or directly
XWindow_tpointer used as first argument.So one can implement painting which in theory can be fully independent from other parallel actions.
This PR is the exercise if such transition is possible. It moves all attributes to
XWindow_tstructure andprovide all painting methods using these attributes. And this seems to be working!
Missing part is refactoring of
TTFclass. It is crucial for text drawing and currently has fully static interface - which does not allow multi-threaded usage. But there is no principal problem to solve this. Similar problem is code inRotated.cxx- which used for text rotation.In all classes where
gVirtualXused directly in painting - replace it by calls toTVirtualPadPainter.So only in very special places - like TASImage or TLatex - implement painting code which differs for PS and X11 interface. But these places are very few and can be adjusted later,