mirror of
https://github.com/glfw/glfw.git
synced 2024-11-10 00:51:47 +00:00
EGL: Implement glfwSwapBufferWithDamage()
This is provided by the EGL_KHR_swap_buffers_with_damage extension.
This commit is contained in:
parent
e0b1f518cf
commit
8e354c2259
@ -232,6 +232,23 @@ static void swapBuffersEGL(_GLFWwindow* window)
|
||||
eglSwapBuffers(_glfw.egl.display, window->context.egl.surface);
|
||||
}
|
||||
|
||||
static void swapBuffersWithDamageEGL(_GLFWwindow* window, GLFWrect* rects, int n_rects)
|
||||
{
|
||||
if (window != _glfwPlatformGetTls(&_glfw.contextSlot))
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"EGL: The context must be current on the calling thread when swapping buffers");
|
||||
return;
|
||||
}
|
||||
|
||||
if (eglSwapBuffersWithDamageKHR)
|
||||
eglSwapBuffersWithDamageKHR(_glfw.egl.display,
|
||||
window->context.egl.surface,
|
||||
(EGLint*)rects, (EGLint)n_rects);
|
||||
else
|
||||
eglSwapBuffers(_glfw.egl.display, window->context.egl.surface);
|
||||
}
|
||||
|
||||
static void swapIntervalEGL(int interval)
|
||||
{
|
||||
eglSwapInterval(_glfw.egl.display, interval);
|
||||
@ -425,6 +442,12 @@ GLFWbool _glfwInitEGL(void)
|
||||
extensionSupportedEGL("EGL_KHR_get_all_proc_addresses");
|
||||
_glfw.egl.KHR_context_flush_control =
|
||||
extensionSupportedEGL("EGL_KHR_context_flush_control");
|
||||
_glfw.egl.KHR_swap_buffers_with_damage =
|
||||
extensionSupportedEGL("EGL_KHR_swap_buffers_with_damage");
|
||||
|
||||
if (_glfw.egl.KHR_swap_buffers_with_damage)
|
||||
_glfw.egl.SwapBuffersWithDamageKHR = (PFN_eglSwapBuffersWithDamageKHR)
|
||||
_glfw.egl.GetProcAddress("eglSwapBuffersWithDamageKHR");
|
||||
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
@ -694,6 +717,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
||||
|
||||
window->context.makeCurrent = makeContextCurrentEGL;
|
||||
window->context.swapBuffers = swapBuffersEGL;
|
||||
window->context.swapBuffersWithDamage = swapBuffersWithDamageEGL;
|
||||
window->context.swapInterval = swapIntervalEGL;
|
||||
window->context.extensionSupported = extensionSupportedEGL;
|
||||
window->context.getProcAddress = getProcAddressEGL;
|
||||
|
@ -132,6 +132,7 @@ typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint);
|
||||
typedef const char* (EGLAPIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint);
|
||||
typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapBuffersWithDamageKHR)(EGLDisplay,EGLSurface,EGLint*,EGLint);
|
||||
#define eglGetConfigAttrib _glfw.egl.GetConfigAttrib
|
||||
#define eglGetConfigs _glfw.egl.GetConfigs
|
||||
#define eglGetDisplay _glfw.egl.GetDisplay
|
||||
@ -148,6 +149,7 @@ typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*);
|
||||
#define eglSwapInterval _glfw.egl.SwapInterval
|
||||
#define eglQueryString _glfw.egl.QueryString
|
||||
#define eglGetProcAddress _glfw.egl.GetProcAddress
|
||||
#define eglSwapBuffersWithDamageKHR _glfw.egl.SwapBuffersWithDamageKHR
|
||||
|
||||
#define _GLFW_EGL_CONTEXT_STATE _GLFWcontextEGL egl
|
||||
#define _GLFW_EGL_LIBRARY_CONTEXT_STATE _GLFWlibraryEGL egl
|
||||
@ -178,6 +180,7 @@ typedef struct _GLFWlibraryEGL
|
||||
GLFWbool KHR_gl_colorspace;
|
||||
GLFWbool KHR_get_all_proc_addresses;
|
||||
GLFWbool KHR_context_flush_control;
|
||||
GLFWbool KHR_swap_buffers_with_damage;
|
||||
|
||||
void* handle;
|
||||
|
||||
@ -197,6 +200,7 @@ typedef struct _GLFWlibraryEGL
|
||||
PFN_eglSwapInterval SwapInterval;
|
||||
PFN_eglQueryString QueryString;
|
||||
PFN_eglGetProcAddress GetProcAddress;
|
||||
PFN_eglSwapBuffersWithDamageKHR SwapBuffersWithDamageKHR;
|
||||
|
||||
} _GLFWlibraryEGL;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user