# HG changeset patch # User Alain Mazy # Date 1555572600 -7200 # Node ID 1201b12eb9f85d6b576625f5bacee9282b0b6c95 # Parent d5579bdc59b50930e671b4b5b4a8ffeeccbe53de# Parent aaeec7be8fb7865f21e5e13be2c696bb7a1660e8 merge default -> dev diff -r d5579bdc59b5 -r 1201b12eb9f8 Applications/Sdl/SdlCairoSurface.cpp --- a/Applications/Sdl/SdlCairoSurface.cpp Wed Apr 17 16:13:42 2019 +0200 +++ b/Applications/Sdl/SdlCairoSurface.cpp Thu Apr 18 09:30:00 2019 +0200 @@ -51,7 +51,7 @@ cairoSurface_->GetWidth() != width || cairoSurface_->GetHeight() != height) { - cairoSurface_.reset(new CairoSurface(width, height)); + cairoSurface_.reset(new CairoSurface(width, height, false /* no alpha */)); // TODO Big endian? static const uint32_t rmask = 0x00ff0000; diff -r d5579bdc59b5 -r 1201b12eb9f8 Applications/Sdl/SdlWindow.h --- a/Applications/Sdl/SdlWindow.h Wed Apr 17 16:13:42 2019 +0200 +++ b/Applications/Sdl/SdlWindow.h Thu Apr 18 09:30:00 2019 +0200 @@ -44,6 +44,11 @@ ~SdlWindow(); + SDL_Window *GetObject() const + { + return window_; + } + unsigned int GetWidth() const; unsigned int GetHeight() const; diff -r d5579bdc59b5 -r 1201b12eb9f8 Applications/StoneApplicationContext.h --- a/Applications/StoneApplicationContext.h Wed Apr 17 16:13:42 2019 +0200 +++ b/Applications/StoneApplicationContext.h Thu Apr 18 09:30:00 2019 +0200 @@ -27,24 +27,7 @@ #include "../Framework/Viewport/WidgetViewport.h" -#ifdef _MSC_VER - #if _MSC_VER > 1910 - #define orthanc_override override #else - #define orthanc_override - #endif -#elif defined __GNUC__ - #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) -/* Test for GCC > 3.2.0 */ - #if GCC_VERSION > 40900 - #define orthanc_override override - #else - #define orthanc_override - #endif -#else - #define orthanc_override -#endif - #include namespace OrthancStone diff -r d5579bdc59b5 -r 1201b12eb9f8 Framework/Layers/ColorFrameRenderer.cpp --- a/Framework/Layers/ColorFrameRenderer.cpp Wed Apr 17 16:13:42 2019 +0200 +++ b/Framework/Layers/ColorFrameRenderer.cpp Thu Apr 18 09:30:00 2019 +0200 @@ -29,7 +29,7 @@ { CairoSurface* ColorFrameRenderer::GenerateDisplay(const RenderStyle& style) { - std::auto_ptr display(new CairoSurface(frame_->GetWidth(), frame_->GetHeight())); + std::auto_ptr display(new CairoSurface(frame_->GetWidth(), frame_->GetHeight(), false /* no alpha */)); Orthanc::ImageAccessor target; display->GetWriteableAccessor(target); diff -r d5579bdc59b5 -r 1201b12eb9f8 Framework/Layers/GrayscaleFrameRenderer.cpp --- a/Framework/Layers/GrayscaleFrameRenderer.cpp Wed Apr 17 16:13:42 2019 +0200 +++ b/Framework/Layers/GrayscaleFrameRenderer.cpp Thu Apr 18 09:30:00 2019 +0200 @@ -41,7 +41,7 @@ //LOG(INFO) << "Window: " << x0 << " => " << x1; - result.reset(new CairoSurface(frame_->GetWidth(), frame_->GetHeight())); + result.reset(new CairoSurface(frame_->GetWidth(), frame_->GetHeight(), false /* no alpha */)); const uint8_t* lut = NULL; if (style.applyLut_) diff -r d5579bdc59b5 -r 1201b12eb9f8 Framework/Radiography/RadiographyWidget.cpp --- a/Framework/Radiography/RadiographyWidget.cpp Wed Apr 17 16:13:42 2019 +0200 +++ b/Framework/Radiography/RadiographyWidget.cpp Thu Apr 18 09:30:00 2019 +0200 @@ -94,7 +94,7 @@ cairoBuffer_->GetWidth() != width || cairoBuffer_->GetHeight() != height) { - cairoBuffer_.reset(new CairoSurface(width, height)); + cairoBuffer_.reset(new CairoSurface(width, height, false /* no alpha */)); } RenderBackground(*floatBuffer_, x0, x1); diff -r d5579bdc59b5 -r 1201b12eb9f8 Framework/StoneEnumerations.cpp --- a/Framework/StoneEnumerations.cpp Wed Apr 17 16:13:42 2019 +0200 +++ b/Framework/StoneEnumerations.cpp Thu Apr 18 09:30:00 2019 +0200 @@ -78,7 +78,8 @@ double& deltaY, BitmapAnchor anchor, unsigned int bitmapWidth, - unsigned int bitmapHeight) + unsigned int bitmapHeight, + unsigned int border) { double dw = static_cast(bitmapWidth); double dh = static_cast(bitmapHeight); @@ -133,5 +134,46 @@ default: throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); } + + if (border != 0) + { + double b = static_cast(border); + + switch (anchor) + { + case BitmapAnchor_TopLeft: + case BitmapAnchor_TopCenter: + case BitmapAnchor_TopRight: + deltaY += b; + break; + + case BitmapAnchor_BottomLeft: + case BitmapAnchor_BottomCenter: + case BitmapAnchor_BottomRight: + deltaY -= b; + break; + + default: + break; + } + + switch (anchor) + { + case BitmapAnchor_TopLeft: + case BitmapAnchor_CenterLeft: + case BitmapAnchor_BottomLeft: + deltaX += b; + break; + + case BitmapAnchor_CenterRight: + case BitmapAnchor_TopRight: + case BitmapAnchor_BottomRight: + deltaX -= b; + break; + + default: + break; + } + } } } diff -r d5579bdc59b5 -r 1201b12eb9f8 Framework/StoneEnumerations.h --- a/Framework/StoneEnumerations.h Wed Apr 17 16:13:42 2019 +0200 +++ b/Framework/StoneEnumerations.h Thu Apr 18 09:30:00 2019 +0200 @@ -206,5 +206,6 @@ double& deltaY /* out */, BitmapAnchor anchor, unsigned int bitmapWidth, - unsigned int bitmapHeight); + unsigned int bitmapHeight, + unsigned int border = 0); } diff -r d5579bdc59b5 -r 1201b12eb9f8 Framework/Viewport/CairoSurface.cpp --- a/Framework/Viewport/CairoSurface.cpp Wed Apr 17 16:13:42 2019 +0200 +++ b/Framework/Viewport/CairoSurface.cpp Thu Apr 18 09:30:00 2019 +0200 @@ -38,11 +38,15 @@ void CairoSurface::Allocate(unsigned int width, - unsigned int height) + unsigned int height, + bool hasAlpha) { Release(); - surface_ = cairo_image_surface_create(CAIRO_FORMAT_RGB24, width, height); + hasAlpha_ = hasAlpha; + + surface_ = cairo_image_surface_create + (hasAlpha ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24, width, height); if (!surface_) { // Should never occur @@ -63,7 +67,9 @@ } - CairoSurface::CairoSurface(Orthanc::ImageAccessor& accessor) + CairoSurface::CairoSurface(Orthanc::ImageAccessor& accessor, + bool hasAlpha) : + hasAlpha_(hasAlpha) { if (accessor.GetFormat() != Orthanc::PixelFormat_BGRA32) { @@ -76,7 +82,9 @@ buffer_ = accessor.GetBuffer(); surface_ = cairo_image_surface_create_for_data - (reinterpret_cast(buffer_), CAIRO_FORMAT_RGB24, width_, height_, pitch_); + (reinterpret_cast(buffer_), + hasAlpha_ ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24, + width_, height_, pitch_); if (!surface_) { // Should never occur @@ -93,24 +101,44 @@ void CairoSurface::SetSize(unsigned int width, - unsigned int height) + unsigned int height, + bool hasAlpha) { - if (width_ != width || + if (hasAlpha_ != hasAlpha || + width_ != width || height_ != height) { - Allocate(width, height); + Allocate(width, height, hasAlpha); } } void CairoSurface::Copy(const CairoSurface& other) { + SetSize(other.GetWidth(), other.GetHeight(), other.HasAlpha()); + Orthanc::ImageAccessor source, target; other.GetReadOnlyAccessor(source); GetWriteableAccessor(target); Orthanc::ImageProcessing::Copy(target, source); + + cairo_surface_mark_dirty(surface_); + } + + + void CairoSurface::Copy(const Orthanc::ImageAccessor& source, + bool hasAlpha) + { + SetSize(source.GetWidth(), source.GetHeight(), hasAlpha); + + Orthanc::ImageAccessor target; + GetWriteableAccessor(target); + + Orthanc::ImageProcessing::Convert(target, source); + + cairo_surface_mark_dirty(surface_); } diff -r d5579bdc59b5 -r 1201b12eb9f8 Framework/Viewport/CairoSurface.h --- a/Framework/Viewport/CairoSurface.h Wed Apr 17 16:13:42 2019 +0200 +++ b/Framework/Viewport/CairoSurface.h Thu Apr 18 09:30:00 2019 +0200 @@ -36,27 +36,31 @@ unsigned int height_; unsigned int pitch_; void* buffer_; + bool hasAlpha_; void Release(); void Allocate(unsigned int width, - unsigned int height); + unsigned int height, + bool hasAlpha); public: CairoSurface() : surface_(NULL) { - Allocate(0, 0); + Allocate(0, 0, false); } CairoSurface(unsigned int width, - unsigned int height) : + unsigned int height, + bool hasAlpha) : surface_(NULL) { - Allocate(width, height); + Allocate(width, height, hasAlpha); } - CairoSurface(Orthanc::ImageAccessor& accessor); + CairoSurface(Orthanc::ImageAccessor& accessor, + bool hasAlpha); ~CairoSurface() { @@ -64,10 +68,14 @@ } void SetSize(unsigned int width, - unsigned int height); + unsigned int height, + bool hasAlpha); void Copy(const CairoSurface& other); + void Copy(const Orthanc::ImageAccessor& source, + bool hasAlpha); + unsigned int GetWidth() const { return width_; @@ -98,6 +106,11 @@ return surface_; } + bool HasAlpha() const + { + return hasAlpha_; + } + void GetReadOnlyAccessor(Orthanc::ImageAccessor& target) const; void GetWriteableAccessor(Orthanc::ImageAccessor& target); diff -r d5579bdc59b5 -r 1201b12eb9f8 Framework/Viewport/WidgetViewport.cpp --- a/Framework/Viewport/WidgetViewport.cpp Wed Apr 17 16:13:42 2019 +0200 +++ b/Framework/Viewport/WidgetViewport.cpp Thu Apr 18 09:30:00 2019 +0200 @@ -90,7 +90,7 @@ void WidgetViewport::SetSize(unsigned int width, unsigned int height) { - background_.SetSize(width, height); + background_.SetSize(width, height, false /* no alpha */); if (centralWidget_.get() != NULL) { diff -r d5579bdc59b5 -r 1201b12eb9f8 Framework/Widgets/CairoWidget.cpp --- a/Framework/Widgets/CairoWidget.cpp Wed Apr 17 16:13:42 2019 +0200 +++ b/Framework/Widgets/CairoWidget.cpp Thu Apr 18 09:30:00 2019 +0200 @@ -40,7 +40,7 @@ void CairoWidget::SetSize(unsigned int width, unsigned int height) { - surface_.SetSize(width, height); + surface_.SetSize(width, height, false /* no alpha */); } @@ -51,7 +51,7 @@ if (IsAligned(target)) { - CairoSurface surface(target); + CairoSurface surface(target, false /* no alpha */); CairoContext context(surface); ClearBackgroundCairo(context); return RenderCairo(context); @@ -82,7 +82,7 @@ { if (IsAligned(target)) { - CairoSurface surface(target); + CairoSurface surface(target, false /* no alpha */); CairoContext context(surface); RenderMouseOverCairo(context, x, y); } diff -r d5579bdc59b5 -r 1201b12eb9f8 Framework/Widgets/WidgetBase.cpp --- a/Framework/Widgets/WidgetBase.cpp Wed Apr 17 16:13:42 2019 +0200 +++ b/Framework/Widgets/WidgetBase.cpp Thu Apr 18 09:30:00 2019 +0200 @@ -86,7 +86,7 @@ void WidgetBase::ClearBackgroundCairo(Orthanc::ImageAccessor& target) const { - CairoSurface surface(target); + CairoSurface surface(target, false /* no alpha */); CairoContext context(surface); ClearBackgroundCairo(context); } diff -r d5579bdc59b5 -r 1201b12eb9f8 Framework/Widgets/WorldSceneWidget.cpp --- a/Framework/Widgets/WorldSceneWidget.cpp Wed Apr 17 16:13:42 2019 +0200 +++ b/Framework/Widgets/WorldSceneWidget.cpp Thu Apr 18 09:30:00 2019 +0200 @@ -60,7 +60,7 @@ { if (tracker_->HasRender()) { - CairoSurface surface(target); + CairoSurface surface(target, false /* no alpha */); CairoContext context(surface); view_.ApplyTransform(context); tracker_->Render(context, view_.GetZoom()); diff -r d5579bdc59b5 -r 1201b12eb9f8 Resources/CMake/OrthancStoneConfiguration.cmake --- a/Resources/CMake/OrthancStoneConfiguration.cmake Wed Apr 17 16:13:42 2019 +0200 +++ b/Resources/CMake/OrthancStoneConfiguration.cmake Thu Apr 18 09:30:00 2019 +0200 @@ -25,7 +25,9 @@ if (ENABLE_DCMTK) set(ENABLE_LOCALE ON) else() - set(ENABLE_LOCALE OFF) # Disable support for locales (notably in Boost) + if (NOT DEFINED ENABLE_LOCALE) + set(ENABLE_LOCALE OFF) # Disable support for locales (notably in Boost) + endif() endif() include(${ORTHANC_ROOT}/Resources/CMake/OrthancFrameworkConfiguration.cmake) @@ -141,10 +143,12 @@ COLORMAP_RED ${ORTHANC_STONE_ROOT}/Resources/Colormaps/red.lut COLORMAP_GREEN ${ORTHANC_STONE_ROOT}/Resources/Colormaps/green.lut COLORMAP_BLUE ${ORTHANC_STONE_ROOT}/Resources/Colormaps/blue.lut + + # Additional resources specific to the application being built + ${ORTHANC_STONE_APPLICATION_RESOURCES} ) - ##################################################################### ## System-specific patches ##################################################################### diff -r d5579bdc59b5 -r 1201b12eb9f8 UnitTestsSources/TestMessageBroker.cpp --- a/UnitTestsSources/TestMessageBroker.cpp Wed Apr 17 16:13:42 2019 +0200 +++ b/UnitTestsSources/TestMessageBroker.cpp Thu Apr 18 09:30:00 2019 +0200 @@ -312,7 +312,7 @@ ASSERT_EQ(0, testCounter); } -#if 0 //__cplusplus >= 201103L +#if 0 /* __cplusplus >= 201103L*/ TEST(MessageBroker, TestLambdaSimpleUseCase) {