]> OCCT Git - occt.git/commitdiff
0032991: Visualization, TKOpenGl - OpenGl_Window::Resize() ignores window virtual...
authorkgv <kgv@opencascade.com>
Fri, 27 May 2022 22:04:31 +0000 (01:04 +0300)
committerafokin <afokin@opencascade.com>
Mon, 30 May 2022 17:47:07 +0000 (20:47 +0300)
Added handling of Aspect_Window::IsVirtual() flag on macOS platform.

src/Cocoa/Cocoa_Window.mm
src/OpenGl/OpenGl_Window_1.mm
src/ViewerTest/ViewerTest_EventManager.cxx

index d491b11e170dc92602cc0249c4bacb846edeb7e6..cd42e414eb535eb099e274ee1e1b02ce14c9ac39 100644 (file)
@@ -436,15 +436,6 @@ void Cocoa_Window::InvalidateContent (const Handle(Aspect_DisplayConnection)& )
     return;
   }
 
-  if ([NSThread isMainThread])
-  {
-  #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
-    [myHView setNeedsDisplay];
-  #else
-    [myHView setNeedsDisplay: YES];
-  #endif
-  }
-  else
   {
     [myHView performSelectorOnMainThread: @selector(invalidateContentOcct:)
                               withObject: NULL
index f1cc8c19d55f1c63459e1a692726022b266ab733..8e61ad112abb7e5be518da291e73d1f16328961c 100644 (file)
@@ -274,11 +274,18 @@ OpenGl_Window::~OpenGl_Window()
 void OpenGl_Window::Resize()
 {
   // If the size is not changed - do nothing
-  Standard_Integer aWidthPt  = 0;
-  Standard_Integer aHeightPt = 0;
-  mySizeWindow->Size (aWidthPt, aHeightPt);
-  if (mySizePt.x() == aWidthPt
-   && mySizePt.y() == aHeightPt)
+  Graphic3d_Vec2i aWinSize;
+  mySizeWindow->Size (aWinSize.x(), aWinSize.y());
+  if (myPlatformWindow->IsVirtual()
+   || mySizeWindow != myPlatformWindow)
+  {
+    if (mySize == aWinSize)
+    {
+      return;
+    }
+    mySize = aWinSize;
+  }
+  else if (mySizePt == aWinSize)
   {
   #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
     return;
@@ -303,8 +310,7 @@ void OpenGl_Window::Resize()
   #endif
   }
 
-  mySizePt.x() = aWidthPt;
-  mySizePt.y() = aHeightPt;
+  mySizePt = aWinSize;
 
   init();
 }
@@ -366,40 +372,42 @@ void OpenGl_Window::init()
   aDefFbo->BindBuffer (myGlContext);
   aDefFbo.Nullify();
 #else
-  NSOpenGLContext* aGLCtx  = myGlContext->myGContext;
-Standard_DISABLE_DEPRECATION_WARNINGS
-  NSView*          aView   = [aGLCtx view];
-Standard_ENABLE_DEPRECATION_WARNINGS
-  NSRect           aBounds = [aView bounds];
+  if (!myPlatformWindow->IsVirtual()
+    && mySizeWindow == myPlatformWindow)
+  {
+    NSOpenGLContext* aGLCtx  = myGlContext->myGContext;
+  Standard_DISABLE_DEPRECATION_WARNINGS
+    NSView*          aView   = [aGLCtx view];
+  Standard_ENABLE_DEPRECATION_WARNINGS
+    NSRect           aBounds = [aView bounds];
 
-  // we should call this method each time when window is resized
-  [aGLCtx update];
+    // we should call this method each time when window is resized
+    [aGLCtx update];
 
-  if ([aView respondsToSelector: @selector(convertSizeToBacking:)])
-  {
-    NSSize aRes = [aView convertSizeToBacking: aBounds.size];
-    mySize.x() = Standard_Integer(aRes.width);
-    mySize.y() = Standard_Integer(aRes.height);
-  }
-  else
-  {
-    mySize.x() = Standard_Integer(aBounds.size.width);
-    mySize.y() = Standard_Integer(aBounds.size.height);
+    if ([aView respondsToSelector: @selector(convertSizeToBacking:)])
+    {
+      NSSize aRes = [aView convertSizeToBacking: aBounds.size];
+      mySize.x() = Standard_Integer(aRes.width);
+      mySize.y() = Standard_Integer(aRes.height);
+    }
+    else
+    {
+      mySize.x() = Standard_Integer(aBounds.size.width);
+      mySize.y() = Standard_Integer(aBounds.size.height);
+    }
+    mySizePt.x() = Standard_Integer(aBounds.size.width);
+    mySizePt.y() = Standard_Integer(aBounds.size.height);
   }
-  mySizePt.x() = Standard_Integer(aBounds.size.width);
-  mySizePt.y() = Standard_Integer(aBounds.size.height);
 #endif
 
   myGlContext->core11fwd->glDisable (GL_DITHER);
   myGlContext->core11fwd->glDisable (GL_SCISSOR_TEST);
-  myGlContext->core11fwd->glViewport (0, 0, mySize.x(), mySize.y());
-  if (myGlContext->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES)
+  const Standard_Integer aViewport[4] = { 0, 0, mySize.x(), mySize.y() };
+  myGlContext->ResizeViewport (aViewport);
+  myGlContext->SetDrawBuffer (GL_BACK);
+  if (myGlContext->core11ffp != NULL)
   {
-    myGlContext->core11fwd->glDrawBuffer (GL_BACK);
-    if (myGlContext->core11ffp != NULL)
-    {
-      myGlContext->core11ffp->glMatrixMode (GL_MODELVIEW);
-    }
+    myGlContext->core11ffp->glMatrixMode (GL_MODELVIEW);
   }
 }
 
index d3fae9c88ebf8c23cd9b56ac015a66294246193b..2bb2362f357dd86f9f4822ddd2c4000948bbc003 100644 (file)
@@ -253,7 +253,7 @@ void ViewerTest_EventManager::handleViewRedraw (const Handle(AIS_InteractiveCont
      && (!aRedrawer.IsStarted() || aRedrawer.IsPaused()))
     {
       myIsTmpContRedraw = true;
-    #if !defined(_WIN32) && !defined(__EMSCRIPTEN__)
+    #if !defined(_WIN32) && !defined(__EMSCRIPTEN__) && !defined(__APPLE__)
       aRedrawer.Start (theView, 60.0);
     #endif
     }
@@ -269,7 +269,7 @@ void ViewerTest_EventManager::handleViewRedraw (const Handle(AIS_InteractiveCont
   else if (myIsTmpContRedraw)
   {
     myIsTmpContRedraw = false;
-  #ifndef _WIN32
+  #if !defined(_WIN32) && !defined(__APPLE__)
     ViewerTest_ContinuousRedrawer& aRedrawer = ViewerTest_ContinuousRedrawer::Instance();
     aRedrawer.Pause();
   #endif