eglconfig.h revision 3464ebd5
13464ebd5Sriastradh/**************************************************************************
23464ebd5Sriastradh *
33464ebd5Sriastradh * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
43464ebd5Sriastradh * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
53464ebd5Sriastradh * Copyright 2010-2011 LunarG, Inc.
63464ebd5Sriastradh * All Rights Reserved.
73464ebd5Sriastradh *
83464ebd5Sriastradh * Permission is hereby granted, free of charge, to any person obtaining a
93464ebd5Sriastradh * copy of this software and associated documentation files (the
103464ebd5Sriastradh * "Software"), to deal in the Software without restriction, including
113464ebd5Sriastradh * without limitation the rights to use, copy, modify, merge, publish,
123464ebd5Sriastradh * distribute, sub license, and/or sell copies of the Software, and to
133464ebd5Sriastradh * permit persons to whom the Software is furnished to do so, subject to
143464ebd5Sriastradh * the following conditions:
153464ebd5Sriastradh *
163464ebd5Sriastradh * The above copyright notice and this permission notice (including the
173464ebd5Sriastradh * next paragraph) shall be included in all copies or substantial portions
183464ebd5Sriastradh * of the Software.
193464ebd5Sriastradh *
203464ebd5Sriastradh * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
213464ebd5Sriastradh * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
223464ebd5Sriastradh * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
233464ebd5Sriastradh * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
243464ebd5Sriastradh * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
253464ebd5Sriastradh * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
263464ebd5Sriastradh * DEALINGS IN THE SOFTWARE.
273464ebd5Sriastradh *
283464ebd5Sriastradh **************************************************************************/
293464ebd5Sriastradh
303464ebd5Sriastradh
314a49301eSmrg#ifndef EGLCONFIG_INCLUDED
324a49301eSmrg#define EGLCONFIG_INCLUDED
334a49301eSmrg
344a49301eSmrg
354a49301eSmrg#include <assert.h>
363464ebd5Sriastradh#include <stddef.h>
374a49301eSmrg#include "egltypedefs.h"
384a49301eSmrg
394a49301eSmrg
403464ebd5Sriastradh/* update _eglValidationTable and _eglOffsetOfConfig before updating this
413464ebd5Sriastradh * struct */
424a49301eSmrgstruct _egl_config
434a49301eSmrg{
444a49301eSmrg   _EGLDisplay *Display;
454a49301eSmrg
463464ebd5Sriastradh   /* core */
473464ebd5Sriastradh   EGLint BufferSize;
483464ebd5Sriastradh   EGLint AlphaSize;
493464ebd5Sriastradh   EGLint BlueSize;
503464ebd5Sriastradh   EGLint GreenSize;
513464ebd5Sriastradh   EGLint RedSize;
523464ebd5Sriastradh   EGLint DepthSize;
533464ebd5Sriastradh   EGLint StencilSize;
543464ebd5Sriastradh   EGLint ConfigCaveat;
553464ebd5Sriastradh   EGLint ConfigID;
563464ebd5Sriastradh   EGLint Level;
573464ebd5Sriastradh   EGLint MaxPbufferHeight;
583464ebd5Sriastradh   EGLint MaxPbufferPixels;
593464ebd5Sriastradh   EGLint MaxPbufferWidth;
603464ebd5Sriastradh   EGLint NativeRenderable;
613464ebd5Sriastradh   EGLint NativeVisualID;
623464ebd5Sriastradh   EGLint NativeVisualType;
633464ebd5Sriastradh   EGLint Samples;
643464ebd5Sriastradh   EGLint SampleBuffers;
653464ebd5Sriastradh   EGLint SurfaceType;
663464ebd5Sriastradh   EGLint TransparentType;
673464ebd5Sriastradh   EGLint TransparentBlueValue;
683464ebd5Sriastradh   EGLint TransparentGreenValue;
693464ebd5Sriastradh   EGLint TransparentRedValue;
703464ebd5Sriastradh   EGLint BindToTextureRGB;
713464ebd5Sriastradh   EGLint BindToTextureRGBA;
723464ebd5Sriastradh   EGLint MinSwapInterval;
733464ebd5Sriastradh   EGLint MaxSwapInterval;
743464ebd5Sriastradh   EGLint LuminanceSize;
753464ebd5Sriastradh   EGLint AlphaMaskSize;
763464ebd5Sriastradh   EGLint ColorBufferType;
773464ebd5Sriastradh   EGLint RenderableType;
783464ebd5Sriastradh   EGLint MatchNativePixmap;
793464ebd5Sriastradh   EGLint Conformant;
803464ebd5Sriastradh
813464ebd5Sriastradh   /* extensions */
823464ebd5Sriastradh   EGLint YInvertedNOK;
833464ebd5Sriastradh};
844a49301eSmrg
854a49301eSmrg
864a49301eSmrg/**
873464ebd5Sriastradh * Map an EGL attribute enum to the offset of the member in _EGLConfig.
884a49301eSmrg */
894a49301eSmrgstatic INLINE EGLint
903464ebd5Sriastradh_eglOffsetOfConfig(EGLint attr)
914a49301eSmrg{
923464ebd5Sriastradh   switch (attr) {
933464ebd5Sriastradh#define ATTRIB_MAP(attr, memb) case attr: return offsetof(_EGLConfig, memb)
943464ebd5Sriastradh   /* core */
953464ebd5Sriastradh   ATTRIB_MAP(EGL_BUFFER_SIZE,               BufferSize);
963464ebd5Sriastradh   ATTRIB_MAP(EGL_ALPHA_SIZE,                AlphaSize);
973464ebd5Sriastradh   ATTRIB_MAP(EGL_BLUE_SIZE,                 BlueSize);
983464ebd5Sriastradh   ATTRIB_MAP(EGL_GREEN_SIZE,                GreenSize);
993464ebd5Sriastradh   ATTRIB_MAP(EGL_RED_SIZE,                  RedSize);
1003464ebd5Sriastradh   ATTRIB_MAP(EGL_DEPTH_SIZE,                DepthSize);
1013464ebd5Sriastradh   ATTRIB_MAP(EGL_STENCIL_SIZE,              StencilSize);
1023464ebd5Sriastradh   ATTRIB_MAP(EGL_CONFIG_CAVEAT,             ConfigCaveat);
1033464ebd5Sriastradh   ATTRIB_MAP(EGL_CONFIG_ID,                 ConfigID);
1043464ebd5Sriastradh   ATTRIB_MAP(EGL_LEVEL,                     Level);
1053464ebd5Sriastradh   ATTRIB_MAP(EGL_MAX_PBUFFER_HEIGHT,        MaxPbufferHeight);
1063464ebd5Sriastradh   ATTRIB_MAP(EGL_MAX_PBUFFER_PIXELS,        MaxPbufferPixels);
1073464ebd5Sriastradh   ATTRIB_MAP(EGL_MAX_PBUFFER_WIDTH,         MaxPbufferWidth);
1083464ebd5Sriastradh   ATTRIB_MAP(EGL_NATIVE_RENDERABLE,         NativeRenderable);
1093464ebd5Sriastradh   ATTRIB_MAP(EGL_NATIVE_VISUAL_ID,          NativeVisualID);
1103464ebd5Sriastradh   ATTRIB_MAP(EGL_NATIVE_VISUAL_TYPE,        NativeVisualType);
1113464ebd5Sriastradh   ATTRIB_MAP(EGL_SAMPLES,                   Samples);
1123464ebd5Sriastradh   ATTRIB_MAP(EGL_SAMPLE_BUFFERS,            SampleBuffers);
1133464ebd5Sriastradh   ATTRIB_MAP(EGL_SURFACE_TYPE,              SurfaceType);
1143464ebd5Sriastradh   ATTRIB_MAP(EGL_TRANSPARENT_TYPE,          TransparentType);
1153464ebd5Sriastradh   ATTRIB_MAP(EGL_TRANSPARENT_BLUE_VALUE,    TransparentBlueValue);
1163464ebd5Sriastradh   ATTRIB_MAP(EGL_TRANSPARENT_GREEN_VALUE,   TransparentGreenValue);
1173464ebd5Sriastradh   ATTRIB_MAP(EGL_TRANSPARENT_RED_VALUE,     TransparentRedValue);
1183464ebd5Sriastradh   ATTRIB_MAP(EGL_BIND_TO_TEXTURE_RGB,       BindToTextureRGB);
1193464ebd5Sriastradh   ATTRIB_MAP(EGL_BIND_TO_TEXTURE_RGBA,      BindToTextureRGBA);
1203464ebd5Sriastradh   ATTRIB_MAP(EGL_MIN_SWAP_INTERVAL,         MinSwapInterval);
1213464ebd5Sriastradh   ATTRIB_MAP(EGL_MAX_SWAP_INTERVAL,         MaxSwapInterval);
1223464ebd5Sriastradh   ATTRIB_MAP(EGL_LUMINANCE_SIZE,            LuminanceSize);
1233464ebd5Sriastradh   ATTRIB_MAP(EGL_ALPHA_MASK_SIZE,           AlphaMaskSize);
1243464ebd5Sriastradh   ATTRIB_MAP(EGL_COLOR_BUFFER_TYPE,         ColorBufferType);
1253464ebd5Sriastradh   ATTRIB_MAP(EGL_RENDERABLE_TYPE,           RenderableType);
1263464ebd5Sriastradh   ATTRIB_MAP(EGL_MATCH_NATIVE_PIXMAP,       MatchNativePixmap);
1273464ebd5Sriastradh   ATTRIB_MAP(EGL_CONFORMANT,                Conformant);
1283464ebd5Sriastradh   /* extensions */
1293464ebd5Sriastradh   ATTRIB_MAP(EGL_Y_INVERTED_NOK,            YInvertedNOK);
1303464ebd5Sriastradh#undef ATTRIB_MAP
1313464ebd5Sriastradh   default:
1324a49301eSmrg      return -1;
1333464ebd5Sriastradh   }
1344a49301eSmrg}
1354a49301eSmrg
1364a49301eSmrg
1374a49301eSmrg/**
1384a49301eSmrg * Update a config for a given key.
139cdc920a0Smrg *
140cdc920a0Smrg * Note that a valid key is not necessarily a valid attribute.  There are gaps
141cdc920a0Smrg * in the attribute enums.  The separation is to catch application errors.
142cdc920a0Smrg * Drivers should never set a key that is an invalid attribute.
1434a49301eSmrg */
1444a49301eSmrgstatic INLINE void
1454a49301eSmrg_eglSetConfigKey(_EGLConfig *conf, EGLint key, EGLint val)
1464a49301eSmrg{
1473464ebd5Sriastradh   EGLint offset = _eglOffsetOfConfig(key);
1483464ebd5Sriastradh   assert(offset >= 0);
1493464ebd5Sriastradh   *((EGLint *) ((char *) conf + offset)) = val;
1504a49301eSmrg}
1514a49301eSmrg
1524a49301eSmrg
1534a49301eSmrg/**
1544a49301eSmrg * Return the value for a given key.
1554a49301eSmrg */
1564a49301eSmrgstatic INLINE EGLint
1574a49301eSmrg_eglGetConfigKey(const _EGLConfig *conf, EGLint key)
1584a49301eSmrg{
1593464ebd5Sriastradh   EGLint offset = _eglOffsetOfConfig(key);
1603464ebd5Sriastradh   assert(offset >= 0);
1613464ebd5Sriastradh   return *((EGLint *) ((char *) conf + offset));
1624a49301eSmrg}
1634a49301eSmrg
1644a49301eSmrg
165cdc920a0SmrgPUBLIC void
166cdc920a0Smrg_eglInitConfig(_EGLConfig *config, _EGLDisplay *dpy, EGLint id);
1674a49301eSmrg
1684a49301eSmrg
169cdc920a0SmrgPUBLIC EGLConfig
1703464ebd5Sriastradh_eglLinkConfig(_EGLConfig *conf);
1714a49301eSmrg
1724a49301eSmrg
1733464ebd5Sriastradhextern _EGLConfig *
1743464ebd5Sriastradh_eglLookupConfig(EGLConfig config, _EGLDisplay *dpy);
1754a49301eSmrg
1764a49301eSmrg
1774a49301eSmrg/**
1783464ebd5Sriastradh * Return the handle of a linked config.
1794a49301eSmrg */
1804a49301eSmrgstatic INLINE EGLConfig
1814a49301eSmrg_eglGetConfigHandle(_EGLConfig *conf)
1824a49301eSmrg{
1833464ebd5Sriastradh   return (EGLConfig) conf;
1844a49301eSmrg}
1854a49301eSmrg
1864a49301eSmrg
187cdc920a0SmrgPUBLIC EGLBoolean
1884a49301eSmrg_eglValidateConfig(const _EGLConfig *conf, EGLBoolean for_matching);
1894a49301eSmrg
1904a49301eSmrg
191cdc920a0SmrgPUBLIC EGLBoolean
1924a49301eSmrg_eglMatchConfig(const _EGLConfig *conf, const _EGLConfig *criteria);
1934a49301eSmrg
1944a49301eSmrg
195cdc920a0SmrgPUBLIC EGLBoolean
1963464ebd5Sriastradh_eglParseConfigAttribList(_EGLConfig *conf, _EGLDisplay *dpy,
1973464ebd5Sriastradh                          const EGLint *attrib_list);
1984a49301eSmrg
1994a49301eSmrg
200cdc920a0SmrgPUBLIC EGLint
2014a49301eSmrg_eglCompareConfigs(const _EGLConfig *conf1, const _EGLConfig *conf2,
2024a49301eSmrg                   const _EGLConfig *criteria, EGLBoolean compare_id);
2034a49301eSmrg
2044a49301eSmrg
205cdc920a0SmrgPUBLIC void
2064a49301eSmrg_eglSortConfigs(const _EGLConfig **configs, EGLint count,
2074a49301eSmrg                EGLint (*compare)(const _EGLConfig *, const _EGLConfig *,
2084a49301eSmrg                                  void *),
2094a49301eSmrg                void *priv_data);
2104a49301eSmrg
2114a49301eSmrg
2124a49301eSmrgextern EGLBoolean
2134a49301eSmrg_eglChooseConfig(_EGLDriver *drv, _EGLDisplay *dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
2144a49301eSmrg
2154a49301eSmrg
2164a49301eSmrgextern EGLBoolean
2174a49301eSmrg_eglGetConfigAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, EGLint attribute, EGLint *value);
2184a49301eSmrg
2194a49301eSmrg
2204a49301eSmrgextern EGLBoolean
2214a49301eSmrg_eglGetConfigs(_EGLDriver *drv, _EGLDisplay *dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
2224a49301eSmrg
2234a49301eSmrg
2244a49301eSmrg#endif /* EGLCONFIG_INCLUDED */
225