Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /**************************************************************************
  2.  *
  3.  * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
  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.  
  31. #ifndef EGLDISPLAY_INCLUDED
  32. #define EGLDISPLAY_INCLUDED
  33.  
  34.  
  35. #include "egltypedefs.h"
  36. #include "egldefines.h"
  37. #include "eglmutex.h"
  38. #include "eglarray.h"
  39.  
  40.  
  41. enum _egl_platform_type {
  42.    _EGL_PLATFORM_DRM,
  43.  
  44.    _EGL_NUM_PLATFORMS,
  45.    _EGL_INVALID_PLATFORM = -1
  46. };
  47. typedef enum _egl_platform_type _EGLPlatformType;
  48.  
  49.  
  50. enum _egl_resource_type {
  51.    _EGL_RESOURCE_CONTEXT,
  52.    _EGL_RESOURCE_SURFACE,
  53.    _EGL_RESOURCE_IMAGE,
  54.    _EGL_RESOURCE_SYNC,
  55.  
  56.    _EGL_NUM_RESOURCES
  57. };
  58. /* this cannot and need not go into egltypedefs.h */
  59. typedef enum _egl_resource_type _EGLResourceType;
  60.  
  61.  
  62. /**
  63.  * A resource of a display.
  64.  */
  65. struct _egl_resource
  66. {
  67.    /* which display the resource belongs to */
  68.    _EGLDisplay *Display;
  69.    EGLBoolean IsLinked;
  70.    EGLint RefCount;
  71.  
  72.    /* used to link resources of the same type */
  73.    _EGLResource *Next;
  74. };
  75.  
  76.  
  77. /**
  78.  * Optional EGL extensions info.
  79.  */
  80. struct _egl_extensions
  81. {
  82.    EGLBoolean MESA_screen_surface;
  83.    EGLBoolean MESA_copy_context;
  84.    EGLBoolean MESA_drm_display;
  85.    EGLBoolean MESA_drm_image;
  86.  
  87.    EGLBoolean WL_bind_wayland_display;
  88.  
  89.    EGLBoolean KHR_image_base;
  90.    EGLBoolean KHR_image_pixmap;
  91.    EGLBoolean KHR_vg_parent_image;
  92.    EGLBoolean KHR_gl_texture_2D_image;
  93.    EGLBoolean KHR_gl_texture_cubemap_image;
  94.    EGLBoolean KHR_gl_texture_3D_image;
  95.    EGLBoolean KHR_gl_renderbuffer_image;
  96.  
  97.    EGLBoolean KHR_reusable_sync;
  98.    EGLBoolean KHR_fence_sync;
  99.  
  100.    EGLBoolean KHR_surfaceless_context;
  101.    EGLBoolean KHR_create_context;
  102.  
  103.    EGLBoolean NOK_swap_region;
  104.    EGLBoolean NOK_texture_from_pixmap;
  105.  
  106.    EGLBoolean ANDROID_image_native_buffer;
  107.  
  108.    EGLBoolean NV_post_sub_buffer;
  109.  
  110.    EGLBoolean EXT_create_context_robustness;
  111.    EGLBoolean EXT_buffer_age;
  112.    EGLBoolean EXT_swap_buffers_with_damage;
  113. };
  114.  
  115.  
  116. struct _egl_display
  117. {
  118.    /* used to link displays */
  119.    _EGLDisplay *Next;
  120.  
  121.    _EGLMutex Mutex;
  122.  
  123.    _EGLPlatformType Platform; /**< The type of the platform display */
  124.    void *PlatformDisplay;     /**< A pointer to the platform display */
  125.  
  126.    _EGLDriver *Driver;        /**< Matched driver of the display */
  127.    EGLBoolean Initialized;    /**< True if the display is initialized */
  128.  
  129.    /* options that affect how the driver initializes the display */
  130.    struct {
  131.       EGLBoolean TestOnly;    /**< Driver should not set fields when true */
  132.       EGLBoolean UseFallback; /**< Use fallback driver (sw or less features) */
  133.    } Options;
  134.  
  135.    /* these fields are set by the driver during init */
  136.    void *DriverData;          /**< Driver private data */
  137.    EGLint VersionMajor;       /**< EGL major version */
  138.    EGLint VersionMinor;       /**< EGL minor version */
  139.    EGLint ClientAPIs;         /**< Bitmask of APIs supported (EGL_xxx_BIT) */
  140.    _EGLExtensions Extensions; /**< Extensions supported */
  141.  
  142.    /* these fields are derived from above */
  143.    char VersionString[1000];                       /**< EGL_VERSION */
  144.    char ClientAPIsString[1000];                    /**< EGL_CLIENT_APIS */
  145.    char ExtensionsString[_EGL_MAX_EXTENSIONS_LEN]; /**< EGL_EXTENSIONS */
  146.  
  147.    _EGLArray *Screens;
  148.    _EGLArray *Configs;
  149.  
  150.    /* lists of resources */
  151.    _EGLResource *ResourceLists[_EGL_NUM_RESOURCES];
  152. };
  153.  
  154.  
  155. extern _EGLPlatformType
  156. _eglGetNativePlatform(EGLNativeDisplayType nativeDisplay);
  157.  
  158.  
  159. extern void
  160. _eglFiniDisplay(void);
  161.  
  162.  
  163. extern _EGLDisplay *
  164. _eglFindDisplay(_EGLPlatformType plat, void *plat_dpy);
  165.  
  166.  
  167. PUBLIC void
  168. _eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *dpy);
  169.  
  170.  
  171. PUBLIC void
  172. _eglCleanupDisplay(_EGLDisplay *disp);
  173.  
  174.  
  175. extern EGLBoolean
  176. _eglCheckDisplayHandle(EGLDisplay dpy);
  177.  
  178.  
  179. PUBLIC EGLBoolean
  180. _eglCheckResource(void *res, _EGLResourceType type, _EGLDisplay *dpy);
  181.  
  182.  
  183. /**
  184.  * Lookup a handle to find the linked display.
  185.  * Return NULL if the handle has no corresponding linked display.
  186.  */
  187. static INLINE _EGLDisplay *
  188. _eglLookupDisplay(EGLDisplay display)
  189. {
  190.    _EGLDisplay *dpy = (_EGLDisplay *) display;
  191.    if (!_eglCheckDisplayHandle(display))
  192.       dpy = NULL;
  193.    return dpy;
  194. }
  195.  
  196.  
  197. /**
  198.  * Return the handle of a linked display, or EGL_NO_DISPLAY.
  199.  */
  200. static INLINE EGLDisplay
  201. _eglGetDisplayHandle(_EGLDisplay *dpy)
  202. {
  203.    return (EGLDisplay) ((dpy) ? dpy : EGL_NO_DISPLAY);
  204. }
  205.  
  206.  
  207. extern void
  208. _eglInitResource(_EGLResource *res, EGLint size, _EGLDisplay *dpy);
  209.  
  210.  
  211. PUBLIC void
  212. _eglGetResource(_EGLResource *res);
  213.  
  214.  
  215. PUBLIC EGLBoolean
  216. _eglPutResource(_EGLResource *res);
  217.  
  218.  
  219. extern void
  220. _eglLinkResource(_EGLResource *res, _EGLResourceType type);
  221.  
  222.  
  223. extern void
  224. _eglUnlinkResource(_EGLResource *res, _EGLResourceType type);
  225.  
  226.  
  227. /**
  228.  * Return true if the resource is linked.
  229.  */
  230. static INLINE EGLBoolean
  231. _eglIsResourceLinked(_EGLResource *res)
  232. {
  233.    return res->IsLinked;
  234. }
  235.  
  236.  
  237. #endif /* EGLDISPLAY_INCLUDED */
  238.