Skip to content

Redesign TASImage::Paint() - #23246

Open
linev wants to merge 13 commits into
root-project:masterfrom
linev:pp_image_paint
Open

Redesign TASImage::Paint()#23246
linev wants to merge 13 commits into
root-project:masterfrom
linev:pp_image_paint

Conversation

@linev

@linev linev commented Sep 3, 2026

Copy link
Copy Markdown
Member

Radical paradigm change.

Now image painting delegated to pad painter instance, which knows better
details of the platform. Thus lot of magic around gVirtualX, gVirtualPS, gPad->GetGLDevice()
completely vanishes and move to correspondent back-end. Extra palette painting made very simple.

Provide two methods for TASImage / TImage to make implementation easier.
One is access to image mask bits and second is direct invocation of X11-optimize function.
Last used only with TPadPainter which operates with gVirtualX

Special implementation provided for:

  • gVirtualX and TGX11 in TPadPainter
  • GL support in TGLPadPainter
  • SVG, PS, PDF, ImageDump via TPadPainterPS

New approach opens possibility to provide image painting for
any external platforms like Qt6 or Gtk4 or any other

Later one can remove old ugly API from TVirtualPS:

   virtual void  CellArrayBegin(Int_t W, Int_t H, Double_t x1, Double_t x2, Double_t y1, Double_t y2) = 0;
   virtual void  CellArrayFill(Int_t r, Int_t g, Int_t b) = 0;
   virtual void  CellArrayPng(char * /* buffer */, int /* size */) {}
   virtual void  CellArrayEnd() = 0;

and from TVirtualPadPainter:

   virtual void     DrawPixels(const unsigned char *pixelData, UInt_t width, UInt_t height,
                               Int_t dstX, Int_t dstY, Bool_t enableAlphaBlending) = 0;

This was last hard place with complex dependency from gVirtualX ,

linev added 11 commits September 3, 2026 15:50
These classes should handle image drawing directly without complex
logic in TASImage::Paint method.
Now it is just entry points
Just call Merge for target image
Instead calling 4 different methods,
just create PNG buffer and embed it into SVG file. Make implementation straight-forward
1. GetMaskBits create vector which can be used to create masks in X11 displayes
   One will be able to create pixmap with such masks later On

2. DrawX11 provides hook to call x11 drawing in the TASImage. Idea to remove
   use gVirtualX API from internals of TASImage and just invoke existing
   functionality from outside

3. Configure proper PNG parameters when calling GetImageBuffer

These new methods will be used in different implementations of DrawImage
Simplify logic how image placed in the PDF file
Old API was not clear enough for that
Use correct coordinates calculations to properly
scale image from pixel to PS coordinates

Partially use old API - until old will be deprecated
Redirect to fPS instance, recalculate to global coordinates
while all image formats operate with global coordinates
Use gVirtualX-based code like in original Image2Drawable method
of TASImage. There are now several shortcuts,
therefore methods looks much simpler. Also GL handling will be implemented
in correspondent painter
Simple redirection to existing DrawPixels method,
can be eliminated in the future while only used from ASImage
Radical paradigm change.

Now image painting delegated to pad painter instance, which knows better
details of platform. Thus lot of magic around virtualX, virtualPS, GL
completely vanishes.

Extra palette painting made very simple and works exactly the same as
image painting itself plut TGaxis.

Special implementation provided for:
   - gVirtualX and TGX11 in TPadPainter
   - GL support in TGLPadPainter
   - SVG, PS, PDF, ImageDump via TPadPainterPS

New approach opens possibility to provide image painting for
any external platforms like Qt6 or Gtk4 or any other
After change in TASImage::Paint there are minimal
changes in scaling/offset because of different rounding

Therefore in SVG file image offset changed sometime by one pixel
or scaling factor by 0.1%.
@linev linev self-assigned this Sep 3, 2026
After change code to TTFhandle wrong align was applied. One should use 13 instead 11
When image object drawn on the pad - just use
pp->DrawImage(). It is natural way now.
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

Test Results

    3 files      3 suites   2h 21m 56s ⏱️
2 628 tests 2 628 ✅ 0 💤 0 ❌
4 922 runs  4 922 ✅ 0 💤 0 ❌

Results for commit 77bd512.

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