Mercurial > hg > orthanc-stone
diff Framework/Viewport/SdlViewport.cpp @ 1331:ab81ee8fce1f broker
- Viewport is not passed and stored as a shared_ptr instead
of raw reference.
- ViewportController can now be injected with an undo
stack (not a ctor param anymore, as a preparation for the
move of the undo stack to an interactor)
- Added (temp) flag to disable emscripten events registration
in the WebAssemblyViewport (because legacy client code
deals with them directly)
- Added emscripten_clear_timeout in ~WebGLViewportsRegistry
- Removed GenericToolbox::HoldingRef whose responsibility is
better served with proper callback un-registration.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 30 Mar 2020 14:23:46 +0200 |
parents | 1a08b779be64 |
children | be614695747d |
line wrap: on
line diff
--- a/Framework/Viewport/SdlViewport.cpp Mon Mar 30 08:47:30 2020 +0200 +++ b/Framework/Viewport/SdlViewport.cpp Mon Mar 30 14:23:46 2020 +0200 @@ -22,6 +22,8 @@ #include <Core/OrthancException.h> +#include <boost/make_shared.hpp> + namespace OrthancStone { ICompositor& SdlViewport::SdlLock::GetCompositor() @@ -48,8 +50,7 @@ compositor_.reset(compositor); } - SdlViewport::SdlViewport() : - controller_(new ViewportController(*this)) + SdlViewport::SdlViewport() { refreshEvent_ = SDL_RegisterEvents(1); @@ -58,18 +59,12 @@ throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); } } - - SdlViewport::SdlViewport(boost::weak_ptr<UndoStack> undoStackW) : - controller_(new ViewportController(*this,undoStackW)) + + void SdlViewport::PostConstructor() { - refreshEvent_ = SDL_RegisterEvents(1); - - if (refreshEvent_ == static_cast<uint32_t>(-1)) - { - throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); - } + controller_ = boost::make_shared<ViewportController>(shared_from_this()); } - + void SdlViewport::SendRefreshEvent() { SDL_Event event; @@ -88,15 +83,15 @@ AcquireCompositor(new OpenGLCompositor(context_)); // (*) } - SdlOpenGLViewport::SdlOpenGLViewport(const char* title, - boost::weak_ptr<UndoStack> undoStackW, - unsigned int width, - unsigned int height, - bool allowDpiScaling) : - SdlViewport(undoStackW), - context_(title, width, height, allowDpiScaling) + boost::shared_ptr<SdlOpenGLViewport> SdlOpenGLViewport::Create(const char* title, + unsigned int width, + unsigned int height, + bool allowDpiScaling) { - AcquireCompositor(new OpenGLCompositor(context_)); // (*) + boost::shared_ptr<SdlOpenGLViewport> that = + boost::shared_ptr<SdlOpenGLViewport>(new SdlOpenGLViewport(title, width, height, allowDpiScaling)); + that->SdlViewport::PostConstructor(); + return that; } SdlOpenGLViewport::~SdlOpenGLViewport()