diff Framework/Viewport/SdlViewport.cpp @ 1307:8a28a9bf8876 broker

ViewportController now gets a ref to its parent viewport for proper lock usage
author Benjamin Golinvaux <bgo@osimis.io>
date Wed, 04 Mar 2020 10:07:37 +0100
parents 7ec8fea061b9
children 3d26447ddd28
line wrap: on
line diff
--- a/Framework/Viewport/SdlViewport.cpp	Wed Mar 04 10:07:14 2020 +0100
+++ b/Framework/Viewport/SdlViewport.cpp	Wed Mar 04 10:07:37 2020 +0100
@@ -48,18 +48,27 @@
     compositor_.reset(compositor);
   }
 
-
   SdlViewport::SdlViewport() :
-    controller_(new ViewportController)
+    controller_(new ViewportController(*this))
   {
     refreshEvent_ = SDL_RegisterEvents(1);
-    
+
     if (refreshEvent_ == static_cast<uint32_t>(-1))
     {
       throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
     }
   }
 
+  SdlViewport::SdlViewport(boost::weak_ptr<UndoStack> undoStackW) :
+    controller_(new ViewportController(*this,undoStackW))
+  {
+    refreshEvent_ = SDL_RegisterEvents(1);
+
+    if (refreshEvent_ == static_cast<uint32_t>(-1))
+    {
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
+    }
+  }
 
   void SdlViewport::SendRefreshEvent()
   {
@@ -79,6 +88,16 @@
     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)
+  {
+    AcquireCompositor(new OpenGLCompositor(context_));  // (*)
+  }
 
   SdlOpenGLViewport::~SdlOpenGLViewport()
   {