changeset 1483:6abd819aa534

moving edge case from WebGLViewport::UpdateSize() to WebAssemblyOpenGLContext::RefreshCanvasSize()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 20 Jun 2020 11:16:55 +0200
parents 5c96bf3f1d32
children 121d01aa328e
files Framework/OpenGL/WebAssemblyOpenGLContext.cpp Framework/Viewport/WebGLViewport.cpp Framework/Viewport/WebGLViewport.h
diffstat 3 files changed, 21 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/OpenGL/WebAssemblyOpenGLContext.cpp	Sat Jun 20 11:08:28 2020 +0200
+++ b/Framework/OpenGL/WebAssemblyOpenGLContext.cpp	Sat Jun 20 11:16:55 2020 +0200
@@ -243,7 +243,23 @@
     void WebAssemblyOpenGLContext::RefreshCanvasSize()
     {
       assert(pimpl_.get() != NULL);
-      pimpl_->UpdateSize();
+
+      try
+      {
+        pimpl_->UpdateSize();
+      }
+      catch (const StoneException& e)
+      {
+        // Ignore problems about the loss of the WebGL context (edge case)
+        if (e.GetErrorCode() == ErrorCode_WebGLContextLost)
+        {
+          return;
+        }
+        else
+        {
+          throw;
+        }
+      }
     }
 
     const std::string& WebAssemblyOpenGLContext::GetCanvasSelector() const
--- a/Framework/Viewport/WebGLViewport.cpp	Sat Jun 20 11:08:28 2020 +0200
+++ b/Framework/Viewport/WebGLViewport.cpp	Sat Jun 20 11:16:55 2020 +0200
@@ -59,26 +59,6 @@
   }
     
 
-  void WebGLViewport::UpdateSize(ICompositor& compositor)
-  {
-    try
-    {
-      context_.RefreshCanvasSize();
-    }
-    catch (const StoneException& e)
-    {
-      // Ignore problems about the loss of the WebGL context (edge case)
-      if (e.GetErrorCode() == ErrorCode_WebGLContextLost)
-      {
-        return;
-      }
-      else
-      {
-        throw;
-      }
-    }
-  }
-
   WebGLViewport::WebGLViewport(const std::string& canvasId, bool enableEmscriptenMouseEvents) :
     WebAssemblyViewport(canvasId,enableEmscriptenMouseEvents),
     context_(GetCanvasCssSelector())
--- a/Framework/Viewport/WebGLViewport.h	Sat Jun 20 11:08:28 2020 +0200
+++ b/Framework/Viewport/WebGLViewport.h	Sat Jun 20 11:16:55 2020 +0200
@@ -37,7 +37,10 @@
     virtual void Paint(ICompositor& compositor,
                        ViewportController& controller) ORTHANC_OVERRIDE;
     
-    virtual void UpdateSize(ICompositor& compositor) ORTHANC_OVERRIDE;
+    virtual void UpdateSize(ICompositor& compositor) ORTHANC_OVERRIDE
+    {
+      context_.RefreshCanvasSize();
+    }
 
   public:
     static boost::shared_ptr<WebGLViewport> Create(const std::string& canvasId, bool enableEmscriptenMouseEvents = true);