Subversion Repositories Kolibri OS

Rev

Rev 5563 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /**************************************************************************
  2.  *
  3.  * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
  4.  * Copyright 2010-2011 LunarG, Inc.
  5.  * All Rights Reserved.
  6.  *
  7.  * Permission is hereby granted, free of charge, to any person obtaining a
  8.  * copy of this software and associated documentation files (the
  9.  * "Software"), to deal in the Software without restriction, including
  10.  * without limitation the rights to use, copy, modify, merge, publish,
  11.  * distribute, sub license, and/or sell copies of the Software, and to
  12.  * permit persons to whom the Software is furnished to do so, subject to
  13.  * the following conditions:
  14.  *
  15.  * The above copyright notice and this permission notice (including the
  16.  * next paragraph) shall be included in all copies or substantial portions
  17.  * of the Software.
  18.  *
  19.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  22.  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23.  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  24.  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  25.  * DEALINGS IN THE SOFTWARE.
  26.  *
  27.  **************************************************************************/
  28.  
  29.  
  30. #ifndef EGLIMAGE_INCLUDED
  31. #define EGLIMAGE_INCLUDED
  32.  
  33.  
  34. #include "egltypedefs.h"
  35. #include "egldisplay.h"
  36.  
  37.  
  38. struct _egl_image_attribs
  39. {
  40.    /* EGL_KHR_image_base */
  41.    EGLBoolean ImagePreserved;
  42.  
  43.    /* EGL_KHR_gl_image */
  44.    EGLint GLTextureLevel;
  45.    EGLint GLTextureZOffset;
  46.  
  47.    /* EGL_MESA_drm_image */
  48.    EGLint Width;
  49.    EGLint Height;
  50.    EGLint DRMBufferFormatMESA;
  51.    EGLint DRMBufferUseMESA;
  52.    EGLint DRMBufferStrideMESA;
  53.  
  54.    /* EGL_WL_bind_wayland_display */
  55.    EGLint PlaneWL;
  56.  
  57.     /* Kolibri specific */
  58.  
  59.    EGLint Plane0_offset;
  60.    EGLint Plane1_offset;
  61.    EGLint Plane2_offset;
  62.    EGLint Plane0_pitch;
  63.    EGLint Plane1_pitch;
  64.    EGLint Plane2_pitch;
  65. };
  66.  
  67. /**
  68.  * "Base" class for device driver images.
  69.  */
  70. struct _egl_image
  71. {
  72.    /* An image is a display resource */
  73.    _EGLResource Resource;
  74. };
  75.  
  76.  
  77. PUBLIC EGLint
  78. _eglParseImageAttribList(_EGLImageAttribs *attrs, _EGLDisplay *dpy,
  79.                          const EGLint *attrib_list);
  80.  
  81.  
  82. PUBLIC EGLBoolean
  83. _eglInitImage(_EGLImage *img, _EGLDisplay *dpy);
  84.  
  85.  
  86. /**
  87.  * Increment reference count for the image.
  88.  */
  89. static INLINE _EGLImage *
  90. _eglGetImage(_EGLImage *img)
  91. {
  92.    if (img)
  93.       _eglGetResource(&img->Resource);
  94.    return img;
  95. }
  96.  
  97.  
  98. /**
  99.  * Decrement reference count for the image.
  100.  */
  101. static INLINE EGLBoolean
  102. _eglPutImage(_EGLImage *img)
  103. {
  104.    return (img) ? _eglPutResource(&img->Resource) : EGL_FALSE;
  105. }
  106.  
  107.  
  108. /**
  109.  * Link an image to its display and return the handle of the link.
  110.  * The handle can be passed to client directly.
  111.  */
  112. static INLINE EGLImageKHR
  113. _eglLinkImage(_EGLImage *img)
  114. {
  115.    _eglLinkResource(&img->Resource, _EGL_RESOURCE_IMAGE);
  116.    return (EGLImageKHR) img;
  117. }
  118.  
  119.  
  120. /**
  121.  * Unlink a linked image from its display.
  122.  * Accessing an unlinked image should generate EGL_BAD_PARAMETER error.
  123.  */
  124. static INLINE void
  125. _eglUnlinkImage(_EGLImage *img)
  126. {
  127.    _eglUnlinkResource(&img->Resource, _EGL_RESOURCE_IMAGE);
  128. }
  129.  
  130.  
  131. /**
  132.  * Lookup a handle to find the linked image.
  133.  * Return NULL if the handle has no corresponding linked image.
  134.  */
  135. static INLINE _EGLImage *
  136. _eglLookupImage(EGLImageKHR image, _EGLDisplay *dpy)
  137. {
  138.    _EGLImage *img = (_EGLImage *) image;
  139.    if (!dpy || !_eglCheckResource((void *) img, _EGL_RESOURCE_IMAGE, dpy))
  140.       img = NULL;
  141.    return img;
  142. }
  143.  
  144.  
  145. /**
  146.  * Return the handle of a linked image, or EGL_NO_IMAGE_KHR.
  147.  */
  148. static INLINE EGLImageKHR
  149. _eglGetImageHandle(_EGLImage *img)
  150. {
  151.    _EGLResource *res = (_EGLResource *) img;
  152.    return (res && _eglIsResourceLinked(res)) ?
  153.       (EGLImageKHR) img : EGL_NO_IMAGE_KHR;
  154. }
  155.  
  156.  
  157. #endif /* EGLIMAGE_INCLUDED */
  158.