Mercurial > hg > orthanc-stone
diff Framework/Viewport/WebAssemblyViewport.cpp @ 1054:3c9529edf5fd
fixing WebAssemblyViewport
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 10 Oct 2019 15:55:54 +0200 |
parents | d393ad9cf68c |
children | a28861abf888 ce3052f28f2e |
line wrap: on
line diff
--- a/Framework/Viewport/WebAssemblyViewport.cpp Thu Oct 10 15:24:48 2019 +0200 +++ b/Framework/Viewport/WebAssemblyViewport.cpp Thu Oct 10 15:55:54 2019 +0200 @@ -85,14 +85,31 @@ void WebAssemblyOpenGLViewport::DisableCompositor() { - compositor_.reset(NULL); + compositor_.reset(); + } + + ICompositor& WebAssemblyOpenGLViewport::GetCompositor() + { + if (compositor_.get() == NULL) + { + // "HasCompositor()" should have been called + throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); + } + else + { + return *compositor_; + } } void WebAssemblyOpenGLViewport::Refresh() { try { - if (!GetCompositor()) + if (HasCompositor()) + { + GetCompositor().Refresh(); + } + else { // this block was added because of (perceived?) bugs in the // browser where the WebGL contexts are NOT automatically restored @@ -102,16 +119,14 @@ //LOG(ERROR) << "About to call WebAssemblyOpenGLContext::TryRecreate()."; //LOG(ERROR) << "Before calling it, isContextLost == " << context_.IsContextLost(); - if (!context_.IsContextLost()) { + if (!context_.IsContextLost()) + { LOG(TRACE) << "Context restored!"; //LOG(ERROR) << "After calling it, isContextLost == " << context_.IsContextLost(); RestoreCompositor(); UpdateSize(); } } - if (GetCompositor()) { - GetCompositor()->Refresh(); - } } catch (const StoneException& e) { @@ -160,7 +175,7 @@ // maybe the context has already been restored by other means (the // Refresh() function) - if (!GetCompositor()) + if (!HasCompositor()) { RestoreCompositor(); UpdateSize(); @@ -248,6 +263,6 @@ void WebAssemblyCairoViewport::Refresh() { LOG(INFO) << "refreshing cairo viewport, TODO: blit to the canvans.getContext('2d')"; - GetCompositor()->Refresh(); + GetCompositor().Refresh(); } }