OCC22377 Patch for visualization component
authorAPL <>
Thu, 19 May 2011 10:55:02 +0000 (10:55 +0000)
committerbugmaster <bugmaster@opencascade.com>
Mon, 5 Mar 2012 15:28:51 +0000 (19:28 +0400)
src/OpenGl/OpenGl_attri.cxx
src/OpenGl/OpenGl_subrvis.cxx
src/OpenGl/OpenGl_togl_redraw.cxx
src/OpenGl/OpenGl_txgl.cxx

index 9739ba6..894df1d 100755 (executable)
@@ -527,7 +527,7 @@ TsmPopAttri( void )
     if( attri_tail->TransPers.mode != node->TransPers.mode ||
         attri_tail->TransPers.pointX != node->TransPers.pointX ||
         attri_tail->TransPers.pointY != node->TransPers.pointY ||
-        attri_tail->TransPers.pointZ != node->TransPers.pointX )
+        attri_tail->TransPers.pointZ != node->TransPers.pointZ )
 
     {
       transform_persistence_begin( attri_tail->TransPers.mode, 
index 325a8ab..8b3f96c 100755 (executable)
@@ -120,6 +120,8 @@ from higher API */
 #include <OpenGl_tgl_util.hxx>
 #include <OpenGl_Memory.hxx>
 #include <OpenGl_graduatedtrihedron.hxx>
+#include <OpenGl_ResourceCleaner.hxx>
+#include <OpenGl_ResourceTexture.hxx>
 
 /*----------------------------------------------------------------------*/
 /*
@@ -759,20 +761,39 @@ void
 call_subr_close_ws( CALL_DEF_VIEW * aview )
 {
   CMN_KEY_DATA key;
+  CMN_KEY_DATA textureKey;
+
+  TsmGetWSAttri( aview->WsId, WSWindow, &key );
+
 #ifdef OCC1188
   tsm_bg_texture texture;
+  WINDOW aWnd = (WINDOW) key.ldata;
 
-  TsmGetWSAttri( aview->WsId, WSBgTexture, &key );
-  texture = (tsm_bg_texture)key.pdata;
-  
-  if( texture == 0 )
-     return;
+  TsmGetWSAttri( aview->WsId, WSBgTexture, &textureKey );
+  texture = (tsm_bg_texture)textureKey.pdata;
 
-  if ( texture->texId != 0 )
-    glDeleteTextures( 1,(GLuint *)&(texture->texId) );
+  if ( texture != 0 && texture->texId != 0 )
+  {
+    OpenGl_ResourceCleaner* anCleaner = OpenGl_ResourceCleaner::GetInstance();
+
+    // Delete the texture with ResourceCleaner; if it is not possible
+    // do this directly with proper context selected
+    if ( !anCleaner->AddResource( TxglGetContext(aWnd), 
+                   new OpenGl_ResourceTexture(texture->texId) ) )
+    {
+      GLCONTEXT  cur_context  = GET_GL_CONTEXT(); 
+      GLDRAWABLE cur_drawable = GET_GLDEV_CONTEXT();
+
+      if ( TxglWinset( call_thedisplay, aWnd ) == TSuccess )
+        glDeleteTextures( 1,(GLuint *)&(texture->texId) ); 
+
+      // activate the previous context for this thread
+      GL_MAKE_CURRENT( call_thedisplay, cur_drawable, cur_context );
+    }
+  }
+  
 #endif
 
-  TsmGetWSAttri( aview->WsId, WSWindow, &key );
 #ifdef RIC120302
   if( !aview->GContext )
 #endif
index 0b52495..dfbbce6 100755 (executable)
@@ -95,6 +95,7 @@ call_togl_redraw
       call_togl_redraw_layer2d (aview, anunderlayer);
     }
     call_func_redraw_all_structs_proc (aview->WsId);
+    call_subr_displayCB (aview, OCC_REDRAW_WINDOW | OCC_PRE_OVERLAY);
     if (anoverlayer->ptrLayer)
     {
       call_togl_redraw_layer2d (aview, anoverlayer);
@@ -172,6 +173,7 @@ call_togl_redraw_area
         call_togl_redraw_layer2d (aview, anunderlayer);
       }
       call_func_redraw_all_structs_proc (aview->WsId);
+      call_subr_displayCB (aview, OCC_REDRAW_WINDOWAREA | OCC_PRE_OVERLAY);
       if (anoverlayer->ptrLayer)
       {
         call_togl_redraw_layer2d (aview, anoverlayer);
index b94f44b..6bcbff0 100755 (executable)
@@ -302,7 +302,6 @@ __declspec( dllexport ) int __fastcall __OpenGl_INIT__ (
       /* recover display lists from dead_ctx, then destroy it */
       ctx = glXCreateContext( disp, vis, dead_ctx, GL_TRUE );
       glXDestroyContext(dead_dpy, dead_ctx);
-      dead_ctx = 0;
     } else if (previous_ctx == 0) {
       ctx = glXCreateContext( disp, vis, NULL, GL_TRUE );
     } else {
@@ -311,9 +310,16 @@ __declspec( dllexport ) int __fastcall __OpenGl_INIT__ (
     }
     previous_ctx = ctx;
 
-    if( !ctx) return TFailure;
+    if( ctx )
+      OpenGl_ResourceCleaner::GetInstance()->AppendContext( ctx, true );
 
-    OpenGl_ResourceCleaner::GetInstance()->AppendContext( ctx, true );
+    // remove the dead_ctx for ResourceCleaner after appending shared ctx
+    if (dead_ctx) {
+      OpenGl_ResourceCleaner::GetInstance()->RemoveContext(dead_ctx);
+      dead_ctx = 0;
+    }
+
+    if( !ctx) return TFailure;
 
     cmap = XCreateColormap( disp,  par, vis->visual, AllocNone );
 
@@ -783,7 +789,6 @@ __declspec( dllexport ) int __fastcall __OpenGl_INIT__ (
     /* FSXXX sync necessary if non-direct rendering */
     glXWaitGL();
 
-    OpenGl_ResourceCleaner::GetInstance()->RemoveContext( ctx );
     _Txgl_Map.UnBind( win );
 
     if (previous_ctx == ctx) {
@@ -800,12 +805,14 @@ __declspec( dllexport ) int __fastcall __OpenGl_INIT__ (
       * losing any shared display lists (fonts...)
       */
       if (previous_ctx) {
+        OpenGl_ResourceCleaner::GetInstance()->RemoveContext(ctx);
         glXDestroyContext(disp, ctx);
       } else {
         dead_ctx = ctx;
         dead_dpy = disp;
       }
     } else {
+      OpenGl_ResourceCleaner::GetInstance()->RemoveContext(ctx);
       glXDestroyContext(disp, ctx);
     }