Chia-I Wu | f2001df | 2011-07-02 17:57:30 +0900 | [diff] [blame] | 1 | /************************************************************************** |
| 2 | * |
José Fonseca | 8771285 | 2014-01-17 16:27:50 +0000 | [diff] [blame] | 3 | * Copyright 2008 VMware, Inc. |
Chia-I Wu | f2001df | 2011-07-02 17:57:30 +0900 | [diff] [blame] | 4 | * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> |
| 5 | * Copyright 2010-2011 LunarG, Inc. |
| 6 | * All Rights Reserved. |
| 7 | * |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 9 | * copy of this software and associated documentation files (the |
| 10 | * "Software"), to deal in the Software without restriction, including |
| 11 | * without limitation the rights to use, copy, modify, merge, publish, |
| 12 | * distribute, sub license, and/or sell copies of the Software, and to |
| 13 | * permit persons to whom the Software is furnished to do so, subject to |
| 14 | * the following conditions: |
| 15 | * |
| 16 | * The above copyright notice and this permission notice (including the |
| 17 | * next paragraph) shall be included in all copies or substantial portions |
| 18 | * of the Software. |
| 19 | * |
| 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 23 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 25 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 26 | * DEALINGS IN THE SOFTWARE. |
| 27 | * |
| 28 | **************************************************************************/ |
| 29 | |
| 30 | |
Brian Paul | adbff7e | 2005-04-22 21:09:39 +0000 | [diff] [blame] | 31 | #ifndef EGLDISPLAY_INCLUDED |
| 32 | #define EGLDISPLAY_INCLUDED |
| 33 | |
Emil Velikov | 7bd1693 | 2015-02-28 16:35:22 +0000 | [diff] [blame] | 34 | #include "c99_compat.h" |
Emil Velikov | efe87f1 | 2015-03-06 16:54:55 +0000 | [diff] [blame] | 35 | #include "c11/threads.h" |
Chia-I Wu | 94cb321 | 2010-01-29 09:00:30 +0800 | [diff] [blame] | 36 | |
Brian Paul | adbff7e | 2005-04-22 21:09:39 +0000 | [diff] [blame] | 37 | #include "egltypedefs.h" |
Chia-I Wu | 5a2c937 | 2009-08-13 13:38:24 +0800 | [diff] [blame] | 38 | #include "egldefines.h" |
Chia-I Wu | 6717a31 | 2010-06-30 17:10:10 +0800 | [diff] [blame] | 39 | #include "eglarray.h" |
Chia-I Wu | 5a2c937 | 2009-08-13 13:38:24 +0800 | [diff] [blame] | 40 | |
| 41 | |
Alexander von Gluck IV | 8362068 | 2015-05-13 17:13:37 -0500 | [diff] [blame] | 42 | #ifdef __cplusplus |
| 43 | extern "C" { |
| 44 | #endif |
| 45 | |
Chia-I Wu | f22665d | 2010-06-17 17:14:03 +0800 | [diff] [blame] | 46 | enum _egl_platform_type { |
Chia-I Wu | f22665d | 2010-06-17 17:14:03 +0800 | [diff] [blame] | 47 | _EGL_PLATFORM_X11, |
Benjamin Franzke | e586c4b | 2011-02-04 12:22:58 +0100 | [diff] [blame] | 48 | _EGL_PLATFORM_WAYLAND, |
Chia-I Wu | f22665d | 2010-06-17 17:14:03 +0800 | [diff] [blame] | 49 | _EGL_PLATFORM_DRM, |
Chia-I Wu | b0945c1 | 2010-10-11 16:09:52 +0800 | [diff] [blame] | 50 | _EGL_PLATFORM_ANDROID, |
Alexander von Gluck IV | 400b833 | 2014-12-22 10:10:13 -0500 | [diff] [blame] | 51 | _EGL_PLATFORM_HAIKU, |
Haixia Shi | 6b8accb | 2015-06-12 10:10:58 -0700 | [diff] [blame] | 52 | _EGL_PLATFORM_SURFACELESS, |
Emil Velikov | d6edcce | 2019-05-16 18:01:40 +0100 | [diff] [blame^] | 53 | _EGL_PLATFORM_DEVICE, |
Chia-I Wu | f22665d | 2010-06-17 17:14:03 +0800 | [diff] [blame] | 54 | |
| 55 | _EGL_NUM_PLATFORMS, |
| 56 | _EGL_INVALID_PLATFORM = -1 |
| 57 | }; |
| 58 | typedef enum _egl_platform_type _EGLPlatformType; |
| 59 | |
| 60 | |
Chia-I Wu | 7abf426 | 2010-01-24 20:30:04 +0800 | [diff] [blame] | 61 | enum _egl_resource_type { |
| 62 | _EGL_RESOURCE_CONTEXT, |
| 63 | _EGL_RESOURCE_SURFACE, |
Chia-I Wu | a1c4a8a | 2009-08-15 22:58:13 +0800 | [diff] [blame] | 64 | _EGL_RESOURCE_IMAGE, |
Chia-I Wu | 4eebea7 | 2010-08-14 23:09:12 +0800 | [diff] [blame] | 65 | _EGL_RESOURCE_SYNC, |
Chia-I Wu | 7abf426 | 2010-01-24 20:30:04 +0800 | [diff] [blame] | 66 | |
| 67 | _EGL_NUM_RESOURCES |
| 68 | }; |
Chia-I Wu | 496724b | 2010-02-19 11:47:54 +0800 | [diff] [blame] | 69 | /* this cannot and need not go into egltypedefs.h */ |
| 70 | typedef enum _egl_resource_type _EGLResourceType; |
Chia-I Wu | 7abf426 | 2010-01-24 20:30:04 +0800 | [diff] [blame] | 71 | |
| 72 | |
| 73 | /** |
| 74 | * A resource of a display. |
| 75 | */ |
| 76 | struct _egl_resource |
| 77 | { |
Chia-I Wu | f65ed0a | 2010-01-26 15:16:49 +0800 | [diff] [blame] | 78 | /* which display the resource belongs to */ |
Chia-I Wu | 7abf426 | 2010-01-24 20:30:04 +0800 | [diff] [blame] | 79 | _EGLDisplay *Display; |
Chia-I Wu | f65ed0a | 2010-01-26 15:16:49 +0800 | [diff] [blame] | 80 | EGLBoolean IsLinked; |
Chia-I Wu | dc4f845 | 2010-10-23 11:59:03 +0800 | [diff] [blame] | 81 | EGLint RefCount; |
Chia-I Wu | f65ed0a | 2010-01-26 15:16:49 +0800 | [diff] [blame] | 82 | |
Kyle Brenneman | 7206b3a | 2016-09-12 16:15:10 -0400 | [diff] [blame] | 83 | EGLLabelKHR Label; |
| 84 | |
Chia-I Wu | f65ed0a | 2010-01-26 15:16:49 +0800 | [diff] [blame] | 85 | /* used to link resources of the same type */ |
Chia-I Wu | 7abf426 | 2010-01-24 20:30:04 +0800 | [diff] [blame] | 86 | _EGLResource *Next; |
| 87 | }; |
| 88 | |
| 89 | |
Chia-I Wu | 5a2c937 | 2009-08-13 13:38:24 +0800 | [diff] [blame] | 90 | /** |
| 91 | * Optional EGL extensions info. |
| 92 | */ |
| 93 | struct _egl_extensions |
| 94 | { |
Marek Olšák | 32aa1d7 | 2015-06-09 23:08:57 +0200 | [diff] [blame] | 95 | /* Please keep these sorted alphabetically. */ |
Tapani Pälli | 6f5b570 | 2017-12-28 10:51:11 +0200 | [diff] [blame] | 96 | EGLBoolean ANDROID_blob_cache; |
Rob Herring | 8975527 | 2016-02-02 14:23:07 -0600 | [diff] [blame] | 97 | EGLBoolean ANDROID_framebuffer_target; |
Chia-I Wu | 00b365b | 2010-10-01 15:27:42 -0400 | [diff] [blame] | 98 | EGLBoolean ANDROID_image_native_buffer; |
Rob Clark | 0201f01 | 2016-11-18 08:39:33 -0500 | [diff] [blame] | 99 | EGLBoolean ANDROID_native_fence_sync; |
Rob Herring | e21e81a | 2016-02-02 14:23:08 -0600 | [diff] [blame] | 100 | EGLBoolean ANDROID_recordable; |
Fredrik Höglund | 7d46b45 | 2011-12-14 21:24:09 +0100 | [diff] [blame] | 101 | |
Sarah Sharp | c524f3e | 2014-05-06 12:10:57 -0700 | [diff] [blame] | 102 | EGLBoolean CHROMIUM_sync_control; |
| 103 | |
Marek Olšák | 32aa1d7 | 2015-06-09 23:08:57 +0200 | [diff] [blame] | 104 | EGLBoolean EXT_buffer_age; |
| 105 | EGLBoolean EXT_create_context_robustness; |
| 106 | EGLBoolean EXT_image_dma_buf_import; |
Pekka Paalanen | fb2a1c2 | 2017-05-30 17:23:35 +0530 | [diff] [blame] | 107 | EGLBoolean EXT_image_dma_buf_import_modifiers; |
Tapani Pälli | 41f7de4 | 2017-10-31 10:57:42 +0200 | [diff] [blame] | 108 | EGLBoolean EXT_pixel_format_float; |
Tapani Pälli | 799b3d1 | 2018-04-05 13:02:36 +0300 | [diff] [blame] | 109 | EGLBoolean EXT_surface_CTA861_3_metadata; |
| 110 | EGLBoolean EXT_surface_SMPTE2086_metadata; |
Marek Olšák | 32aa1d7 | 2015-06-09 23:08:57 +0200 | [diff] [blame] | 111 | EGLBoolean EXT_swap_buffers_with_damage; |
| 112 | |
Chris Wilson | 95ecf3d | 2016-10-27 19:34:46 +0100 | [diff] [blame] | 113 | unsigned int IMG_context_priority; |
| 114 | #define __EGL_CONTEXT_PRIORITY_LOW_BIT 0 |
| 115 | #define __EGL_CONTEXT_PRIORITY_MEDIUM_BIT 1 |
| 116 | #define __EGL_CONTEXT_PRIORITY_HIGH_BIT 2 |
| 117 | |
Marek Olšák | 32aa1d7 | 2015-06-09 23:08:57 +0200 | [diff] [blame] | 118 | EGLBoolean KHR_cl_event2; |
Emil Velikov | 26541a1 | 2016-12-05 14:42:04 +0000 | [diff] [blame] | 119 | EGLBoolean KHR_config_attribs; |
Adam Jackson | c0be3aa | 2016-09-22 03:47:55 -0400 | [diff] [blame] | 120 | EGLBoolean KHR_context_flush_control; |
Marek Olšák | 32aa1d7 | 2015-06-09 23:08:57 +0200 | [diff] [blame] | 121 | EGLBoolean KHR_create_context; |
Eric Engestrom | 57223fb | 2018-01-08 15:47:09 +0000 | [diff] [blame] | 122 | EGLBoolean KHR_create_context_no_error; |
Marek Olšák | 32aa1d7 | 2015-06-09 23:08:57 +0200 | [diff] [blame] | 123 | EGLBoolean KHR_fence_sync; |
| 124 | EGLBoolean KHR_get_all_proc_addresses; |
| 125 | EGLBoolean KHR_gl_colorspace; |
| 126 | EGLBoolean KHR_gl_renderbuffer_image; |
| 127 | EGLBoolean KHR_gl_texture_2D_image; |
| 128 | EGLBoolean KHR_gl_texture_3D_image; |
| 129 | EGLBoolean KHR_gl_texture_cubemap_image; |
Harish Krupo | 96fc5fb | 2017-12-08 21:29:39 +0530 | [diff] [blame] | 130 | EGLBoolean KHR_image; |
Marek Olšák | 32aa1d7 | 2015-06-09 23:08:57 +0200 | [diff] [blame] | 131 | EGLBoolean KHR_image_base; |
| 132 | EGLBoolean KHR_image_pixmap; |
Chad Versace | 3dc2238 | 2018-04-30 22:32:25 -0700 | [diff] [blame] | 133 | EGLBoolean KHR_mutable_render_buffer; |
Adam Jackson | d9f5b19 | 2016-09-09 12:25:34 -0400 | [diff] [blame] | 134 | EGLBoolean KHR_no_config_context; |
Harish Krupo | 9827547 | 2017-06-09 20:13:34 +0530 | [diff] [blame] | 135 | EGLBoolean KHR_partial_update; |
Marek Olšák | 32aa1d7 | 2015-06-09 23:08:57 +0200 | [diff] [blame] | 136 | EGLBoolean KHR_reusable_sync; |
| 137 | EGLBoolean KHR_surfaceless_context; |
Marek Olšák | 32aa1d7 | 2015-06-09 23:08:57 +0200 | [diff] [blame] | 138 | EGLBoolean KHR_wait_sync; |
| 139 | |
Marek Olšák | 32aa1d7 | 2015-06-09 23:08:57 +0200 | [diff] [blame] | 140 | EGLBoolean MESA_drm_image; |
| 141 | EGLBoolean MESA_image_dma_buf_export; |
Veluri Mithun | 6afce78 | 2019-01-23 22:44:25 +0530 | [diff] [blame] | 142 | EGLBoolean MESA_query_driver; |
Marek Olšák | 32aa1d7 | 2015-06-09 23:08:57 +0200 | [diff] [blame] | 143 | |
| 144 | EGLBoolean NOK_swap_region; |
| 145 | EGLBoolean NOK_texture_from_pixmap; |
| 146 | |
Fredrik Höglund | 7d46b45 | 2011-12-14 21:24:09 +0100 | [diff] [blame] | 147 | EGLBoolean NV_post_sub_buffer; |
Ian Romanick | f171571 | 2012-07-19 15:08:06 -0700 | [diff] [blame] | 148 | |
Marek Olšák | 32aa1d7 | 2015-06-09 23:08:57 +0200 | [diff] [blame] | 149 | EGLBoolean WL_bind_wayland_display; |
| 150 | EGLBoolean WL_create_wayland_buffer_from_image; |
Chia-I Wu | 5a2c937 | 2009-08-13 13:38:24 +0800 | [diff] [blame] | 151 | }; |
Brian Paul | adbff7e | 2005-04-22 21:09:39 +0000 | [diff] [blame] | 152 | |
Chia-I Wu | f22665d | 2010-06-17 17:14:03 +0800 | [diff] [blame] | 153 | struct _egl_display |
Brian Paul | adbff7e | 2005-04-22 21:09:39 +0000 | [diff] [blame] | 154 | { |
Chia-I Wu | 38feefd | 2009-08-14 17:47:00 +0800 | [diff] [blame] | 155 | /* used to link displays */ |
| 156 | _EGLDisplay *Next; |
| 157 | |
Emil Velikov | efe87f1 | 2015-03-06 16:54:55 +0000 | [diff] [blame] | 158 | mtx_t Mutex; |
Chia-I Wu | 99bcb1f | 2010-02-17 17:29:52 +0800 | [diff] [blame] | 159 | |
Chia-I Wu | a4a38dc | 2011-01-13 16:53:13 +0800 | [diff] [blame] | 160 | _EGLPlatformType Platform; /**< The type of the platform display */ |
| 161 | void *PlatformDisplay; /**< A pointer to the platform display */ |
Brian Paul | adbff7e | 2005-04-22 21:09:39 +0000 | [diff] [blame] | 162 | |
Emil Velikov | 7552fcb | 2015-07-24 16:19:55 +0200 | [diff] [blame] | 163 | _EGLDevice *Device; /**< Device backing the display */ |
Chia-I Wu | a4a38dc | 2011-01-13 16:53:13 +0800 | [diff] [blame] | 164 | _EGLDriver *Driver; /**< Matched driver of the display */ |
| 165 | EGLBoolean Initialized; /**< True if the display is initialized */ |
Chia-I Wu | 5a2c937 | 2009-08-13 13:38:24 +0800 | [diff] [blame] | 166 | |
Chia-I Wu | 655e459 | 2011-01-13 00:27:45 +0800 | [diff] [blame] | 167 | /* options that affect how the driver initializes the display */ |
| 168 | struct { |
Eric Engestrom | 81cea66 | 2017-12-20 15:53:09 +0000 | [diff] [blame] | 169 | EGLBoolean ForceSoftware; /**< Use software path only */ |
Adam Jackson | 8e991ce | 2019-05-16 18:01:34 +0100 | [diff] [blame] | 170 | EGLAttrib *Attribs; /**< Platform-specific options */ |
Emil Velikov | d6edcce | 2019-05-16 18:01:40 +0100 | [diff] [blame^] | 171 | int fd; /**< plaform device specific, local fd */ |
Chia-I Wu | 655e459 | 2011-01-13 00:27:45 +0800 | [diff] [blame] | 172 | } Options; |
| 173 | |
Chia-I Wu | a4a38dc | 2011-01-13 16:53:13 +0800 | [diff] [blame] | 174 | /* these fields are set by the driver during init */ |
| 175 | void *DriverData; /**< Driver private data */ |
Marek Olšák | 0e4b564 | 2015-05-12 16:40:29 +0200 | [diff] [blame] | 176 | EGLint Version; /**< EGL version major*10+minor */ |
Chia-I Wu | a4a38dc | 2011-01-13 16:53:13 +0800 | [diff] [blame] | 177 | EGLint ClientAPIs; /**< Bitmask of APIs supported (EGL_xxx_BIT) */ |
| 178 | _EGLExtensions Extensions; /**< Extensions supported */ |
Chia-I Wu | 5a2c937 | 2009-08-13 13:38:24 +0800 | [diff] [blame] | 179 | |
Chia-I Wu | a4a38dc | 2011-01-13 16:53:13 +0800 | [diff] [blame] | 180 | /* these fields are derived from above */ |
Emil Velikov | bbaf22a | 2015-03-19 01:36:08 +0000 | [diff] [blame] | 181 | char VersionString[100]; /**< EGL_VERSION */ |
| 182 | char ClientAPIsString[100]; /**< EGL_CLIENT_APIS */ |
Chia-I Wu | a4a38dc | 2011-01-13 16:53:13 +0800 | [diff] [blame] | 183 | char ExtensionsString[_EGL_MAX_EXTENSIONS_LEN]; /**< EGL_EXTENSIONS */ |
Chia-I Wu | 5a2c937 | 2009-08-13 13:38:24 +0800 | [diff] [blame] | 184 | |
Chia-I Wu | 6717a31 | 2010-06-30 17:10:10 +0800 | [diff] [blame] | 185 | _EGLArray *Configs; |
Brian Paul | 6052af1 | 2008-05-27 16:48:23 -0600 | [diff] [blame] | 186 | |
Chia-I Wu | ecb3b31 | 2010-01-24 20:32:34 +0800 | [diff] [blame] | 187 | /* lists of resources */ |
Chia-I Wu | 7abf426 | 2010-01-24 20:30:04 +0800 | [diff] [blame] | 188 | _EGLResource *ResourceLists[_EGL_NUM_RESOURCES]; |
Kyle Brenneman | 7206b3a | 2016-09-12 16:15:10 -0400 | [diff] [blame] | 189 | |
| 190 | EGLLabelKHR Label; |
Tapani Pälli | 6f5b570 | 2017-12-28 10:51:11 +0200 | [diff] [blame] | 191 | |
| 192 | EGLSetBlobFuncANDROID BlobCacheSet; |
| 193 | EGLGetBlobFuncANDROID BlobCacheGet; |
Brian Paul | adbff7e | 2005-04-22 21:09:39 +0000 | [diff] [blame] | 194 | }; |
| 195 | |
| 196 | |
Chia-I Wu | ea05299 | 2010-06-17 23:45:41 +0800 | [diff] [blame] | 197 | extern _EGLPlatformType |
Chad Versace | 6d1f83e | 2014-01-07 14:54:51 -0800 | [diff] [blame] | 198 | _eglGetNativePlatform(void *nativeDisplay); |
Chia-I Wu | ea05299 | 2010-06-17 23:45:41 +0800 | [diff] [blame] | 199 | |
| 200 | |
Chia-I Wu | 38feefd | 2009-08-14 17:47:00 +0800 | [diff] [blame] | 201 | extern void |
| 202 | _eglFiniDisplay(void); |
| 203 | |
| 204 | |
Brian Paul | adbff7e | 2005-04-22 21:09:39 +0000 | [diff] [blame] | 205 | extern _EGLDisplay * |
Adam Jackson | 8e991ce | 2019-05-16 18:01:34 +0100 | [diff] [blame] | 206 | _eglFindDisplay(_EGLPlatformType plat, void *plat_dpy, const EGLAttrib *attr); |
Chia-I Wu | be9d1ab | 2009-07-16 21:21:56 -0700 | [diff] [blame] | 207 | |
| 208 | |
Emil Velikov | dd438ae | 2015-02-28 17:20:01 +0000 | [diff] [blame] | 209 | extern void |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 210 | _eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *disp); |
Chia-I Wu | 3f7e0d5 | 2009-07-16 21:21:57 -0700 | [diff] [blame] | 211 | |
| 212 | |
Emil Velikov | dd438ae | 2015-02-28 17:20:01 +0000 | [diff] [blame] | 213 | extern void |
Jon Smirl | 7012d01 | 2005-05-13 18:31:35 +0000 | [diff] [blame] | 214 | _eglCleanupDisplay(_EGLDisplay *disp); |
| 215 | |
| 216 | |
Chia-I Wu | e484a92 | 2009-08-14 18:02:38 +0800 | [diff] [blame] | 217 | extern EGLBoolean |
| 218 | _eglCheckDisplayHandle(EGLDisplay dpy); |
| 219 | |
| 220 | |
Emil Velikov | dd438ae | 2015-02-28 17:20:01 +0000 | [diff] [blame] | 221 | extern EGLBoolean |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 222 | _eglCheckResource(void *res, _EGLResourceType type, _EGLDisplay *disp); |
Chia-I Wu | 7abf426 | 2010-01-24 20:30:04 +0800 | [diff] [blame] | 223 | |
| 224 | |
Chia-I Wu | e3734e4 | 2009-08-14 18:05:19 +0800 | [diff] [blame] | 225 | /** |
| 226 | * Lookup a handle to find the linked display. |
| 227 | * Return NULL if the handle has no corresponding linked display. |
| 228 | */ |
Emil Velikov | 7bd1693 | 2015-02-28 16:35:22 +0000 | [diff] [blame] | 229 | static inline _EGLDisplay * |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 230 | _eglLookupDisplay(EGLDisplay dpy) |
Chia-I Wu | e3734e4 | 2009-08-14 18:05:19 +0800 | [diff] [blame] | 231 | { |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 232 | _EGLDisplay *disp = (_EGLDisplay *) dpy; |
| 233 | if (!_eglCheckDisplayHandle(dpy)) |
| 234 | disp = NULL; |
| 235 | return disp; |
Chia-I Wu | e3734e4 | 2009-08-14 18:05:19 +0800 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | |
| 239 | /** |
| 240 | * Return the handle of a linked display, or EGL_NO_DISPLAY. |
| 241 | */ |
Emil Velikov | 7bd1693 | 2015-02-28 16:35:22 +0000 | [diff] [blame] | 242 | static inline EGLDisplay |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 243 | _eglGetDisplayHandle(_EGLDisplay *disp) |
Chia-I Wu | e3734e4 | 2009-08-14 18:05:19 +0800 | [diff] [blame] | 244 | { |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 245 | return (EGLDisplay) ((disp) ? disp : EGL_NO_DISPLAY); |
Chia-I Wu | e3734e4 | 2009-08-14 18:05:19 +0800 | [diff] [blame] | 246 | } |
| 247 | |
| 248 | |
Chia-I Wu | 7abf426 | 2010-01-24 20:30:04 +0800 | [diff] [blame] | 249 | extern void |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 250 | _eglInitResource(_EGLResource *res, EGLint size, _EGLDisplay *disp); |
Chia-I Wu | dc4f845 | 2010-10-23 11:59:03 +0800 | [diff] [blame] | 251 | |
| 252 | |
Emil Velikov | dd438ae | 2015-02-28 17:20:01 +0000 | [diff] [blame] | 253 | extern void |
Chia-I Wu | dc4f845 | 2010-10-23 11:59:03 +0800 | [diff] [blame] | 254 | _eglGetResource(_EGLResource *res); |
| 255 | |
| 256 | |
Emil Velikov | dd438ae | 2015-02-28 17:20:01 +0000 | [diff] [blame] | 257 | extern EGLBoolean |
Chia-I Wu | dc4f845 | 2010-10-23 11:59:03 +0800 | [diff] [blame] | 258 | _eglPutResource(_EGLResource *res); |
| 259 | |
| 260 | |
| 261 | extern void |
Chia-I Wu | 4ce33ec | 2010-10-23 00:37:19 +0800 | [diff] [blame] | 262 | _eglLinkResource(_EGLResource *res, _EGLResourceType type); |
Chia-I Wu | 7abf426 | 2010-01-24 20:30:04 +0800 | [diff] [blame] | 263 | |
| 264 | |
| 265 | extern void |
| 266 | _eglUnlinkResource(_EGLResource *res, _EGLResourceType type); |
| 267 | |
| 268 | |
| 269 | /** |
| 270 | * Return true if the resource is linked. |
| 271 | */ |
Emil Velikov | 7bd1693 | 2015-02-28 16:35:22 +0000 | [diff] [blame] | 272 | static inline EGLBoolean |
Chia-I Wu | 7abf426 | 2010-01-24 20:30:04 +0800 | [diff] [blame] | 273 | _eglIsResourceLinked(_EGLResource *res) |
| 274 | { |
Chia-I Wu | f65ed0a | 2010-01-26 15:16:49 +0800 | [diff] [blame] | 275 | return res->IsLinked; |
Chia-I Wu | 7abf426 | 2010-01-24 20:30:04 +0800 | [diff] [blame] | 276 | } |
| 277 | |
Emil Velikov | 72b9aa9 | 2019-05-16 18:01:33 +0100 | [diff] [blame] | 278 | static inline size_t |
| 279 | _eglNumAttribs(const EGLAttrib *attribs) |
| 280 | { |
| 281 | size_t len = 0; |
| 282 | |
| 283 | if (attribs) { |
| 284 | while (attribs[len] != EGL_NONE) |
| 285 | len += 2; |
| 286 | len++; |
| 287 | } |
| 288 | return len; |
| 289 | } |
| 290 | |
Chad Versace | 468cc86 | 2014-01-23 07:26:10 -0800 | [diff] [blame] | 291 | #ifdef HAVE_X11_PLATFORM |
| 292 | _EGLDisplay* |
Adam Jackson | ddcd4b0 | 2017-11-16 13:27:27 -0500 | [diff] [blame] | 293 | _eglGetX11Display(Display *native_display, const EGLAttrib *attrib_list); |
Chad Versace | 468cc86 | 2014-01-23 07:26:10 -0800 | [diff] [blame] | 294 | #endif |
| 295 | |
| 296 | #ifdef HAVE_DRM_PLATFORM |
| 297 | struct gbm_device; |
| 298 | |
| 299 | _EGLDisplay* |
| 300 | _eglGetGbmDisplay(struct gbm_device *native_display, |
Adam Jackson | ddcd4b0 | 2017-11-16 13:27:27 -0500 | [diff] [blame] | 301 | const EGLAttrib *attrib_list); |
Chad Versace | 468cc86 | 2014-01-23 07:26:10 -0800 | [diff] [blame] | 302 | #endif |
| 303 | |
| 304 | #ifdef HAVE_WAYLAND_PLATFORM |
| 305 | struct wl_display; |
| 306 | |
| 307 | _EGLDisplay* |
| 308 | _eglGetWaylandDisplay(struct wl_display *native_display, |
Adam Jackson | ddcd4b0 | 2017-11-16 13:27:27 -0500 | [diff] [blame] | 309 | const EGLAttrib *attrib_list); |
Chad Versace | 468cc86 | 2014-01-23 07:26:10 -0800 | [diff] [blame] | 310 | #endif |
Chia-I Wu | 7abf426 | 2010-01-24 20:30:04 +0800 | [diff] [blame] | 311 | |
Chad Versace | a597c8a | 2016-10-12 15:48:15 -0700 | [diff] [blame] | 312 | #ifdef HAVE_SURFACELESS_PLATFORM |
| 313 | _EGLDisplay* |
| 314 | _eglGetSurfacelessDisplay(void *native_display, |
Adam Jackson | ddcd4b0 | 2017-11-16 13:27:27 -0500 | [diff] [blame] | 315 | const EGLAttrib *attrib_list); |
Chad Versace | a597c8a | 2016-10-12 15:48:15 -0700 | [diff] [blame] | 316 | #endif |
Alexander von Gluck IV | 8362068 | 2015-05-13 17:13:37 -0500 | [diff] [blame] | 317 | |
Emil Velikov | d6edcce | 2019-05-16 18:01:40 +0100 | [diff] [blame^] | 318 | _EGLDisplay* |
| 319 | _eglGetDeviceDisplay(void *native_display, |
| 320 | const EGLAttrib *attrib_list); |
| 321 | |
Alexander von Gluck IV | 8362068 | 2015-05-13 17:13:37 -0500 | [diff] [blame] | 322 | #ifdef __cplusplus |
| 323 | } |
| 324 | #endif |
| 325 | |
Brian Paul | adbff7e | 2005-04-22 21:09:39 +0000 | [diff] [blame] | 326 | #endif /* EGLDISPLAY_INCLUDED */ |