Reverted 6912 with minor changes (LockCtx requires to specify canvas that locks a context).
This commit is contained in:
parent
571206aa07
commit
b82ccc3b4e
|
@ -117,7 +117,7 @@ EDA_3D_CANVAS::EDA_3D_CANVAS( EDA_3D_FRAME* parent, int* attribList ) :
|
|||
|
||||
EDA_3D_CANVAS::~EDA_3D_CANVAS()
|
||||
{
|
||||
GL_CONTEXT_MANAGER::Get().LockCtx( m_glRC );
|
||||
GL_CONTEXT_MANAGER::Get().LockCtx( m_glRC, this );
|
||||
|
||||
ClearLists();
|
||||
m_init = false;
|
||||
|
|
|
@ -302,7 +302,7 @@ void EDA_3D_CANVAS::Redraw()
|
|||
// Display build time at the end of build
|
||||
unsigned strtime = GetRunningMicroSecs();
|
||||
|
||||
GL_CONTEXT_MANAGER::Get().LockCtx( m_glRC );
|
||||
GL_CONTEXT_MANAGER::Get().LockCtx( m_glRC, this );
|
||||
|
||||
// Set the OpenGL viewport according to the client size of this canvas.
|
||||
// This is done here rather than in a wxSizeEvent handler because our
|
||||
|
|
|
@ -101,7 +101,7 @@ C3D_MODEL_VIEWER::C3D_MODEL_VIEWER( wxWindow *aParent,
|
|||
|
||||
C3D_MODEL_VIEWER::~C3D_MODEL_VIEWER()
|
||||
{
|
||||
GL_CONTEXT_MANAGER::Get().LockCtx( m_glRC );
|
||||
GL_CONTEXT_MANAGER::Get().LockCtx( m_glRC, this );
|
||||
|
||||
wxLogTrace( m_logTrace, wxT( "C3D_MODEL_VIEWER::~C3D_MODEL_VIEWER" ) );
|
||||
|
||||
|
@ -205,7 +205,7 @@ void C3D_MODEL_VIEWER::OnPaint( wxPaintEvent &event )
|
|||
// "Makes the OpenGL state that is represented by the OpenGL rendering
|
||||
// context context current, i.e. it will be used by all subsequent OpenGL calls.
|
||||
// This function may only be called when the window is shown on screen"
|
||||
GL_CONTEXT_MANAGER::Get().LockCtx( m_glRC );
|
||||
GL_CONTEXT_MANAGER::Get().LockCtx( m_glRC, this );
|
||||
|
||||
// Set the OpenGL viewport according to the client size of this canvas.
|
||||
// This is done here rather than in a wxSizeEvent handler because our
|
||||
|
|
|
@ -143,7 +143,7 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
|
|||
|
||||
OPENGL_GAL::~OPENGL_GAL()
|
||||
{
|
||||
GL_CONTEXT_MANAGER::Get().LockCtx( glPrivContext );
|
||||
GL_CONTEXT_MANAGER::Get().LockCtx( glPrivContext, this );
|
||||
|
||||
--instanceCounter;
|
||||
glFlush();
|
||||
|
@ -165,7 +165,7 @@ OPENGL_GAL::~OPENGL_GAL()
|
|||
// Are we destroying the last GAL instance?
|
||||
if( instanceCounter == 0 )
|
||||
{
|
||||
GL_CONTEXT_MANAGER::Get().LockCtx( glMainContext );
|
||||
GL_CONTEXT_MANAGER::Get().LockCtx( glMainContext, this );
|
||||
|
||||
if( isBitmapFontLoaded )
|
||||
{
|
||||
|
@ -193,7 +193,7 @@ void OPENGL_GAL::BeginDrawing()
|
|||
prof_start( &totalRealTime );
|
||||
#endif /* __WXDEBUG__ */
|
||||
|
||||
GL_CONTEXT_MANAGER::Get().LockCtx( glPrivContext );
|
||||
GL_CONTEXT_MANAGER::Get().LockCtx( glPrivContext, this );
|
||||
|
||||
#ifdef RETINA_OPENGL_PATCH
|
||||
const float scaleFactor = GetBackingScaleFactor();
|
||||
|
@ -346,7 +346,7 @@ void OPENGL_GAL::EndDrawing()
|
|||
|
||||
void OPENGL_GAL::BeginUpdate()
|
||||
{
|
||||
GL_CONTEXT_MANAGER::Get().LockCtx( glPrivContext );
|
||||
GL_CONTEXT_MANAGER::Get().LockCtx( glPrivContext, this );
|
||||
cachedManager->Map();
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,6 @@ void GL_CONTEXT_MANAGER::DestroyCtx( wxGLContext* aContext )
|
|||
if( m_glCtx == aContext )
|
||||
{
|
||||
m_glCtx = NULL;
|
||||
m_glCanvas = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,13 +78,9 @@ void GL_CONTEXT_MANAGER::LockCtx( wxGLContext* aContext, wxGLCanvas* aCanvas )
|
|||
m_glCtxMutex.lock();
|
||||
wxGLCanvas* canvas = aCanvas ? aCanvas : m_glContexts.at( aContext );
|
||||
|
||||
if( aContext != m_glCtx || canvas != m_glCanvas )
|
||||
{
|
||||
canvas->SetCurrent( *aContext );
|
||||
m_glCanvas = canvas;
|
||||
m_glCtx = aContext;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GL_CONTEXT_MANAGER::UnlockCtx( wxGLContext* aContext )
|
||||
|
@ -95,6 +90,7 @@ void GL_CONTEXT_MANAGER::UnlockCtx( wxGLContext* aContext )
|
|||
if( m_glCtx == aContext )
|
||||
{
|
||||
m_glCtxMutex.unlock();
|
||||
m_glCtx = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -104,7 +100,7 @@ void GL_CONTEXT_MANAGER::UnlockCtx( wxGLContext* aContext )
|
|||
|
||||
|
||||
GL_CONTEXT_MANAGER::GL_CONTEXT_MANAGER()
|
||||
: m_glCtx( NULL ), m_glCanvas( NULL )
|
||||
: m_glCtx( NULL )
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ public:
|
|||
* @param aCanvas (optional) allows caller to bind the context to a non-parent canvas
|
||||
* (e.g. when a few canvases share a single GL context).
|
||||
*/
|
||||
void LockCtx( wxGLContext* aContext, wxGLCanvas* aCanvas = NULL );
|
||||
void LockCtx( wxGLContext* aContext, wxGLCanvas* aCanvas );
|
||||
|
||||
/**
|
||||
* Function UnlockCtx
|
||||
|
@ -88,9 +88,6 @@ private:
|
|||
///> Currently bound GL context.
|
||||
wxGLContext* m_glCtx;
|
||||
|
||||
///> The canvas that uses the current GL context.
|
||||
wxGLCanvas* m_glCanvas;
|
||||
|
||||
///> Lock to prevent unexpected GL context switching.
|
||||
MUTEX m_glCtxMutex;
|
||||
|
||||
|
|
Loading…
Reference in New Issue