# HG changeset patch # User Sebastien Jodogne # Date 1570716478 -7200 # Node ID af456106576c5e551c6f7b508bc60bbdaba8e7d5 # Parent 3c9529edf5fdc9ec14f2adc0372c3eb99d363e26 moving GetCanvasIdentifier from IViewport to WebAssemblyViewport diff -r 3c9529edf5fd -r af456106576c Framework/Viewport/IViewport.h --- a/Framework/Viewport/IViewport.h Thu Oct 10 15:55:54 2019 +0200 +++ b/Framework/Viewport/IViewport.h Thu Oct 10 16:07:58 2019 +0200 @@ -42,9 +42,6 @@ virtual void Refresh() = 0; - // TODO - Is this needed at this level (e.g. for SDL)? - virtual const std::string& GetCanvasIdentifier() const = 0; - virtual ScenePoint2D GetPixelCenterCoordinates(int x, int y) = 0; virtual bool HasCompositor() const = 0; diff -r 3c9529edf5fd -r af456106576c Framework/Viewport/SdlViewport.cpp --- a/Framework/Viewport/SdlViewport.cpp Thu Oct 10 15:55:54 2019 +0200 +++ b/Framework/Viewport/SdlViewport.cpp Thu Oct 10 16:07:58 2019 +0200 @@ -30,7 +30,6 @@ unsigned int width, unsigned int height, bool allowDpiScaling) : - SdlViewport(title), context_(title, width, height, allowDpiScaling) { compositor_.reset(new OpenGLCompositor(context_, GetScene())); @@ -41,7 +40,7 @@ unsigned int height, boost::shared_ptr& scene, bool allowDpiScaling) : - SdlViewport(title, scene), + SdlViewport(scene), context_(title, width, height, allowDpiScaling) { compositor_.reset(new OpenGLCompositor(context_, GetScene())); @@ -57,7 +56,6 @@ unsigned int width, unsigned int height, bool allowDpiScaling) : - SdlViewport(title), window_(title, width, height, false /* enable OpenGL */, allowDpiScaling), compositor_(GetScene(), width, height) { diff -r 3c9529edf5fd -r af456106576c Framework/Viewport/SdlViewport.h --- a/Framework/Viewport/SdlViewport.h Thu Oct 10 15:55:54 2019 +0200 +++ b/Framework/Viewport/SdlViewport.h Thu Oct 10 16:07:58 2019 +0200 @@ -46,14 +46,12 @@ class SdlViewport : public ViewportBase { public: - SdlViewport(const std::string& identifier) - : ViewportBase(identifier) + SdlViewport() { } - SdlViewport(const std::string& identifier, - boost::shared_ptr& scene) - : ViewportBase(identifier, scene) + SdlViewport(boost::shared_ptr& scene) : + ViewportBase(scene) { } diff -r 3c9529edf5fd -r af456106576c Framework/Viewport/ViewportBase.cpp --- a/Framework/Viewport/ViewportBase.cpp Thu Oct 10 15:55:54 2019 +0200 +++ b/Framework/Viewport/ViewportBase.cpp Thu Oct 10 16:07:58 2019 +0200 @@ -26,16 +26,13 @@ namespace OrthancStone { - ViewportBase::ViewportBase(const std::string& identifier) : - identifier_(identifier), + ViewportBase::ViewportBase() : scene_(boost::make_shared()) { } - ViewportBase::ViewportBase(const std::string& identifier, - boost::shared_ptr& scene) : - identifier_(identifier), + ViewportBase::ViewportBase(boost::shared_ptr& scene) : scene_(scene) { if (scene.get() == NULL) diff -r 3c9529edf5fd -r af456106576c Framework/Viewport/ViewportBase.h --- a/Framework/Viewport/ViewportBase.h Thu Oct 10 15:55:54 2019 +0200 +++ b/Framework/Viewport/ViewportBase.h Thu Oct 10 16:07:58 2019 +0200 @@ -29,25 +29,18 @@ class ViewportBase : public IViewport { private: - std::string identifier_; boost::shared_ptr scene_; public: - ViewportBase(const std::string& identifier); + ViewportBase(); - ViewportBase(const std::string& identifier, - boost::shared_ptr& scene); + ViewportBase(boost::shared_ptr& scene); virtual Scene2D& GetScene() ORTHANC_OVERRIDE { return *scene_; } - virtual const std::string& GetCanvasIdentifier() const ORTHANC_OVERRIDE - { - return identifier_; - } - virtual ScenePoint2D GetPixelCenterCoordinates(int x, int y) ORTHANC_OVERRIDE; }; } diff -r 3c9529edf5fd -r af456106576c Framework/Viewport/WebAssemblyViewport.h --- a/Framework/Viewport/WebAssemblyViewport.h Thu Oct 10 15:55:54 2019 +0200 +++ b/Framework/Viewport/WebAssemblyViewport.h Thu Oct 10 16:07:58 2019 +0200 @@ -30,19 +30,29 @@ { class WebAssemblyViewport : public ViewportBase { + private: + std::string canvasIdentifier_; + public: - WebAssemblyViewport(const std::string& identifier) - : ViewportBase(identifier) + WebAssemblyViewport(const std::string& canvasIdentifier) : + canvasIdentifier_(canvasIdentifier) { } - WebAssemblyViewport(const std::string& identifier, - boost::shared_ptr& scene) - : ViewportBase(identifier, scene) + WebAssemblyViewport(const std::string& canvasIdentifier, + boost::shared_ptr& scene) : + ViewportBase(scene), + canvasIdentifier_(canvasIdentifier) { } + + const std::string& GetCanvasIdentifier() const + { + return canvasIdentifier_; + } }; + class WebAssemblyOpenGLViewport : public WebAssemblyViewport { private: @@ -81,6 +91,7 @@ void RegisterContextCallbacks(); }; + class WebAssemblyCairoViewport : public WebAssemblyViewport { private: