1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-03 14:10:33 +03:00

0032991: Visualization, TKOpenGl - OpenGl_Window::Resize() ignores window virtual flag on macOS

Added handling of Aspect_Window::IsVirtual() flag on macOS platform (7.6.x backport).
This commit is contained in:
kgv
2022-06-13 10:13:53 +03:00
parent 77003e1894
commit 507ead3c5a
3 changed files with 44 additions and 40 deletions

View File

@@ -436,15 +436,6 @@ void Cocoa_Window::InvalidateContent (const Handle(Aspect_DisplayConnection)& )
return; return;
} }
if ([NSThread isMainThread])
{
#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
[myHView setNeedsDisplay];
#else
[myHView setNeedsDisplay: YES];
#endif
}
else
{ {
[myHView performSelectorOnMainThread: @selector(invalidateContentOcct:) [myHView performSelectorOnMainThread: @selector(invalidateContentOcct:)
withObject: NULL withObject: NULL

View File

@@ -264,11 +264,20 @@ OpenGl_Window::~OpenGl_Window()
void OpenGl_Window::Resize() void OpenGl_Window::Resize()
{ {
// If the size is not changed - do nothing // If the size is not changed - do nothing
Standard_Integer aWidthPt = 0; Graphic3d_Vec2i aWinSize;
Standard_Integer aHeightPt = 0; myPlatformWindow->Size (aWinSize.x(), aWinSize.y());
myPlatformWindow->Size (aWidthPt, aHeightPt); if (myPlatformWindow->IsVirtual())
if (myWidthPt == aWidthPt {
&& myHeightPt == aHeightPt) 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 #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
return; return;
@@ -293,8 +302,8 @@ void OpenGl_Window::Resize()
#endif #endif
} }
myWidthPt = aWidthPt; myWidthPt = aWinSize.x();
myHeightPt = aHeightPt; myHeightPt = aWinSize.y();
Init(); Init();
} }
@@ -356,35 +365,39 @@ void OpenGl_Window::Init()
aDefFbo->BindBuffer (myGlContext); aDefFbo->BindBuffer (myGlContext);
aDefFbo.Nullify(); aDefFbo.Nullify();
#else #else
NSOpenGLContext* aGLCtx = myGlContext->myGContext; if (!myPlatformWindow->IsVirtual())
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];
if ([aView respondsToSelector: @selector(convertSizeToBacking:)])
{ {
NSSize aRes = [aView convertSizeToBacking: aBounds.size]; NSOpenGLContext* aGLCtx = myGlContext->myGContext;
myWidth = Standard_Integer(aRes.width); Standard_DISABLE_DEPRECATION_WARNINGS
myHeight = Standard_Integer(aRes.height); 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];
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);
} }
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);
#endif #endif
::glDisable (GL_DITHER); ::glDisable (GL_DITHER);
::glDisable (GL_SCISSOR_TEST); ::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) #if !defined(GL_ES_VERSION_2_0)
::glDrawBuffer (GL_BACK); myGlContext->SetDrawBuffer (GL_BACK);
if (myGlContext->core11ffp != NULL) if (myGlContext->core11ffp != NULL)
{ {
::glMatrixMode (GL_MODELVIEW); ::glMatrixMode (GL_MODELVIEW);

View File

@@ -196,7 +196,7 @@ void ViewerTest_EventManager::handleViewRedraw (const Handle(AIS_InteractiveCont
&& (!aRedrawer.IsStarted() || aRedrawer.IsPaused())) && (!aRedrawer.IsStarted() || aRedrawer.IsPaused()))
{ {
myIsTmpContRedraw = true; myIsTmpContRedraw = true;
#if !defined(_WIN32) && !defined(__EMSCRIPTEN__) #if !defined(_WIN32) && !defined(__EMSCRIPTEN__) && !defined(__APPLE__)
aRedrawer.Start (theView, 60.0); aRedrawer.Start (theView, 60.0);
#endif #endif
} }
@@ -210,7 +210,7 @@ void ViewerTest_EventManager::handleViewRedraw (const Handle(AIS_InteractiveCont
else if (myIsTmpContRedraw) else if (myIsTmpContRedraw)
{ {
myIsTmpContRedraw = false; myIsTmpContRedraw = false;
#ifndef _WIN32 #if !defined(_WIN32) && !defined(__APPLE__)
ViewerTest_ContinuousRedrawer& aRedrawer = ViewerTest_ContinuousRedrawer::Instance(); ViewerTest_ContinuousRedrawer& aRedrawer = ViewerTest_ContinuousRedrawer::Instance();
aRedrawer.Pause(); aRedrawer.Pause();
#endif #endif