From 53d2d72603a79122f2f81f8a8241034e380bac21 Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Tue, 27 Oct 2026 11:16:04 +0100 Subject: [PATCH 1/4] [asutils] build dummy library when asimage not build When asimage disabled just build dummy library It will does nothing and will not try to link with libAfterImage Avoid complex workaround in different places where ASUtils are used now. Also better shows places where asimage is really required --- graf2d/CMakeLists.txt | 6 +- graf2d/asimage/CMakeLists.txt | 97 ++++++++++++++++++--------------- graf2d/asimage/src/TASUtils.cxx | 49 ++++++++++++++++- 3 files changed, 105 insertions(+), 47 deletions(-) diff --git a/graf2d/CMakeLists.txt b/graf2d/CMakeLists.txt index 8d993e59f9682..def0cabf92dd5 100644 --- a/graf2d/CMakeLists.txt +++ b/graf2d/CMakeLists.txt @@ -17,9 +17,9 @@ elseif(x11) add_subdirectory(x11) # special CMakeLists.txt add_subdirectory(x11ttf) # special CMakeLists.txt endif() -if(asimage) - add_subdirectory(asimage) # special CMakeLists.txt -endif() + +add_subdirectory(asimage) # special CMakeLists.txt + add_subdirectory(padpainter) if(gviz) add_subdirectory(gviz) diff --git a/graf2d/asimage/CMakeLists.txt b/graf2d/asimage/CMakeLists.txt index 6ef9aa0e6007e..6cbbb48095345 100644 --- a/graf2d/asimage/CMakeLists.txt +++ b/graf2d/asimage/CMakeLists.txt @@ -7,35 +7,57 @@ ############################################################################ # CMakeLists.txt file for building ROOT graf2d/asimage package # @author Pere Mato, CERN +# @author Sergey Linev, GSI ############################################################################ -ROOT_STANDARD_LIBRARY_PACKAGE(ASImage - NO_INSTALL_HEADERS - HEADERS - TASImage.h - TASImagePlugin.h - TASPluginGS.h - TASPngWriter.h - SOURCES - TASImage.cxx - TASPluginGS.cxx - TASPngWriter.cxx - DICTIONARY_OPTIONS - -writeEmptyRootPCM - LIBRARIES - libAfterImage - DEPENDENCIES - Core - Graf - Postscript -) +if(asimage) + + ROOT_STANDARD_LIBRARY_PACKAGE(ASImage + NO_INSTALL_HEADERS + HEADERS + TASImage.h + TASImagePlugin.h + TASPluginGS.h + TASPngWriter.h + SOURCES + TASImage.cxx + TASPluginGS.cxx + TASPngWriter.cxx + DICTIONARY_OPTIONS + -writeEmptyRootPCM + LIBRARIES + libAfterImage + DEPENDENCIES + Core + Graf + Postscript + ) + + if (x11) + target_link_libraries(ASImage PRIVATE X11::X11) + endif() + + ROOT_STANDARD_LIBRARY_PACKAGE(ASImageGui + NO_INSTALL_HEADERS + HEADERS + TASPaletteEditor.h + SOURCES + src/TASPaletteEditor.cxx + LINKDEF + LinkDefGui.h + DICTIONARY_OPTIONS + -writeEmptyRootPCM + LIBRARIES + libAfterImage + DEPENDENCIES + Gui + ASImage + ) -if (x11) - target_link_libraries(ASImage PRIVATE X11::X11) endif() ROOT_STANDARD_LIBRARY_PACKAGE(ASImageUtils - NO_INSTALL_HEADERS + NO_INSTALL_HEADERS HEADERS TASUtils.h SOURCES @@ -44,30 +66,19 @@ ROOT_STANDARD_LIBRARY_PACKAGE(ASImageUtils LinkDefUtils.h DICTIONARY_OPTIONS -writeEmptyRootPCM - LIBRARIES - libAfterImage DEPENDENCIES - ASImage Gpad ) -ROOT_STANDARD_LIBRARY_PACKAGE(ASImageGui - NO_INSTALL_HEADERS - HEADERS - TASPaletteEditor.h - SOURCES - src/TASPaletteEditor.cxx - LINKDEF - LinkDefGui.h - DICTIONARY_OPTIONS - -writeEmptyRootPCM - LIBRARIES - libAfterImage - DEPENDENCIES - Gui - ASImage -) +if(asimage) + target_link_libraries(ASImageUtils PRIVATE libAfterImage) + target_link_libraries(ASImageUtils PUBLIC ASImage) +else() + target_compile_definitions(ASImageUtils PRIVATE NO_ASIMAGE) +endif() ROOT_INSTALL_HEADERS() -ROOT_ADD_TEST_SUBDIRECTORY(test) +if(asimage) + ROOT_ADD_TEST_SUBDIRECTORY(test) +endif() diff --git a/graf2d/asimage/src/TASUtils.cxx b/graf2d/asimage/src/TASUtils.cxx index dd01c8d3a9e76..6c7b2a1509af3 100644 --- a/graf2d/asimage/src/TASUtils.cxx +++ b/graf2d/asimage/src/TASUtils.cxx @@ -11,12 +11,57 @@ #include "TASUtils.h" #include "RConfigure.h" -#include "TASImage.h" #include "TVirtualX.h" #include "TSystem.h" #include "TVirtualPad.h" #include "TError.h" + +#ifdef NO_ASIMAGE + +#include "TImage.h" + + +Pixmap_t TASUtils::GetPixmap(TImage *) +{ + ::Error("TASUtils::GetPixmap", "Not implemented, ASImage is not compiled"); + return 0; +} + +Pixmap_t TASUtils::GetMask(TImage *) +{ + ::Error("TASUtils::GetMask", "Not implemented, ASImage is not compiled"); + return 0; +} + +Bool_t TASUtils::PaintImage(TImage *, Drawable_t, Int_t, Int_t, Bool_t) +{ + ::Error("TASUtils::PaintImage", "Not implemented, ASImage is not compiled"); + return kFALSE; +} + +Bool_t TASUtils::FillImageFromWindow(TImage *, Window_t, Int_t, Int_t) +{ + ::Error("TASUtils::FillImageFromWindow", "Not implemented, ASImage is not compiled"); + return kFALSE; +} + +std::unique_ptr TASUtils::FromWindow(Window_t) +{ + ::Error("TASUtils::FromWindow", "Not implemented, ASImage is not compiled"); + return nullptr; +} + +std::unique_ptr TASUtils::FromPixmap(Pixmap_t, Pixmap_t) +{ + ::Error("TASUtils::FromPixmap", "Not implemented, ASImage is not compiled"); + return nullptr; +} + +#else // NO_ASIMAGE + +#include "TASImage.h" + #ifdef WIN32 #define X_DISPLAY_MISSING 1 #include "Windows4root.h" @@ -341,3 +386,5 @@ Bool_t TASUtils::PaintImage(TImage *timg, Drawable_t wid, Int_t x, Int_t y, Bool return res; } + +#endif // NO_ASIMAGE \ No newline at end of file From 9bbbe8d1cac7fa32bccd95429c213a8b8a2950ba Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Tue, 27 Oct 2026 11:24:30 +0100 Subject: [PATCH 2/4] [padpainter] always use ASUtils No need for special workarounds when asimage is disabled - now it is done in the asutils intself --- graf2d/padpainter/CMakeLists.txt | 7 +------ graf2d/padpainter/src/TPadPainter.cxx | 23 ++--------------------- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/graf2d/padpainter/CMakeLists.txt b/graf2d/padpainter/CMakeLists.txt index 2553f0411cda1..5b6603d8a256e 100644 --- a/graf2d/padpainter/CMakeLists.txt +++ b/graf2d/padpainter/CMakeLists.txt @@ -19,13 +19,8 @@ ROOT_STANDARD_LIBRARY_PACKAGE(ROOTPadPainter -writeEmptyRootPCM DEPENDENCIES Gpad + ASImageUtils ) -if(asimage) - target_link_libraries(ROOTPadPainter PUBLIC ASImageUtils) - target_compile_definitions(ROOTPadPainter PRIVATE USE_ASIMAGEUTILS) -endif() - - ROOT_INSTALL_HEADERS() diff --git a/graf2d/padpainter/src/TPadPainter.cxx b/graf2d/padpainter/src/TPadPainter.cxx index 071a0866e7440..874f3b06b31f9 100644 --- a/graf2d/padpainter/src/TPadPainter.cxx +++ b/graf2d/padpainter/src/TPadPainter.cxx @@ -17,6 +17,7 @@ #include "TPadPainter.h" #include "TVirtualX.h" #include "TSystem.h" +#include "TASUtils.h" #include "TCanvas.h" #include "TPoint.h" #include "TError.h" @@ -25,10 +26,6 @@ #include "TMath.h" #include "TPad.h" -#ifdef USE_ASIMAGEUTILS -#include "TASUtils.h" -#endif - namespace { //Typedef is fine, but let's pretend we look cool and modern: @@ -234,17 +231,9 @@ void TPadPainter::DrawImage(TImage *img, Int_t x, Int_t y, Int_t flags) // use old API to draw image on gVirtualX window // img->PaintImage(wid, x, y, 0, 0, 0, 0, flags ? "" : "opaque"); -#ifdef USE_ASIMAGEUTILS + // new API invokes TASUtils::PaintImage(img, wid, x, y, !flags); -#else - ::Error("TPadPainter::DrawImage", "TASImage not compiled, image painting is not possible"); - (void) wid; - (void) img; - (void) x; - (void) y; - (void) flags; -#endif } //////////////////////////////////////////////////////////////////////////////// @@ -596,7 +585,6 @@ Bool_t TPadPainter::FillImageFromPad(TImage *image, TVirtualPad *pad) const if (!image || !pad) return kFALSE; -#ifdef USE_ASIMAGEUTILS auto width = pad->GetPadWidth(); auto height = pad->GetPadHeight(); @@ -604,14 +592,7 @@ Bool_t TPadPainter::FillImageFromPad(TImage *image, TVirtualPad *pad) const gVirtualX->SelectWindow(wid); Window_t wd = gVirtualX->GetCurrentWindow(); - return TASUtils::FillImageFromWindow(image, wd, width, height); -#else - ::Error("TPadPainter::FillImageFromPad", "Cannot work without TASImage class"); - (void) image; - (void) pad; - return kFALSE; -#endif } //Aux. private functions. From 9a25fa6bb85374d1636fa8f9a67bd7b67378353c Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Wed, 28 Oct 2026 08:01:43 +0100 Subject: [PATCH 3/4] [asimage] extend TImage::FromBitmap functionality Add optional mask argument It can be used by TASUtils::FromPixmap method It also resolves Windows problem where invocation of bitmap2asimage from ASUtils fails. --- graf2d/asimage/inc/TASImage.h | 2 +- graf2d/asimage/src/TASImage.cxx | 4 ++-- graf2d/asimage/src/TASUtils.cxx | 2 +- graf2d/graf/inc/TImage.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/graf2d/asimage/inc/TASImage.h b/graf2d/asimage/inc/TASImage.h index 5a85bc0035c2a..d14af09359688 100644 --- a/graf2d/asimage/inc/TASImage.h +++ b/graf2d/asimage/inc/TASImage.h @@ -112,7 +112,7 @@ friend class TASUtils; // to implement gVirtualX-specific methods const char *GetTitle() const override; const char *GetIconName() const override { return GetTitle(); } - void FromBitmap(const UChar_t *buf, UInt_t width, UInt_t height) override; + void FromBitmap(const UChar_t *buf, UInt_t width, UInt_t height, const UChar_t *mask = nullptr) override; void FromPad(TVirtualPad *pad, Int_t x = 0, Int_t y = 0, UInt_t w = 0, UInt_t h = 0) override; void FromWindow(Drawable_t wid, Int_t x = 0, Int_t y = 0, UInt_t w = 0, UInt_t h = 0) override; void FromGLBuffer(UChar_t *buf, UInt_t width, UInt_t height) override; diff --git a/graf2d/asimage/src/TASImage.cxx b/graf2d/asimage/src/TASImage.cxx index ee0208d3fb1bb..abddad4cabfa7 100644 --- a/graf2d/asimage/src/TASImage.cxx +++ b/graf2d/asimage/src/TASImage.cxx @@ -6353,12 +6353,12 @@ void TASImage::FromGLBuffer(UChar_t* buf, UInt_t w, UInt_t h) //////////////////////////////////////////////////////////////////////////////// /// Creates an image from a RGBA buffer -void TASImage::FromBitmap(const UChar_t *buf, UInt_t width, UInt_t height) +void TASImage::FromBitmap(const UChar_t *buf, UInt_t width, UInt_t height, const UChar_t *mask) { DestroyImage(); DestroyScaledImage(); - fImage = bitmap2asimage(const_cast(buf), width, height, 0, nullptr); + fImage = bitmap2asimage(const_cast(buf), width, height, 0, const_cast(mask)); } diff --git a/graf2d/asimage/src/TASUtils.cxx b/graf2d/asimage/src/TASUtils.cxx index 6c7b2a1509af3..1e6014122efc9 100644 --- a/graf2d/asimage/src/TASUtils.cxx +++ b/graf2d/asimage/src/TASUtils.cxx @@ -295,7 +295,7 @@ std::unique_ptr TASUtils::FromPixmap(Pixmap_t pxm, Pixmap_t mask) unsigned char *mask_bits = mask ? gVirtualX->GetColorBits(mask, 0, 0, w, h) : nullptr; - asimg->fImage = bitmap2asimage(bits, w, h, 0, mask_bits); + asimg->FromBitmap(bits, w, h, mask_bits); if (mask_bits) delete [] mask_bits; diff --git a/graf2d/graf/inc/TImage.h b/graf2d/graf/inc/TImage.h index 4bab2fd8fa545..50460f8ceeca1 100644 --- a/graf2d/graf/inc/TImage.h +++ b/graf2d/graf/inc/TImage.h @@ -124,7 +124,7 @@ friend TImage operator/(const TImage &i1, const TImage &s2); // Create an image from bitmap. (See TASImage::FromBitmap) - virtual void FromBitmap(const UChar_t * /*buf*/, UInt_t /*w*/, UInt_t /*h*/) {} + virtual void FromBitmap(const UChar_t * /*buf*/, UInt_t /*w*/, UInt_t /*h*/, const UChar_t * /* mask */ = nullptr) {} // Create an image from the given pad. (See TASImage::FromPad) virtual void FromPad(TVirtualPad * /*pad*/, Int_t /*x*/ = 0, Int_t /*y*/ = 0, UInt_t /*w*/ = 0, UInt_t /*h*/ = 0) {} From 4eadfe5b8d4dbe51011c4352ed08315aaceaa7f1 Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Wed, 28 Oct 2026 12:57:17 +0100 Subject: [PATCH 4/4] [asimage] adjust cmake file Configure gui library after ASImageUtils Add NO_GLOB_HEADERS to avoid multiple rules for same headers --- graf2d/asimage/CMakeLists.txt | 48 +++++++++++++++++------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/graf2d/asimage/CMakeLists.txt b/graf2d/asimage/CMakeLists.txt index 6cbbb48095345..a0e3ea33e25ca 100644 --- a/graf2d/asimage/CMakeLists.txt +++ b/graf2d/asimage/CMakeLists.txt @@ -13,7 +13,7 @@ if(asimage) ROOT_STANDARD_LIBRARY_PACKAGE(ASImage - NO_INSTALL_HEADERS + NO_GLOB_HEADERS HEADERS TASImage.h TASImagePlugin.h @@ -37,27 +37,10 @@ if(asimage) target_link_libraries(ASImage PRIVATE X11::X11) endif() - ROOT_STANDARD_LIBRARY_PACKAGE(ASImageGui - NO_INSTALL_HEADERS - HEADERS - TASPaletteEditor.h - SOURCES - src/TASPaletteEditor.cxx - LINKDEF - LinkDefGui.h - DICTIONARY_OPTIONS - -writeEmptyRootPCM - LIBRARIES - libAfterImage - DEPENDENCIES - Gui - ASImage - ) - endif() ROOT_STANDARD_LIBRARY_PACKAGE(ASImageUtils - NO_INSTALL_HEADERS + NO_GLOB_HEADERS HEADERS TASUtils.h SOURCES @@ -70,15 +53,32 @@ ROOT_STANDARD_LIBRARY_PACKAGE(ASImageUtils Gpad ) + if(asimage) + target_link_libraries(ASImageUtils PRIVATE libAfterImage) + target_link_libraries(ASImageUtils PUBLIC ASImage) -else() - target_compile_definitions(ASImageUtils PRIVATE NO_ASIMAGE) -endif() -ROOT_INSTALL_HEADERS() + ROOT_STANDARD_LIBRARY_PACKAGE(ASImageGui + NO_GLOB_HEADERS + HEADERS + TASPaletteEditor.h + SOURCES + TASPaletteEditor.cxx + LINKDEF + LinkDefGui.h + DICTIONARY_OPTIONS + -writeEmptyRootPCM + LIBRARIES + libAfterImage + DEPENDENCIES + Gui + ASImage + ) -if(asimage) ROOT_ADD_TEST_SUBDIRECTORY(test) + +else() + target_compile_definitions(ASImageUtils PRIVATE NO_ASIMAGE) endif()