mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-20 12:01:41 +00:00
Move GL_CONTEXT_MANAGER to kicommon
This commit is contained in:
parent
452e69de85
commit
d48c40ba26
@ -60,6 +60,7 @@ set( KICOMMON_SRCS
|
||||
|
||||
# Gal
|
||||
gal/color4d.cpp
|
||||
gal/opengl/gl_context_mgr.cpp
|
||||
# Jobs
|
||||
jobs/job.cpp
|
||||
jobs/job_dispatcher.cpp
|
||||
|
@ -34,7 +34,6 @@ set( GAL_SRCS
|
||||
opengl/opengl_gal.cpp
|
||||
opengl/gl_resources.cpp
|
||||
|
||||
opengl/gl_context_mgr.cpp
|
||||
opengl/shader.cpp
|
||||
opengl/vertex_item.cpp
|
||||
opengl/vertex_container.cpp
|
||||
|
@ -27,12 +27,13 @@
|
||||
#ifndef GL_CONTEXT_MANAGER_H
|
||||
#define GL_CONTEXT_MANAGER_H
|
||||
|
||||
#include <import_export.h>
|
||||
#include <gal/gal.h>
|
||||
#include <wx/glcanvas.h>
|
||||
#include <mutex>
|
||||
#include <map>
|
||||
|
||||
class GAL_API GL_CONTEXT_MANAGER
|
||||
class APIEXPORT GL_CONTEXT_MANAGER
|
||||
{
|
||||
public:
|
||||
/**
|
||||
@ -48,7 +49,7 @@ public:
|
||||
*
|
||||
* @return Created OpenGL context.
|
||||
*/
|
||||
wxGLContext* CreateCtx( wxGLCanvas* aCanvas, const wxGLContext* aOther = nullptr );
|
||||
APIEXPORT wxGLContext* CreateCtx( wxGLCanvas* aCanvas, const wxGLContext* aOther = nullptr );
|
||||
|
||||
/**
|
||||
* Destroy a managed OpenGL context.
|
||||
@ -57,14 +58,14 @@ public:
|
||||
*
|
||||
* @param aContext is the OpenGL context to be destroyed. It will not be managed anymore.
|
||||
*/
|
||||
void DestroyCtx( wxGLContext* aContext );
|
||||
APIEXPORT void DestroyCtx( wxGLContext* aContext );
|
||||
|
||||
/**
|
||||
* Destroy all managed OpenGL contexts.
|
||||
*
|
||||
* This method should be called in the final deinitialization routine.
|
||||
*/
|
||||
void DeleteAll();
|
||||
APIEXPORT void DeleteAll();
|
||||
|
||||
/**
|
||||
* Set a context as current and prevents other canvases from switching it.
|
||||
@ -76,7 +77,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 );
|
||||
APIEXPORT void LockCtx( wxGLContext* aContext, wxGLCanvas* aCanvas );
|
||||
|
||||
/**
|
||||
* Allow other canvases to bind an OpenGL context.
|
||||
@ -84,14 +85,14 @@ public:
|
||||
* @param aContext is the currently bound context. It is only a check to assure the right
|
||||
* canvas wants to unlock GL context.
|
||||
*/
|
||||
void UnlockCtx( wxGLContext* aContext );
|
||||
APIEXPORT void UnlockCtx( wxGLContext* aContext );
|
||||
|
||||
/**
|
||||
* Get the currently bound GL context.
|
||||
*
|
||||
* @return the currently bound GL context.
|
||||
*/
|
||||
wxGLContext* GetCurrentCtx() const
|
||||
APIEXPORT wxGLContext* GetCurrentCtx() const
|
||||
{
|
||||
return m_glCtx;
|
||||
}
|
||||
@ -101,7 +102,7 @@ public:
|
||||
*
|
||||
* @return the currently bound GL canvas.
|
||||
*/
|
||||
wxGLCanvas* GetCurrentCanvas() const
|
||||
APIEXPORT wxGLCanvas* GetCurrentCanvas() const
|
||||
{
|
||||
auto it = m_glContexts.find( m_glCtx );
|
||||
return it != m_glContexts.end() ? it->second : nullptr;
|
||||
@ -113,7 +114,7 @@ public:
|
||||
* @param aFunction is the function to be executed.
|
||||
*/
|
||||
template<typename Func, typename... Args>
|
||||
auto RunWithoutCtxLock( Func&& aFunction, Args&&... args )
|
||||
APIEXPORT auto RunWithoutCtxLock( Func&& aFunction, Args&&... args )
|
||||
{
|
||||
wxGLContext* currentCtx = GetCurrentCtx();
|
||||
wxGLCanvas* currentCanvas = GetCurrentCanvas();
|
||||
|
Loading…
Reference in New Issue
Block a user