# HG changeset patch # User Sebastien Jodogne # Date 1597349113 -7200 # Node ID c54bc5bffd01b2ad09403dc74ca4608b983bfd04 # Parent 012ab2c1f23b34119af14b1b39438fde59de9ff4 software rendering diff -r 012ab2c1f23b -r c54bc5bffd01 Applications/StoneWebViewer/WebAssembly/StoneModule/CMakeLists.txt --- a/Applications/StoneWebViewer/WebAssembly/StoneModule/CMakeLists.txt Thu Aug 13 21:00:55 2020 +0200 +++ b/Applications/StoneWebViewer/WebAssembly/StoneModule/CMakeLists.txt Thu Aug 13 22:05:13 2020 +0200 @@ -51,6 +51,7 @@ include_directories( ${ORTHANC_STONE_MODULE_PREFIX}/include + ${ORTHANC_STONE_MODULE_PREFIX}/include/cairo ${ORTHANC_STONE_MODULE_PREFIX}/include/orthanc-framework ${ORTHANC_STONE_MODULE_PREFIX}/include/orthanc-stone ) diff -r 012ab2c1f23b -r c54bc5bffd01 Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp --- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Thu Aug 13 21:00:55 2020 +0200 +++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Thu Aug 13 22:05:13 2020 +0200 @@ -79,6 +79,7 @@ #include #include #include +#include #include #include @@ -1222,7 +1223,7 @@ std::unique_ptr observer_; OrthancStone::ILoadersContext& context_; - boost::shared_ptr viewport_; + boost::shared_ptr viewport_; boost::shared_ptr loader_; OrthancStone::DicomSource source_; boost::shared_ptr cache_; @@ -1525,6 +1526,7 @@ context_(context), source_(source), viewport_(OrthancStone::WebGLViewport::Create(canvas)), + //viewport_(OrthancStone::WebAssemblyCairoViewport::Create(canvas)), cache_(cache), fitNextContent_(true), isCtrlDown_(false) diff -r 012ab2c1f23b -r c54bc5bffd01 OrthancStone/SharedLibrary/WebAssembly/CMakeLists.txt --- a/OrthancStone/SharedLibrary/WebAssembly/CMakeLists.txt Thu Aug 13 21:00:55 2020 +0200 +++ b/OrthancStone/SharedLibrary/WebAssembly/CMakeLists.txt Thu Aug 13 22:05:13 2020 +0200 @@ -64,6 +64,7 @@ set(SOURCES_WITH_EMSCRIPTEN_CALLBACKS ${ORTHANC_STONE_ROOT}/Sources/Oracle/WebAssemblyOracle.cpp ${ORTHANC_STONE_ROOT}/Sources/Viewport/WebAssemblyViewport.cpp + ${ORTHANC_STONE_ROOT}/Sources/Viewport/WebAssemblyCairoViewport.cpp ) list(REMOVE_ITEM ORTHANC_STONE_SOURCES @@ -139,6 +140,14 @@ PATTERN "*.h" ) +file( + COPY ${CAIRO_SOURCES_DIR}/src/ + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Include/cairo/ + NO_SOURCE_PERMISSIONS + FILES_MATCHING + PATTERN "*.h" + ) + set(DCMTK_MODULES dcmdata config @@ -170,6 +179,7 @@ install( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Include/boost + ${CMAKE_CURRENT_BINARY_DIR}/Include/cairo ${CMAKE_CURRENT_BINARY_DIR}/Include/dcmtk ${CMAKE_CURRENT_BINARY_DIR}/Include/json ${CMAKE_CURRENT_BINARY_DIR}/Include/orthanc-framework diff -r 012ab2c1f23b -r c54bc5bffd01 OrthancStone/Sources/Viewport/WebAssemblyCairoViewport.cpp --- a/OrthancStone/Sources/Viewport/WebAssemblyCairoViewport.cpp Thu Aug 13 21:00:55 2020 +0200 +++ b/OrthancStone/Sources/Viewport/WebAssemblyCairoViewport.cpp Thu Aug 13 22:05:13 2020 +0200 @@ -19,9 +19,15 @@ **/ -#include "WebAssemblyCairoViewport.h" - -#include "../Scene2D/CairoCompositor.h" +#if defined(ORTHANC_BUILDING_STONE_LIBRARY) && ORTHANC_BUILDING_STONE_LIBRARY == 1 +# include "WebAssemblyCairoViewport.h" +# include "../Scene2D/CairoCompositor.h" +#else +// This is the case when using the WebAssembly side module, and this +// source file must be compiled within the WebAssembly main module +# include +# include +#endif #include @@ -124,16 +130,25 @@ } - WebAssemblyCairoViewport::WebAssemblyCairoViewport( - const std::string& canvasId) : - WebAssemblyViewport(canvasId) + WebAssemblyCairoViewport::WebAssemblyCairoViewport(const std::string& canvasId, + bool enableEmscriptenMouseEvents) : + WebAssemblyViewport(canvasId,enableEmscriptenMouseEvents) { unsigned int width, height; GetCanvasSize(width, height); - emscripten_set_canvas_element_size(GetCanvasCssSelector().c_str(), - width, - height); + emscripten_set_canvas_element_size(GetCanvasCssSelector().c_str(), width, height); AcquireCompositor(new CairoCompositor(width, height)); } + + + boost::shared_ptr WebAssemblyCairoViewport::Create( + const std::string& canvasId, bool enableEmscriptenMouseEvents) + { + boost::shared_ptr that = boost::shared_ptr( + new WebAssemblyCairoViewport(canvasId, enableEmscriptenMouseEvents)); + + that->WebAssemblyViewport::PostConstructor(); + return that; + } } diff -r 012ab2c1f23b -r c54bc5bffd01 OrthancStone/Sources/Viewport/WebAssemblyCairoViewport.h --- a/OrthancStone/Sources/Viewport/WebAssemblyCairoViewport.h Thu Aug 13 21:00:55 2020 +0200 +++ b/OrthancStone/Sources/Viewport/WebAssemblyCairoViewport.h Thu Aug 13 22:05:13 2020 +0200 @@ -33,6 +33,9 @@ void GetCanvasSize(unsigned int& width, unsigned int& height); + WebAssemblyCairoViewport(const std::string& canvasId, + bool enableEmscriptenMouseEvents); + protected: virtual void Paint(ICompositor& compositor, ViewportController& controller) ORTHANC_OVERRIDE; @@ -40,7 +43,8 @@ virtual void UpdateSize(ICompositor& compositor) ORTHANC_OVERRIDE; public: - WebAssemblyCairoViewport(const std::string& canvasId); + static boost::shared_ptr Create(const std::string& canvasId, + bool enableEmscriptenMouseEvents = true); virtual ~WebAssemblyCairoViewport() { diff -r 012ab2c1f23b -r c54bc5bffd01 OrthancStone/Sources/Viewport/WebGLViewport.h --- a/OrthancStone/Sources/Viewport/WebGLViewport.h Thu Aug 13 21:00:55 2020 +0200 +++ b/OrthancStone/Sources/Viewport/WebGLViewport.h Thu Aug 13 22:05:13 2020 +0200 @@ -31,7 +31,8 @@ private: OpenGL::WebAssemblyOpenGLContext context_; - WebGLViewport(const std::string& canvasId, bool enableEmscriptenMouseEvents); + WebGLViewport(const std::string& canvasId, + bool enableEmscriptenMouseEvents); protected: virtual void Paint(ICompositor& compositor, @@ -43,7 +44,8 @@ } public: - static boost::shared_ptr Create(const std::string& canvasId, bool enableEmscriptenMouseEvents = true); + static boost::shared_ptr Create(const std::string& canvasId, + bool enableEmscriptenMouseEvents = true); virtual ~WebGLViewport();