mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
internal/glfw: reduce TLS usages at swapInterval*
This commit is contained in:
parent
18d3d91195
commit
09c027b670
@ -647,7 +647,7 @@ GLFWAPI void glfwSwapInterval(GLFWwindow* handle, int interval)
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
window->context.swapInterval(interval);
|
||||
window->context.swapInterval(window, interval);
|
||||
}
|
||||
|
||||
GLFWAPI int glfwExtensionSupported(GLFWwindow* handle, const char* extension)
|
||||
|
@ -513,7 +513,7 @@ func (w *Window) SwapInterval(interval int) error {
|
||||
return NotInitialized
|
||||
}
|
||||
|
||||
if err := w.context.swapInterval(interval); err != nil {
|
||||
if err := w.context.swapInterval(w, interval); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
@ -244,7 +244,7 @@ static void swapBuffersEGL(_GLFWwindow* window)
|
||||
eglSwapBuffers(_glfw.egl.display, window->context.egl.surface);
|
||||
}
|
||||
|
||||
static void swapIntervalEGL(int interval)
|
||||
static void swapIntervalEGL(_GLFWwindow* window, int interval)
|
||||
{
|
||||
eglSwapInterval(_glfw.egl.display, interval);
|
||||
}
|
||||
|
@ -165,11 +165,8 @@ static void swapBuffersGLX(_GLFWwindow* window)
|
||||
glXSwapBuffers(_glfw.x11.display, window->context.glx.window);
|
||||
}
|
||||
|
||||
static void swapIntervalGLX(int interval)
|
||||
static void swapIntervalGLX(_GLFWwindow* window, int interval)
|
||||
{
|
||||
_GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
|
||||
assert(window != NULL);
|
||||
|
||||
if (_glfw.glx.EXT_swap_control)
|
||||
{
|
||||
_glfw.glx.SwapIntervalEXT(_glfw.x11.display,
|
||||
|
@ -55,7 +55,7 @@ typedef struct _GLFWmutex _GLFWmutex;
|
||||
|
||||
typedef void (* _GLFWmakecontextcurrentfun)(_GLFWwindow*);
|
||||
typedef void (* _GLFWswapbuffersfun)(_GLFWwindow*);
|
||||
typedef void (* _GLFWswapintervalfun)(int);
|
||||
typedef void (* _GLFWswapintervalfun)(_GLFWwindow*, int);
|
||||
typedef int (* _GLFWextensionsupportedfun)(const char*);
|
||||
typedef GLFWglproc (* _GLFWgetprocaddressfun)(const char*);
|
||||
typedef void (* _GLFWdestroycontextfun)(_GLFWwindow*);
|
||||
|
@ -87,7 +87,7 @@ type context struct {
|
||||
// TODO: Put these functions in an interface type.
|
||||
makeCurrent func(*Window) error
|
||||
swapBuffers func(*Window) error
|
||||
swapInterval func(int) error
|
||||
swapInterval func(*Window, int) error
|
||||
extensionSupported func(string) bool
|
||||
getProcAddress func(string) uintptr
|
||||
destroy func(*Window) error
|
||||
|
@ -52,13 +52,10 @@ static void swapBuffersNSGL(_GLFWwindow* window)
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
static void swapIntervalNSGL(int interval)
|
||||
static void swapIntervalNSGL(_GLFWwindow* window, int interval)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
_GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
|
||||
assert(window != NULL);
|
||||
|
||||
[window->context.nsgl.object setValues:&interval
|
||||
forParameter:NSOpenGLContextParameterSwapInterval];
|
||||
|
||||
|
@ -71,7 +71,7 @@ static void swapBuffersOSMesa(_GLFWwindow* window)
|
||||
// No double buffering on OSMesa
|
||||
}
|
||||
|
||||
static void swapIntervalOSMesa(int interval)
|
||||
static void swapIntervalOSMesa(_GLFWwindow* window, int interval)
|
||||
{
|
||||
// No swap interval on OSMesa
|
||||
}
|
||||
|
@ -288,13 +288,7 @@ func swapBuffersWGL(window *Window) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func swapIntervalWGL(interval int) error {
|
||||
ptr, err := _glfw.contextSlot.get()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
window := (*Window)(unsafe.Pointer(ptr))
|
||||
|
||||
func swapIntervalWGL(window *Window, interval int) error {
|
||||
window.context.platform.interval = interval
|
||||
|
||||
if window.monitor == nil && winver.IsWindowsVistaOrGreater() {
|
||||
|
Loading…
Reference in New Issue
Block a user