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..a0e3ea33e25ca 100644 --- a/graf2d/asimage/CMakeLists.txt +++ b/graf2d/asimage/CMakeLists.txt @@ -7,35 +7,40 @@ ############################################################################ # 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_GLOB_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() -if (x11) - target_link_libraries(ASImage PRIVATE X11::X11) endif() ROOT_STANDARD_LIBRARY_PACKAGE(ASImageUtils - NO_INSTALL_HEADERS + NO_GLOB_HEADERS HEADERS TASUtils.h SOURCES @@ -44,30 +49,36 @@ 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 -) -ROOT_INSTALL_HEADERS() +if(asimage) -ROOT_ADD_TEST_SUBDIRECTORY(test) + target_link_libraries(ASImageUtils PRIVATE libAfterImage) + + target_link_libraries(ASImageUtils PUBLIC ASImage) + + 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 + ) + + ROOT_ADD_TEST_SUBDIRECTORY(test) + +else() + target_compile_definitions(ASImageUtils PRIVATE NO_ASIMAGE) +endif() 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 dd01c8d3a9e76..1e6014122efc9 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" @@ -250,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; @@ -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 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) {} 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.