]> OCCT Git - occt.git/commitdiff
0032991: Visualization, TKOpenGl - OpenGl_Window::Resize() ignores window virtual...
authorkgv <kgv@opencascade.com>
Mon, 13 Jun 2022 07:13:53 +0000 (10:13 +0300)
committerkgv <kgv@opencascade.com>
Mon, 13 Jun 2022 07:13:53 +0000 (10:13 +0300)
Added handling of Aspect_Window::IsVirtual() flag on macOS platform (7.6.x backport).

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 49108d4f2b76ce9cbed2ee15f2badb5fe6a6a102..03ecdab6a0b31398325ef4229231997ed72213f2 100644 (file)
@@ -264,11 +264,20 @@ OpenGl_Window::~OpenGl_Window()
 void OpenGl_Window::Resize()
 {
   // If the size is not changed - do nothing
-  Standard_Integer aWidthPt  = 0;
-  Standard_Integer aHeightPt = 0;
-  myPlatformWindow->Size (aWidthPt, aHeightPt);
-  if (myWidthPt  == aWidthPt
-   && myHeightPt == aHeightPt)
+  Graphic3d_Vec2i aWinSize;
+  myPlatformWindow->Size (aWinSize.x(), aWinSize.y());
+  if (myPlatformWindow->IsVirtual())
+  {
+    if (myWidth  == aWinSize.x()
+     && myHeight == aWinSize.y())
+    {
+      return;
+    }
+    myWidth  = aWinSize.x();
+    myHeight = aWinSize.y();
+  }
+  else if (myWidthPt  == aWinSize.x()
+        && myHeightPt == aWinSize.y())
   {
   #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
     return;
@@ -293,8 +302,8 @@ void OpenGl_Window::Resize()
   #endif
   }
 
-  myWidthPt  = aWidthPt;
-  myHeightPt = aHeightPt;
+  myWidthPt  = aWinSize.x();
+  myHeightPt = aWinSize.y();
 
   Init();
 }
@@ -356,35 +365,39 @@ 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())
+  {
+    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];
-    myWidth  = Standard_Integer(aRes.width);
-    myHeight = Standard_Integer(aRes.height);
-  }
-  else
-  {
-    myWidth  = Standard_Integer(aBounds.size.width);
-    myHeight = Standard_Integer(aBounds.size.height);
+    if ([aView respondsToSelector: @selector(convertSizeToBacking:)])
+    {
+      NSSize aRes = [aView convertSizeToBacking: aBounds.size];
+      myWidth  = Standard_Integer(aRes.width);
+      myHeight = Standard_Integer(aRes.height);
+    }
+    else
+    {
+      myWidth  = Standard_Integer(aBounds.size.width);
+      myHeight = Standard_Integer(aBounds.size.height);
+    }
+    myWidthPt  = Standard_Integer(aBounds.size.width);
+    myHeightPt = Standard_Integer(aBounds.size.height);
   }
-  myWidthPt  = Standard_Integer(aBounds.size.width);
-  myHeightPt = Standard_Integer(aBounds.size.height);
 #endif
 
   ::glDisable (GL_DITHER);
   ::glDisable (GL_SCISSOR_TEST);
-  ::glViewport (0, 0, myWidth, myHeight);
+  const Standard_Integer aViewport[4] = { 0, 0, myWidth, myHeight };
+  myGlContext->ResizeViewport (aViewport);
 #if !defined(GL_ES_VERSION_2_0)
-  ::glDrawBuffer (GL_BACK);
+  myGlContext->SetDrawBuffer (GL_BACK);
   if (myGlContext->core11ffp != NULL)
   {
     ::glMatrixMode (GL_MODELVIEW);
index 3335af811fceee269ef91f1429f67d59f0d64aab..e0fc6f558ae5c42e93cd974976b7a893c87dbc8c 100644 (file)
@@ -196,7 +196,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
     }
@@ -210,7 +210,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