From 243db302bf1186dfc0705d65398e6e7362693444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 7 Sep 2017 15:18:34 +0200 Subject: [PATCH] EGLDevice: Fix build after rebase Some minor bitrot had occurred since the patch was made. Related to #786. --- CMakeLists.txt | 14 +++++++++++--- src/CMakeLists.txt | 6 +++--- src/egl_context.c | 2 +- src/egl_context.h | 7 ++++++- src/egldevice_init.c | 17 ++++------------- src/egldevice_monitor.c | 26 +++++++------------------ src/egldevice_platform.h | 36 +++++++++++++++++++++++++++++------ src/egldevice_window.c | 41 ++++++++++++++++++++++++++++++++++++++-- 8 files changed, 101 insertions(+), 48 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 467fc7ab..ea65cae6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,8 +41,9 @@ if (WIN32) endif() if (UNIX AND NOT APPLE) - option(GLFW_USE_WAYLAND "Use Wayland for window creation" OFF) - option(GLFW_USE_MIR "Use Mir for window creation" OFF) + option(GLFW_USE_WAYLAND "Use Wayland for window creation" OFF) + option(GLFW_USE_MIR "Use Mir for window creation" OFF) + option(GLFW_USE_EGLDEVICE "Use EGLDevice for window creation" OFF) endif() if (MSVC) @@ -299,8 +300,15 @@ endif() #-------------------------------------------------------------------- if (_GLFW_EGLDEVICE) + find_path(DRM_INCLUDE_DIR NAMES drm.h PATH_SUFFIXES drm libdrm) + if (NOT DRM_INCLUDE_DIR) + message(FATAL_ERROR "The libdrm headers were not found") + endif() + + list(APPEND glfw_INCLUDE_DIRS "${DRM_INCLUDE_DIR}") + list(APPEND glfw_LIBRARIES "-ldrm") - list(APPEND glfw_LIBRARIES "-lpthread") + list(APPEND glfw_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}") endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7be4a074..226cc193 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -49,9 +49,9 @@ elseif (_GLFW_WAYLAND) BASENAME pointer-constraints-unstable-v1) elseif(_GLFW_EGLDEVICE) set(glfw_HEADERS ${common_HEADERS} egldevice_platform.h linux_joystick.h - posix_time.h posix_tls.h xkb_unicode.h egl_context.h) + posix_time.h posix_thread.h xkb_unicode.h egl_context.h) set(glfw_SOURCES ${common_SOURCES} egldevice_init.c egldevice_monitor.c egldevice_window.c - linux_joystick.c posix_time.c posix_tls.c xkb_unicode.c + linux_joystick.c posix_time.c posix_thread.c xkb_unicode.c egl_context.c) elseif (_GLFW_MIR) set(glfw_HEADERS ${common_HEADERS} mir_platform.h linux_joystick.h @@ -94,7 +94,7 @@ set_target_properties(glfw PROPERTIES target_compile_definitions(glfw PRIVATE _GLFW_USE_CONFIG_H - $<$:_XOPEN_SOURCE=600>) + $<$:_POSIX_C_SOURCE=200809L>) target_include_directories(glfw PUBLIC "$" "$/include>") diff --git a/src/egl_context.c b/src/egl_context.c index bef7525c..6f2a4252 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -118,7 +118,7 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig, #if defined(_GLFW_EGLDEVICE) // Only consider stream EGLConfigs - if (!(getConfigAttrib(n, EGL_SURFACE_TYPE) & EGL_STREAM_BIT_KHR)) + if (!(getEGLConfigAttrib(n, EGL_SURFACE_TYPE) & EGL_STREAM_BIT_KHR)) continue; #else diff --git a/src/egl_context.h b/src/egl_context.h index b27cac96..eed35bb4 100644 --- a/src/egl_context.h +++ b/src/egl_context.h @@ -48,7 +48,9 @@ typedef struct wl_egl_window* EGLNativeWindowType; typedef MirEGLNativeDisplayType EGLNativeDisplayType; typedef MirEGLNativeWindowType EGLNativeWindowType; #elif defined(_GLFW_EGLDEVICE) - #include + #define EGLAPIENTRY +typedef void* EGLNativeDisplayType; +typedef int EGLNativeWindowType; #else #error "No supported EGL platform selected" #endif @@ -86,6 +88,8 @@ typedef MirEGLNativeWindowType EGLNativeWindowType; #define EGL_OPENGL_ES_API 0x30a0 #define EGL_OPENGL_API 0x30a2 #define EGL_NONE 0x3038 +#define EGL_WIDTH 0x3057 +#define EGL_HEIGHT 0x3056 #define EGL_EXTENSIONS 0x3055 #define EGL_CONTEXT_CLIENT_VERSION 0x3098 #define EGL_NATIVE_VISUAL_ID 0x302e @@ -120,6 +124,7 @@ typedef void* EGLConfig; typedef void* EGLContext; typedef void* EGLDisplay; typedef void* EGLSurface; +typedef intptr_t EGLAttrib; // EGL function pointer typedefs typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*); diff --git a/src/egldevice_init.c b/src/egldevice_init.c index 6940573c..1372895f 100644 --- a/src/egldevice_init.c +++ b/src/egldevice_init.c @@ -27,7 +27,6 @@ #include "internal.h" #include -#include "egl_context.h" static GLFWbool initializeExtensions() { @@ -187,10 +186,7 @@ static GLFWbool initEGLDisplay(EGLDeviceEXT egl_dev, int drm_fd) if (!eglInitialize(_glfw.egl.display, &_glfw.egl.major, &_glfw.egl.minor)) { - _glfwInputError(GLFW_API_UNAVAILABLE, - "EGL: Failed to initialize EGL: %s", - eglGetError()); - + _glfwInputError(GLFW_API_UNAVAILABLE, "EGL: Failed to initialize EGL"); return GLFW_FALSE; } @@ -252,9 +248,6 @@ int _glfwPlatformInit(void) EGLDeviceEXT egl_dev; int drm_fd; - if (!_glfwInitThreadLocalStoragePOSIX()) - return GLFW_FALSE; - // Initialize EGL if (!_glfwInitEGL()) return GLFW_FALSE; @@ -278,6 +271,8 @@ int _glfwPlatformInit(void) _glfwInitTimerPOSIX(); + _glfwPollMonitorsEGLDevice(); + return GLFW_TRUE; } @@ -285,15 +280,11 @@ void _glfwPlatformTerminate(void) { _glfwTerminateEGL(); _glfwTerminateJoysticksLinux(); - _glfwTerminateThreadLocalStoragePOSIX(); } const char* _glfwPlatformGetVersionString(void) { - return _GLFW_VERSION_NUMBER "EGLDEVICE" -#if defined(_GLFW_EGL) - " EGL" -#endif + return _GLFW_VERSION_NUMBER "EGLDevice EGL" #if defined(_GLFW_BUILD_DLL) " shared" #endif diff --git a/src/egldevice_monitor.c b/src/egldevice_monitor.c index 388b23db..4024df99 100644 --- a/src/egldevice_monitor.c +++ b/src/egldevice_monitor.c @@ -117,30 +117,18 @@ static GLFWbool initDRMResources(_GLFWmonitor* monitor, int drm_fd) /////////// GLFW platform API ////////////// ///////////////////////////////////////////////////////////////////////////// -_GLFWmonitor** _glfwPlatformGetMonitors(int* count) +void _glfwPollMonitorsEGLDevice(void) { - _GLFWmonitor** monitors; - _GLFWmonitor* monitor; - int monitorsCount = 1; + _GLFWmonitor* monitor = _glfwAllocMonitor("Monitor", 0, 0); - monitors = calloc(monitorsCount, sizeof(_GLFWmonitor*)); - monitor = calloc(1, sizeof(_GLFWmonitor)); - - *count = 1; // Obtain DRM resource info if (!initDRMResources(monitor, _glfw.egldevice.drmFd)) - return GLFW_FALSE; + { + _glfwFreeMonitor(monitor); + return; + } - monitors[0] = monitor; - - return monitors; -} - -GLFWbool _glfwPlatformIsSameMonitor(_GLFWmonitor* first, _GLFWmonitor* second) -{ - _glfwInputError(GLFW_PLATFORM_ERROR, - "EGLDevice: _glfwPlatformIsSameMonitor not implemented"); - return 0; + _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_FIRST); } void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) diff --git a/src/egldevice_platform.h b/src/egldevice_platform.h index 39ce2852..0fdfe6be 100644 --- a/src/egldevice_platform.h +++ b/src/egldevice_platform.h @@ -43,18 +43,40 @@ #include #include -#include -#include - #include #include #include #include + #include "posix_time.h" #include "linux_joystick.h" -#include "posix_tls.h" - +#include "posix_thread.h" #include "egl_context.h" +#include "osmesa_context.h" + +#define EGL_NO_DEVICE_EXT ((EGLDeviceEXT) 0) +#define EGL_DRM_DEVICE_FILE_EXT 0x3233 +#define EGL_PLATFORM_DEVICE_EXT 0x313f +#define EGL_DRM_MASTER_FD_EXT 0x333c +#define EGL_STREAM_FIFO_LENGTH_KHR 0x31fc +#define EGL_DRM_CRTC_EXT 0x3234 +#define EGL_NO_STREAM_KHR ((EGLStreamKHR) 0) +#define EGL_STREAM_BIT_KHR 0x0800 + +typedef void* EGLOutputLayerEXT; +typedef void* EGLStreamKHR; +typedef void* EGLDeviceEXT; + +typedef EGLBoolean (EGLAPIENTRY * PFNEGLQUERYDEVICESEXTPROC)(EGLint,EGLDeviceEXT*,EGLint*); +typedef const char *(EGLAPIENTRY * PFNEGLQUERYDEVICESTRINGEXTPROC)(EGLDeviceEXT,EGLint); +typedef EGLDisplay (EGLAPIENTRY * PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum,void*,const EGLint*); +typedef EGLBoolean (EGLAPIENTRY * PFNEGLGETOUTPUTLAYERSEXTPROC)(EGLDisplay,const EGLAttrib*,EGLOutputLayerEXT*,EGLint,EGLint*); +typedef EGLStreamKHR (EGLAPIENTRY * PFNEGLCREATESTREAMKHRPROC)(EGLDisplay,const EGLint*); +typedef EGLBoolean (EGLAPIENTRY * PFNEGLDESTROYSTREAMKHRPROC)(EGLDisplay,EGLStreamKHR); +typedef EGLBoolean (EGLAPIENTRY * PFNEGLSTREAMCONSUMEROUTPUTEXTPROC)(EGLDisplay,EGLStreamKHR,EGLOutputLayerEXT); +typedef EGLSurface (EGLAPIENTRY * PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC)(EGLDisplay,EGLConfig,EGLStreamKHR,const EGLint*); +typedef EGLBoolean (EGLAPIENTRY * PFNEGLSTREAMATTRIBKHRPROC)(EGLDisplay,EGLStreamKHR,EGLenum,EGLint); +typedef EGLBoolean (EGLAPIENTRY * PFNEGLSTREAMCONSUMERACQUIREATTRIBKHRPROC)(EGLDisplay,EGLStreamKHR,const EGLAttrib*); #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL) #define _glfw_dlclose(handle) dlclose(handle) @@ -101,7 +123,7 @@ typedef struct _GLFWlibraryEgldevice PFNEGLSTREAMCONSUMEROUTPUTEXTPROC eglStreamConsumerOutputEXT; PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC eglCreateStreamProducerSurfaceKHR; PFNEGLSTREAMATTRIBKHRPROC eglStreamAttribKHR; - PFNEGLSTREAMCONSUMERACQUIREATTRIBEXTPROC eglStreamConsumerAcquireAttribEXT; + PFNEGLSTREAMCONSUMERACQUIREATTRIBKHRPROC eglStreamConsumerAcquireAttribKHR; } _GLFWlibraryEgldevice; // EGLDEVICE-specific per-monitor data @@ -116,4 +138,6 @@ typedef struct _GLFWmonitorEgldevice { typedef struct _GLFWcursorEgldevice { } _GLFWcursorEgldevice; +void _glfwPollMonitorsEGLDevice(void); + #endif // _glfw3_egldevice_platform_h_ diff --git a/src/egldevice_window.c b/src/egldevice_window.c index 71255df4..55b4d5cb 100644 --- a/src/egldevice_window.c +++ b/src/egldevice_window.c @@ -222,6 +222,30 @@ void _glfwPlatformMaximizeWindow(_GLFWwindow* window) "EGLDevice: _glfwPlatformMaximizeWindow not implemented"); } +void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled) +{ + _glfwInputError(GLFW_PLATFORM_ERROR, + "EGLDevice: _glfwPlatformSetWindowResizable not implemented"); +} + +void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled) +{ + _glfwInputError(GLFW_PLATFORM_ERROR, + "EGLDevice: _glfwPlatformSetWindowDecorated not implemented"); +} + +void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) +{ + _glfwInputError(GLFW_PLATFORM_ERROR, + "EGLDevice: _glfwPlatformSetWindowFloating not implemented"); +} + +void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) +{ + _glfwInputError(GLFW_PLATFORM_ERROR, + "EGLDevice: _glfwPlatformRequestWindowAttention not implemented"); +} + void _glfwPlatformShowWindow(_GLFWwindow* window) { return; @@ -369,11 +393,24 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window) return NULL; } -char** _glfwPlatformGetRequiredInstanceExtensions(uint32_t* count) +const char* _glfwPlatformGetScancodeName(int scancode) +{ + _glfwInputError(GLFW_PLATFORM_ERROR, + "EGLDevice: _glfwPlatformGetScancodeName not supported"); + return ""; +} + +int _glfwPlatformGetKeyScancode(int key) +{ + _glfwInputError(GLFW_PLATFORM_ERROR, + "EGLDevice: _glfwPlatformGetKeyScancode not supported"); + return -1; +} + +void _glfwPlatformGetRequiredInstanceExtensions(char** extensions) { _glfwInputError(GLFW_PLATFORM_ERROR, "EGLDevice: _glfwPlatformGetRequiredInstanceExtensions not supported"); - return NULL; } int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,