Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /**************************************************************************
  2.  *
  3.  * Copyright 2010 LunarG, Inc.
  4.  * All Rights Reserved.
  5.  *
  6.  * Permission is hereby granted, free of charge, to any person obtaining a
  7.  * copy of this software and associated documentation files (the
  8.  * "Software"), to deal in the Software without restriction, including
  9.  * without limitation the rights to use, copy, modify, merge, publish,
  10.  * distribute, sub license, and/or sell copies of the Software, and to
  11.  * permit persons to whom the Software is furnished to do so, subject to
  12.  * the following conditions:
  13.  *
  14.  * The above copyright notice and this permission notice (including the
  15.  * next paragraph) shall be included in all copies or substantial portions
  16.  * of the Software.
  17.  *
  18.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  21.  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22.  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  23.  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  24.  * DEALINGS IN THE SOFTWARE.
  25.  *
  26.  **************************************************************************/
  27.  
  28.  
  29. #ifndef EGLSYNC_INCLUDED
  30. #define EGLSYNC_INCLUDED
  31.  
  32.  
  33. #include "c99_compat.h"
  34.  
  35. #include "egltypedefs.h"
  36. #include "egldisplay.h"
  37.  
  38.  
  39. /**
  40.  * "Base" class for device driver syncs.
  41.  */
  42. struct _egl_sync
  43. {
  44.    /* A sync is a display resource */
  45.    _EGLResource Resource;
  46.  
  47.    EGLenum Type;
  48.    EGLenum SyncStatus;
  49.    EGLenum SyncCondition;
  50.    EGLAttribKHR CLEvent;
  51. };
  52.  
  53.  
  54. extern EGLBoolean
  55. _eglInitSync(_EGLSync *sync, _EGLDisplay *dpy, EGLenum type,
  56.              const EGLint *attrib_list, const EGLAttribKHR *attrib_list64);
  57.  
  58.  
  59. extern EGLBoolean
  60. _eglGetSyncAttribKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
  61.                      EGLint attribute, EGLint *value);
  62.  
  63.  
  64. /**
  65.  * Increment reference count for the sync.
  66.  */
  67. static inline _EGLSync *
  68. _eglGetSync(_EGLSync *sync)
  69. {
  70.    if (sync)
  71.       _eglGetResource(&sync->Resource);
  72.    return sync;
  73. }
  74.  
  75.  
  76. /**
  77.  * Decrement reference count for the sync.
  78.  */
  79. static inline EGLBoolean
  80. _eglPutSync(_EGLSync *sync)
  81. {
  82.    return (sync) ? _eglPutResource(&sync->Resource) : EGL_FALSE;
  83. }
  84.  
  85.  
  86. /**
  87.  * Link a sync to its display and return the handle of the link.
  88.  * The handle can be passed to client directly.
  89.  */
  90. static inline EGLSyncKHR
  91. _eglLinkSync(_EGLSync *sync)
  92. {
  93.    _eglLinkResource(&sync->Resource, _EGL_RESOURCE_SYNC);
  94.    return (EGLSyncKHR) sync;
  95. }
  96.  
  97.  
  98. /**
  99.  * Unlink a linked sync from its display.
  100.  */
  101. static inline void
  102. _eglUnlinkSync(_EGLSync *sync)
  103. {
  104.    _eglUnlinkResource(&sync->Resource, _EGL_RESOURCE_SYNC);
  105. }
  106.  
  107.  
  108. /**
  109.  * Lookup a handle to find the linked sync.
  110.  * Return NULL if the handle has no corresponding linked sync.
  111.  */
  112. static inline _EGLSync *
  113. _eglLookupSync(EGLSyncKHR handle, _EGLDisplay *dpy)
  114. {
  115.    _EGLSync *sync = (_EGLSync *) handle;
  116.    if (!dpy || !_eglCheckResource((void *) sync, _EGL_RESOURCE_SYNC, dpy))
  117.       sync = NULL;
  118.    return sync;
  119. }
  120.  
  121.  
  122. /**
  123.  * Return the handle of a linked sync, or EGL_NO_SYNC_KHR.
  124.  */
  125. static inline EGLSyncKHR
  126. _eglGetSyncHandle(_EGLSync *sync)
  127. {
  128.    _EGLResource *res = (_EGLResource *) sync;
  129.    return (res && _eglIsResourceLinked(res)) ?
  130.       (EGLSyncKHR) sync : EGL_NO_SYNC_KHR;
  131. }
  132.  
  133.  
  134. #endif /* EGLSYNC_INCLUDED */
  135.