xserver

xserver with xephyr scale patch
git clone https://git.neptards.moe/u3shit/xserver.git
Log | Files | Refs | README | LICENSE

glamor_egl.h (3204B)


      1 /*
      2  * Copyright © 2016 Red Hat, Inc.
      3  *
      4  * Permission is hereby granted, free of charge, to any person obtaining a
      5  * copy of this software and associated documentation files (the "Software"),
      6  * to deal in the Software without restriction, including without limitation
      7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      8  * and/or sell copies of the Software, and to permit persons to whom the
      9  * Software is furnished to do so, subject to the following conditions:
     10  *
     11  * The above copyright notice and this permission notice (including the next
     12  * paragraph) shall be included in all copies or substantial portions of the
     13  * Software.
     14  *
     15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
     20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
     21  * DEALINGS IN THE SOFTWARE.
     22  *
     23  * Authors:
     24  *	Adam Jackson <ajax@redhat.com>
     25  */
     26 
     27 #ifndef GLAMOR_EGL_H
     28 #define GLAMOR_EGL_H
     29 
     30 #define MESA_EGL_NO_X11_HEADERS
     31 #define EGL_NO_X11
     32 #include <epoxy/gl.h>
     33 #include <epoxy/egl.h>
     34 #include <glamor_egl_ext.h>
     35 
     36 /*
     37  * Create an EGLDisplay from a native display type. This is a little quirky
     38  * for a few reasons.
     39  *
     40  * 1: GetPlatformDisplayEXT and GetPlatformDisplay are the API you want to
     41  * use, but have different function signatures in the third argument; this
     42  * happens not to matter for us, at the moment, but it means epoxy won't alias
     43  * them together.
     44  *
     45  * 2: epoxy 1.3 and earlier don't understand EGL client extensions, which
     46  * means you can't call "eglGetPlatformDisplayEXT" directly, as the resolver
     47  * will crash.
     48  *
     49  * 3: You can't tell whether you have EGL 1.5 at this point, because
     50  * eglQueryString(EGL_VERSION) is a property of the display, which we don't
     51  * have yet. So you have to query for extensions no matter what. Fortunately
     52  * epoxy_has_egl_extension _does_ let you query for client extensions, so
     53  * we don't have to write our own extension string parsing.
     54  *
     55  * 4. There is no EGL_KHR_platform_base to complement the EXT one, thus one
     56  * needs to know EGL 1.5 is supported in order to use the eglGetPlatformDisplay
     57  * function pointer.
     58  * We can workaround this (circular dependency) by probing for the EGL 1.5
     59  * platform extensions (EGL_KHR_platform_gbm and friends) yet it doesn't seem
     60  * like mesa will be able to adverise these (even though it can do EGL 1.5).
     61  */
     62 static inline EGLDisplay
     63 glamor_egl_get_display(EGLint type, void *native)
     64 {
     65     /* In practise any EGL 1.5 implementation would support the EXT extension */
     66     if (epoxy_has_egl_extension(NULL, "EGL_EXT_platform_base")) {
     67         PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplayEXT =
     68             (void *) eglGetProcAddress("eglGetPlatformDisplayEXT");
     69         if (getPlatformDisplayEXT)
     70             return getPlatformDisplayEXT(type, native, NULL);
     71     }
     72 
     73     /* Welp, everything is awful. */
     74     return eglGetDisplay(native);
     75 }
     76 
     77 #endif