diff Framework/Viewport/ViewportBase.h @ 947:1091b2adeb5a toa2019081001

Fixed animation frame stopping when returning false + big work on the OpenGL objects to make them lost context-safe + debug code to forcefully tag a context as lost + debug macros
author Benjamin Golinvaux <bgo@osimis.io>
date Sat, 10 Aug 2019 13:07:31 +0200
parents 685c9a2d115f
children a7351ad54960
line wrap: on
line diff
--- a/Framework/Viewport/ViewportBase.h	Tue Aug 06 15:07:23 2019 +0200
+++ b/Framework/Viewport/ViewportBase.h	Sat Aug 10 13:07:31 2019 +0200
@@ -28,10 +28,6 @@
 {
   class ViewportBase : public IViewport
   {
-  private:
-    std::string                 identifier_;
-    boost::shared_ptr<Scene2D>  scene_;
-
   public:
     ViewportBase(const std::string& identifier);
 
@@ -50,19 +46,20 @@
 
     virtual ScenePoint2D GetPixelCenterCoordinates(int x, int y) const ORTHANC_OVERRIDE;
 
-    virtual void Refresh() ORTHANC_OVERRIDE
-    {
-      GetCompositor().Refresh();
-    }
-
     virtual unsigned int GetCanvasWidth() const ORTHANC_OVERRIDE
     {
-      return GetCompositor().GetCanvasWidth();
+      if (GetCompositor())
+        return GetCompositor()->GetCanvasWidth();
+      else
+        return 0;
     }
 
     virtual unsigned int GetCanvasHeight() const ORTHANC_OVERRIDE
     {
-      return GetCompositor().GetCanvasHeight();
+      if (GetCompositor())
+        return GetCompositor()->GetCanvasHeight();
+      else
+        return 0;
     }
 
 #if ORTHANC_ENABLE_LOCALE == 1
@@ -71,8 +68,15 @@
       unsigned int fontSize,
       Orthanc::Encoding codepage) ORTHANC_OVERRIDE
     {
-      return GetCompositor().SetFont(index, resource, fontSize, codepage);
+      return GetCompositor()->SetFont(index, resource, fontSize, codepage);
     }
 #endif
+
+  private:
+    std::string                 identifier_;
+    boost::shared_ptr<Scene2D>  scene_;
+  protected:
+    virtual void RestoreCompositor() = 0;
+    virtual void DisableCompositor() = 0;
   };
 }