Skip to content

[virtualx/pad] fix pad opacity, support fill styles 4000..4100 on all platforms#21924

Open
linev wants to merge 23 commits intoroot-project:masterfrom
linev:x11_context
Open

[virtualx/pad] fix pad opacity, support fill styles 4000..4100 on all platforms#21924
linev wants to merge 23 commits intoroot-project:masterfrom
linev:x11_context

Conversation

@linev
Copy link
Copy Markdown
Member

@linev linev commented Apr 15, 2026

First extend TVirtualX interface to use window context for CopyPixmap and SetOpacity methods.
These two methods used to emulate transparency of the sub-pads on X11.
Therefore provide SetOpacityW and CopyPixmapW methods for all platforms.
And use these methods from TPadPainter class.

FIX ancient ROOT code for pad opacity. Colors arithmetic was wrong! Old code was:

new_color = old_color + white * opacity

New code is:

new_color = old_color * (1 - opacity) + pad_fill_color * opacity

After such fix created image looks very similar to GL-based rendering:

transparent_pad

TGLPadPainter use absolutely different approach and not invoke these methods directly

Move X11 pads transparency handling with fill styles 4000..4100 in TPad::PaintBorder() method.
And remove all pad-related handling from TPad::PaintBox() - now it will be normal box painting for all other primitives. Clear logic there.

Provide generic support of 4000..4100 fill styles for all platforms - GL/SVG/PDF/PS/Web/X11.
If true colors transparency supported - used it (like in SVG or GL). If not supported - ignore it (like in X11).
Any object like TBox can now be configured with fill style 4050 and become semi-transparent everywhere where it possible.

Adjust transparentpad.C demo to show exactly this new features with TPad and TPaveStats.

@linev linev self-assigned this Apr 15, 2026
@linev linev requested review from couet, dpiparo and pcanal as code owners April 15, 2026 15:39
@linev linev marked this pull request as draft April 15, 2026 15:39
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 15, 2026

Test Results

    22 files      22 suites   3d 6h 34m 36s ⏱️
 3 833 tests  3 782 ✅  1 💤 50 ❌
76 555 runs  76 487 ✅ 18 💤 50 ❌

For more details on these failures, see this check.

Results for commit 4035843.

♻️ This comment has been updated with latest results.

@linev linev changed the title [virtualx] use win context for CopyPixmap and SetOpacity methods [virtualx/pad] support fill styles 4000..4100 on all platforms Apr 17, 2026
@linev linev marked this pull request as ready for review April 17, 2026 13:12
@linev linev requested a review from bellenot as a code owner April 17, 2026 13:12
linev added 16 commits April 17, 2026 17:38
Global gCws context was used

Provide short docu for new methods
Let use window context when calling these methods.
These are central methods to emulate pad opacity without
real support of alpha channel in X11
There are several pad fill attributes which only relevant for pad.
It is fill style 4000..4100 or fillcolor 10 for fillstyle 3000..3100

Move all these special attribute only to TPad::PaintBorder
to exclude misuse of these attributes in different classes
On these platforms transparency can be used as is so
just transform to painting with transparent colors
Special handling of 4000 - do nothing.
It will be used internally in derived classes to transform
fill attributes in convenient format with color opacity
Handle them as transparent colors
So any object with such styles can use it
In case of Cocoa use normal color opacity
Before only fill style 4000..4100 was supported by TPad
Now make special handling for plain X11,
for all other platforms and all other classes like TBox
support 4000..4100 fill styles as color transparency
No need for special handling of TPadPainterPS - all pad painters
handle fill style for the box in same way
Now these are valid styles for all kind of objects
linev added 7 commits April 20, 2026 10:08
Shows styles 4000..4100 which now works similar on all platforms
On X11 only emulation mode is working - any solid painting inside
pad will ignore pad opacity
Now sequence of operation vary a bit therefore produced by web canvas code is slightly different
In previos implementation just white color with provided opacity was add - making effect absolutely "invisible"
Now pad fill color is used.
And - original colors reduced by transparency. As a result If opacity 90% original image will remain by 10%.
This was fully ignored by original algorithms and therefore opacity did not really work
Before just white color was used.
One can use std::vector for same functionality
Use std::vector<ULong_t> to keep new colors which are created for opacity emulation. Move MakeOpaqueColors directly to SetOpacityW method.
Significantly simplify code
Same as in TGX11, mix existing and pad fill color with "100-pecent" and "percent" proportion.
Use everywhere std::vector to manage colors. Remove several no longer used methods
@linev linev changed the title [virtualx/pad] support fill styles 4000..4100 on all platforms [virtualx/pad] fix pad opacity, support fill styles 4000..4100 on all platforms Apr 20, 2026
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