Mercurial > hg > orthanc-stone
changeset 1055:af456106576c
moving GetCanvasIdentifier from IViewport to WebAssemblyViewport
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 10 Oct 2019 16:07:58 +0200 |
parents | 3c9529edf5fd |
children | 28deed30afa8 5df50e0f0390 |
files | Framework/Viewport/IViewport.h Framework/Viewport/SdlViewport.cpp Framework/Viewport/SdlViewport.h Framework/Viewport/ViewportBase.cpp Framework/Viewport/ViewportBase.h Framework/Viewport/WebAssemblyViewport.h |
diffstat | 6 files changed, 24 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- 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;
--- 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<Scene2D>& 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) {
--- 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<Scene2D>& scene) - : ViewportBase(identifier, scene) + SdlViewport(boost::shared_ptr<Scene2D>& scene) : + ViewportBase(scene) { }
--- 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<Scene2D>()) { } - ViewportBase::ViewportBase(const std::string& identifier, - boost::shared_ptr<Scene2D>& scene) : - identifier_(identifier), + ViewportBase::ViewportBase(boost::shared_ptr<Scene2D>& scene) : scene_(scene) { if (scene.get() == NULL)
--- 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<Scene2D> scene_; public: - ViewportBase(const std::string& identifier); + ViewportBase(); - ViewportBase(const std::string& identifier, - boost::shared_ptr<Scene2D>& scene); + ViewportBase(boost::shared_ptr<Scene2D>& 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; }; }
--- 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<Scene2D>& scene) - : ViewportBase(identifier, scene) + WebAssemblyViewport(const std::string& canvasIdentifier, + boost::shared_ptr<Scene2D>& 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: