Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /**************************************************************************
  2.  *
  3.  * Copyright 2008 VMware, Inc.
  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 EGLCONFIG_INCLUDED
  32. #define EGLCONFIG_INCLUDED
  33.  
  34.  
  35. #include <assert.h>
  36. #include <stddef.h>
  37. #include "c99_compat.h"
  38.  
  39. #include "egltypedefs.h"
  40.  
  41.  
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif
  45.  
  46. /* update _eglValidationTable and _eglOffsetOfConfig before updating this
  47.  * struct */
  48. struct _egl_config
  49. {
  50.    _EGLDisplay *Display;
  51.  
  52.    /* core */
  53.    EGLint BufferSize;
  54.    EGLint AlphaSize;
  55.    EGLint BlueSize;
  56.    EGLint GreenSize;
  57.    EGLint RedSize;
  58.    EGLint DepthSize;
  59.    EGLint StencilSize;
  60.    EGLint ConfigCaveat;
  61.    EGLint ConfigID;
  62.    EGLint Level;
  63.    EGLint MaxPbufferHeight;
  64.    EGLint MaxPbufferPixels;
  65.    EGLint MaxPbufferWidth;
  66.    EGLint NativeRenderable;
  67.    EGLint NativeVisualID;
  68.    EGLint NativeVisualType;
  69.    EGLint Samples;
  70.    EGLint SampleBuffers;
  71.    EGLint SurfaceType;
  72.    EGLint TransparentType;
  73.    EGLint TransparentBlueValue;
  74.    EGLint TransparentGreenValue;
  75.    EGLint TransparentRedValue;
  76.    EGLint BindToTextureRGB;
  77.    EGLint BindToTextureRGBA;
  78.    EGLint MinSwapInterval;
  79.    EGLint MaxSwapInterval;
  80.    EGLint LuminanceSize;
  81.    EGLint AlphaMaskSize;
  82.    EGLint ColorBufferType;
  83.    EGLint RenderableType;
  84.    EGLint MatchNativePixmap;
  85.    EGLint Conformant;
  86.  
  87.    /* extensions */
  88.    EGLint YInvertedNOK;
  89. };
  90.  
  91.  
  92. /**
  93.  * Map an EGL attribute enum to the offset of the member in _EGLConfig.
  94.  */
  95. static inline EGLint
  96. _eglOffsetOfConfig(EGLint attr)
  97. {
  98.    switch (attr) {
  99. #define ATTRIB_MAP(attr, memb) case attr: return offsetof(_EGLConfig, memb)
  100.    /* core */
  101.    ATTRIB_MAP(EGL_BUFFER_SIZE,               BufferSize);
  102.    ATTRIB_MAP(EGL_ALPHA_SIZE,                AlphaSize);
  103.    ATTRIB_MAP(EGL_BLUE_SIZE,                 BlueSize);
  104.    ATTRIB_MAP(EGL_GREEN_SIZE,                GreenSize);
  105.    ATTRIB_MAP(EGL_RED_SIZE,                  RedSize);
  106.    ATTRIB_MAP(EGL_DEPTH_SIZE,                DepthSize);
  107.    ATTRIB_MAP(EGL_STENCIL_SIZE,              StencilSize);
  108.    ATTRIB_MAP(EGL_CONFIG_CAVEAT,             ConfigCaveat);
  109.    ATTRIB_MAP(EGL_CONFIG_ID,                 ConfigID);
  110.    ATTRIB_MAP(EGL_LEVEL,                     Level);
  111.    ATTRIB_MAP(EGL_MAX_PBUFFER_HEIGHT,        MaxPbufferHeight);
  112.    ATTRIB_MAP(EGL_MAX_PBUFFER_PIXELS,        MaxPbufferPixels);
  113.    ATTRIB_MAP(EGL_MAX_PBUFFER_WIDTH,         MaxPbufferWidth);
  114.    ATTRIB_MAP(EGL_NATIVE_RENDERABLE,         NativeRenderable);
  115.    ATTRIB_MAP(EGL_NATIVE_VISUAL_ID,          NativeVisualID);
  116.    ATTRIB_MAP(EGL_NATIVE_VISUAL_TYPE,        NativeVisualType);
  117.    ATTRIB_MAP(EGL_SAMPLES,                   Samples);
  118.    ATTRIB_MAP(EGL_SAMPLE_BUFFERS,            SampleBuffers);
  119.    ATTRIB_MAP(EGL_SURFACE_TYPE,              SurfaceType);
  120.    ATTRIB_MAP(EGL_TRANSPARENT_TYPE,          TransparentType);
  121.    ATTRIB_MAP(EGL_TRANSPARENT_BLUE_VALUE,    TransparentBlueValue);
  122.    ATTRIB_MAP(EGL_TRANSPARENT_GREEN_VALUE,   TransparentGreenValue);
  123.    ATTRIB_MAP(EGL_TRANSPARENT_RED_VALUE,     TransparentRedValue);
  124.    ATTRIB_MAP(EGL_BIND_TO_TEXTURE_RGB,       BindToTextureRGB);
  125.    ATTRIB_MAP(EGL_BIND_TO_TEXTURE_RGBA,      BindToTextureRGBA);
  126.    ATTRIB_MAP(EGL_MIN_SWAP_INTERVAL,         MinSwapInterval);
  127.    ATTRIB_MAP(EGL_MAX_SWAP_INTERVAL,         MaxSwapInterval);
  128.    ATTRIB_MAP(EGL_LUMINANCE_SIZE,            LuminanceSize);
  129.    ATTRIB_MAP(EGL_ALPHA_MASK_SIZE,           AlphaMaskSize);
  130.    ATTRIB_MAP(EGL_COLOR_BUFFER_TYPE,         ColorBufferType);
  131.    ATTRIB_MAP(EGL_RENDERABLE_TYPE,           RenderableType);
  132.    ATTRIB_MAP(EGL_MATCH_NATIVE_PIXMAP,       MatchNativePixmap);
  133.    ATTRIB_MAP(EGL_CONFORMANT,                Conformant);
  134.    /* extensions */
  135.    ATTRIB_MAP(EGL_Y_INVERTED_NOK,            YInvertedNOK);
  136. #undef ATTRIB_MAP
  137.    default:
  138.       return -1;
  139.    }
  140. }
  141.  
  142.  
  143. /**
  144.  * Update a config for a given key.
  145.  *
  146.  * Note that a valid key is not necessarily a valid attribute.  There are gaps
  147.  * in the attribute enums.  The separation is to catch application errors.
  148.  * Drivers should never set a key that is an invalid attribute.
  149.  */
  150. static inline void
  151. _eglSetConfigKey(_EGLConfig *conf, EGLint key, EGLint val)
  152. {
  153.    EGLint offset = _eglOffsetOfConfig(key);
  154.    assert(offset >= 0);
  155.    *((EGLint *) ((char *) conf + offset)) = val;
  156. }
  157.  
  158.  
  159. /**
  160.  * Return the value for a given key.
  161.  */
  162. static inline EGLint
  163. _eglGetConfigKey(const _EGLConfig *conf, EGLint key)
  164. {
  165.    EGLint offset = _eglOffsetOfConfig(key);
  166.    assert(offset >= 0);
  167.    return *((EGLint *) ((char *) conf + offset));
  168. }
  169.  
  170.  
  171. extern void
  172. _eglInitConfig(_EGLConfig *config, _EGLDisplay *dpy, EGLint id);
  173.  
  174.  
  175. extern EGLConfig
  176. _eglLinkConfig(_EGLConfig *conf);
  177.  
  178.  
  179. extern _EGLConfig *
  180. _eglLookupConfig(EGLConfig config, _EGLDisplay *dpy);
  181.  
  182.  
  183. /**
  184.  * Return the handle of a linked config.
  185.  */
  186. static inline EGLConfig
  187. _eglGetConfigHandle(_EGLConfig *conf)
  188. {
  189.    return (EGLConfig) conf;
  190. }
  191.  
  192.  
  193. extern EGLBoolean
  194. _eglValidateConfig(const _EGLConfig *conf, EGLBoolean for_matching);
  195.  
  196.  
  197. extern EGLBoolean
  198. _eglMatchConfig(const _EGLConfig *conf, const _EGLConfig *criteria);
  199.  
  200.  
  201. extern EGLBoolean
  202. _eglParseConfigAttribList(_EGLConfig *conf, _EGLDisplay *dpy,
  203.                           const EGLint *attrib_list);
  204.  
  205.  
  206. extern EGLint
  207. _eglCompareConfigs(const _EGLConfig *conf1, const _EGLConfig *conf2,
  208.                    const _EGLConfig *criteria, EGLBoolean compare_id);
  209.  
  210.  
  211. extern EGLBoolean
  212. _eglFilterConfigArray(_EGLArray *array, EGLConfig *configs,
  213.                       EGLint config_size, EGLint *num_configs,
  214.                       EGLBoolean (*match)(const _EGLConfig *, void *),
  215.                       EGLint (*compare)(const _EGLConfig *, const _EGLConfig *,
  216.                                         void *),
  217.                       void *filter_data);
  218.  
  219.  
  220. extern EGLBoolean
  221. _eglChooseConfig(_EGLDriver *drv, _EGLDisplay *dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
  222.  
  223.  
  224. extern EGLBoolean
  225. _eglGetConfigAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, EGLint attribute, EGLint *value);
  226.  
  227.  
  228. extern EGLBoolean
  229. _eglGetConfigs(_EGLDriver *drv, _EGLDisplay *dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
  230.  
  231.  
  232. #ifdef __cplusplus
  233. }
  234. #endif
  235.  
  236. #endif /* EGLCONFIG_INCLUDED */
  237.