SDL: egl: Reject attempts to set negative swap intervals

From 9161f95166f3d8e42248c1156e35255d4ebdc6a0 Mon Sep 17 00:00:00 2001
From: Ethan Lee <[EMAIL REDACTED]>
Date: Tue, 27 Apr 2021 02:25:57 -0400
Subject: [PATCH] egl: Reject attempts to set negative swap intervals

---
 src/video/SDL_egl.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c
index d8adb6174..011d3d8a9 100644
--- a/src/video/SDL_egl.c
+++ b/src/video/SDL_egl.c
@@ -1087,6 +1087,13 @@ SDL_EGL_SetSwapInterval(_THIS, int interval)
     if (!_this->egl_data) {
         return SDL_SetError("EGL not initialized");
     }
+
+    /* FIXME: Revisit this check when EGL_EXT_swap_control_tear is published:
+     * https://github.com/KhronosGroup/EGL-Registry/pull/113
+     */
+    if (interval < 0) {
+        return SDL_SetError("Late swap tearing currently unsupported");
+    }
     
     status = _this->egl_data->eglSwapInterval(_this->egl_data->egl_display, interval);
     if (status == EGL_TRUE) {