summaryrefslogtreecommitdiff
path: root/src/egl/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/egl/main')
-rw-r--r--src/egl/main/Makefile2
-rw-r--r--src/egl/main/SConscript1
-rw-r--r--src/egl/main/eglapi.c2
-rw-r--r--src/egl/main/eglconfig.h2
-rw-r--r--src/egl/main/eglconfigutil.c128
-rw-r--r--src/egl/main/eglconfigutil.h19
-rw-r--r--src/egl/main/eglcontext.c108
-rw-r--r--src/egl/main/eglmode.c2
-rw-r--r--src/egl/main/eglscreen.c2
9 files changed, 35 insertions, 231 deletions
diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile
index d92fbf6d9a..baee1a2f9d 100644
--- a/src/egl/main/Makefile
+++ b/src/egl/main/Makefile
@@ -12,7 +12,6 @@ INCLUDE_DIRS = -I$(TOP)/include
HEADERS = \
eglcompiler.h \
eglconfig.h \
- eglconfigutil.h \
eglcontext.h \
eglcurrent.h \
egldefines.h \
@@ -33,7 +32,6 @@ SOURCES = \
eglapi.c \
eglarray.c \
eglconfig.c \
- eglconfigutil.c \
eglcontext.c \
eglcurrent.c \
egldisplay.c \
diff --git a/src/egl/main/SConscript b/src/egl/main/SConscript
index 06846475ba..45d40e2650 100644
--- a/src/egl/main/SConscript
+++ b/src/egl/main/SConscript
@@ -24,7 +24,6 @@ if env['platform'] != 'winddk':
'eglapi.c',
'eglarray.c',
'eglconfig.c',
- 'eglconfigutil.c',
'eglcontext.c',
'eglcurrent.c',
'egldisplay.c',
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 31c5419bbc..829d700b24 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -405,7 +405,7 @@ eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_list,
if (config)
_EGL_CHECK_CONFIG(disp, conf, EGL_NO_CONTEXT, drv);
else
- drv = _eglCheckDisplay(disp, __FUNCTION__);
+ _EGL_CHECK_DISPLAY(disp, EGL_NO_CONTEXT, drv);
if (!share && share_list != EGL_NO_CONTEXT)
RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_NO_CONTEXT);
diff --git a/src/egl/main/eglconfig.h b/src/egl/main/eglconfig.h
index ca63c40d3d..0ad58cf473 100644
--- a/src/egl/main/eglconfig.h
+++ b/src/egl/main/eglconfig.h
@@ -117,7 +117,7 @@ static INLINE _EGLConfig *
_eglLookupConfig(EGLConfig config, _EGLDisplay *dpy)
{
_EGLConfig *conf = (_EGLConfig *) config;
- if (!_eglCheckConfigHandle(config, dpy))
+ if (!dpy || !_eglCheckConfigHandle(config, dpy))
conf = NULL;
return conf;
}
diff --git a/src/egl/main/eglconfigutil.c b/src/egl/main/eglconfigutil.c
deleted file mode 100644
index e416b190f0..0000000000
--- a/src/egl/main/eglconfigutil.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/**
- * Extra utility functions related to EGL configs.
- */
-
-
-#include <stdlib.h>
-#include <string.h>
-#include "eglconfigutil.h"
-
-
-/**
- * Convert an _EGLConfig to a __GLcontextModes object.
- * NOTE: This routine may be incomplete - we're only making sure that
- * the fields needed by Mesa (for _mesa_create_context/framebuffer) are
- * set correctly.
- */
-void
-_eglConfigToContextModesRec(const _EGLConfig *config, __GLcontextModes *mode)
-{
- memset(mode, 0, sizeof(*mode));
-
- mode->rgbMode = GL_TRUE; /* no color index */
- mode->colorIndexMode = GL_FALSE;
- mode->doubleBufferMode = GL_TRUE; /* always DB for now */
- mode->stereoMode = GL_FALSE;
-
- mode->redBits = GET_CONFIG_ATTRIB(config, EGL_RED_SIZE);
- mode->greenBits = GET_CONFIG_ATTRIB(config, EGL_GREEN_SIZE);
- mode->blueBits = GET_CONFIG_ATTRIB(config, EGL_BLUE_SIZE);
- mode->alphaBits = GET_CONFIG_ATTRIB(config, EGL_ALPHA_SIZE);
- mode->rgbBits = GET_CONFIG_ATTRIB(config, EGL_BUFFER_SIZE);
-
- /* no rgba masks - fix? */
-
- mode->depthBits = GET_CONFIG_ATTRIB(config, EGL_DEPTH_SIZE);
- mode->haveDepthBuffer = mode->depthBits > 0;
-
- mode->stencilBits = GET_CONFIG_ATTRIB(config, EGL_STENCIL_SIZE);
- mode->haveStencilBuffer = mode->stencilBits > 0;
-
- /* no accum */
-
- mode->level = GET_CONFIG_ATTRIB(config, EGL_LEVEL);
- mode->samples = GET_CONFIG_ATTRIB(config, EGL_SAMPLES);
- mode->sampleBuffers = GET_CONFIG_ATTRIB(config, EGL_SAMPLE_BUFFERS);
-
- /* surface type - not really needed */
- mode->visualType = GLX_TRUE_COLOR;
- mode->renderType = GLX_RGBA_BIT;
-}
-
-
-/**
- * Convert a __GLcontextModes object to an _EGLConfig.
- */
-EGLBoolean
-_eglConfigFromContextModesRec(_EGLConfig *conf, const __GLcontextModes *m,
- EGLint conformant, EGLint renderable_type)
-{
- EGLint config_caveat, surface_type;
-
- /* must be RGBA */
- if (!m->rgbMode || !(m->renderType & GLX_RGBA_BIT))
- return EGL_FALSE;
-
- config_caveat = EGL_NONE;
- if (m->visualRating == GLX_SLOW_CONFIG)
- config_caveat = EGL_SLOW_CONFIG;
-
- if (m->visualRating == GLX_NON_CONFORMANT_CONFIG)
- conformant &= ~EGL_OPENGL_BIT;
- if (!(conformant & EGL_OPENGL_ES_BIT))
- config_caveat = EGL_NON_CONFORMANT_CONFIG;
-
- surface_type = 0;
- if (m->drawableType & GLX_WINDOW_BIT)
- surface_type |= EGL_WINDOW_BIT;
- if (m->drawableType & GLX_PIXMAP_BIT)
- surface_type |= EGL_PIXMAP_BIT;
- if (m->drawableType & GLX_PBUFFER_BIT)
- surface_type |= EGL_PBUFFER_BIT;
-
- SET_CONFIG_ATTRIB(conf, EGL_BUFFER_SIZE, m->rgbBits);
- SET_CONFIG_ATTRIB(conf, EGL_RED_SIZE, m->redBits);
- SET_CONFIG_ATTRIB(conf, EGL_GREEN_SIZE, m->greenBits);
- SET_CONFIG_ATTRIB(conf, EGL_BLUE_SIZE, m->blueBits);
- SET_CONFIG_ATTRIB(conf, EGL_ALPHA_SIZE, m->alphaBits);
-
- SET_CONFIG_ATTRIB(conf, EGL_BIND_TO_TEXTURE_RGB, m->bindToTextureRgb);
- SET_CONFIG_ATTRIB(conf, EGL_BIND_TO_TEXTURE_RGBA, m->bindToTextureRgba);
- SET_CONFIG_ATTRIB(conf, EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER);
- SET_CONFIG_ATTRIB(conf, EGL_CONFIG_CAVEAT, config_caveat);
-
- SET_CONFIG_ATTRIB(conf, EGL_CONFORMANT, conformant);
- SET_CONFIG_ATTRIB(conf, EGL_DEPTH_SIZE, m->depthBits);
- SET_CONFIG_ATTRIB(conf, EGL_LEVEL, m->level);
- SET_CONFIG_ATTRIB(conf, EGL_MAX_PBUFFER_WIDTH, m->maxPbufferWidth);
- SET_CONFIG_ATTRIB(conf, EGL_MAX_PBUFFER_HEIGHT, m->maxPbufferHeight);
- SET_CONFIG_ATTRIB(conf, EGL_MAX_PBUFFER_PIXELS, m->maxPbufferPixels);
-
- SET_CONFIG_ATTRIB(conf, EGL_NATIVE_RENDERABLE, m->xRenderable);
- SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_ID, m->visualID);
-
- if (m->visualType != GLX_NONE)
- SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_TYPE, m->visualType);
- else
- SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_TYPE, EGL_NONE);
-
- SET_CONFIG_ATTRIB(conf, EGL_RENDERABLE_TYPE, renderable_type);
- SET_CONFIG_ATTRIB(conf, EGL_SAMPLE_BUFFERS, m->sampleBuffers);
- SET_CONFIG_ATTRIB(conf, EGL_SAMPLES, m->samples);
- SET_CONFIG_ATTRIB(conf, EGL_STENCIL_SIZE, m->stencilBits);
-
- SET_CONFIG_ATTRIB(conf, EGL_SURFACE_TYPE, surface_type);
-
- /* what to do with GLX_TRANSPARENT_INDEX? */
- if (m->transparentPixel == GLX_TRANSPARENT_RGB) {
- SET_CONFIG_ATTRIB(conf, EGL_TRANSPARENT_TYPE, EGL_TRANSPARENT_RGB);
- SET_CONFIG_ATTRIB(conf, EGL_TRANSPARENT_RED_VALUE, m->transparentRed);
- SET_CONFIG_ATTRIB(conf, EGL_TRANSPARENT_GREEN_VALUE, m->transparentGreen);
- SET_CONFIG_ATTRIB(conf, EGL_TRANSPARENT_BLUE_VALUE, m->transparentBlue);
- }
- else {
- SET_CONFIG_ATTRIB(conf, EGL_TRANSPARENT_TYPE, EGL_NONE);
- }
-
- return EGL_TRUE;
-}
diff --git a/src/egl/main/eglconfigutil.h b/src/egl/main/eglconfigutil.h
deleted file mode 100644
index c6f4819960..0000000000
--- a/src/egl/main/eglconfigutil.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef EGLCONFIGUTIL_INCLUDED
-#define EGLCONFIGUTIL_INCLUDED
-
-
-#include "GL/gl.h"
-#include "GL/internal/glcore.h"
-#include "eglconfig.h"
-
-
-PUBLIC void
-_eglConfigToContextModesRec(const _EGLConfig *config, __GLcontextModes *mode);
-
-
-PUBLIC EGLBoolean
-_eglConfigFromContextModesRec(_EGLConfig *conf, const __GLcontextModes *m,
- EGLint conformant, EGLint renderable_type);
-
-
-#endif /* EGLCONFIGUTIL_INCLUDED */
diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c
index e72664c23c..bc22913d40 100644
--- a/src/egl/main/eglcontext.c
+++ b/src/egl/main/eglcontext.c
@@ -205,70 +205,6 @@ _eglQueryContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *c,
/**
- * Bind the context to the surfaces. Return the surfaces that are "orphaned".
- * That is, when the context is not NULL, return the surfaces it previously
- * bound to; when the context is NULL, the same surfaces are returned.
- */
-static void
-_eglBindContextToSurfaces(_EGLContext *newCtx,
- _EGLSurface **draw, _EGLSurface **read)
-{
- _EGLSurface *newDraw = *draw, *newRead = *read;
- _EGLContext *oldCtx;
-
- /*
- * The goal is to bind a newCtx to newDraw. Since newDraw may already have
- * a binding context (oldCtx), and newCtx may already be bound to another
- * surface (oldDraw), the old bindings are broken first and the new one is
- * created.
- */
- if (newDraw) {
- oldCtx = newDraw->CurrentContext;
- if (newCtx != oldCtx) {
- if (oldCtx) {
- assert(oldCtx->DrawSurface == newDraw);
- oldCtx->DrawSurface = NULL;
- }
-
- newDraw->CurrentContext = newCtx;
- }
- }
-
- if (newCtx) {
- _EGLSurface *oldDraw = newCtx->DrawSurface;
- if (oldDraw)
- oldDraw->CurrentContext = NULL;
-
- newCtx->DrawSurface = newDraw;
- *draw = oldDraw;
- }
-
- /* likewise */
- if (newRead && newRead != newDraw) {
- oldCtx = newRead->CurrentContext;
- if (newCtx != oldCtx) {
- if (oldCtx) {
- assert(oldCtx->ReadSurface == newRead);
- oldCtx->ReadSurface = NULL;
- }
-
- newRead->CurrentContext = newCtx;
- }
- }
-
- if (newCtx) {
- _EGLSurface *oldRead = newCtx->ReadSurface;
- if (oldRead)
- oldRead->CurrentContext = NULL;
-
- newCtx->ReadSurface = newRead;
- *read = oldRead;
- }
-
-}
-
-
-/**
* Bind the context to the thread and return the previous context.
*
* Note that the context may be NULL.
@@ -387,36 +323,54 @@ _eglCheckMakeCurrent(_EGLContext *ctx, _EGLSurface *draw, _EGLSurface *read)
/**
* Bind the context to the current thread and given surfaces. Return the
- * previously bound context and the surfaces it bound to. Each argument is
- * both input and output.
+ * "orphaned" context and surfaces. Each argument is both input and output.
*/
EGLBoolean
_eglBindContext(_EGLContext **ctx, _EGLSurface **draw, _EGLSurface **read)
{
_EGLThreadInfo *t = _eglGetCurrentThread();
_EGLContext *newCtx = *ctx, *oldCtx;
+ _EGLSurface *newDraw = *draw, *newRead = *read;
- if (!_eglCheckMakeCurrent(newCtx, *draw, *read))
+ if (!_eglCheckMakeCurrent(newCtx, newDraw, newRead))
return EGL_FALSE;
/* bind the new context */
oldCtx = _eglBindContextToThread(newCtx, t);
- if (newCtx)
- _eglBindContextToSurfaces(newCtx, draw, read);
-
- /* unbind the old context from its binding surfaces */
- if (oldCtx && oldCtx != newCtx) {
- assert(!*draw && !*read);
-
+ /* break old bindings */
+ if (oldCtx) {
+ *ctx = oldCtx;
*draw = oldCtx->DrawSurface;
*read = oldCtx->ReadSurface;
- _eglBindContextToSurfaces(NULL, draw, read);
+ if (*draw)
+ (*draw)->CurrentContext = NULL;
+ if (*read)
+ (*read)->CurrentContext = NULL;
+
+ oldCtx->DrawSurface = NULL;
+ oldCtx->ReadSurface = NULL;
+ }
+
+ /* establish new bindings */
+ if (newCtx) {
+ if (newDraw)
+ newDraw->CurrentContext = newCtx;
+ if (newRead)
+ newRead->CurrentContext = newCtx;
+
+ newCtx->DrawSurface = newDraw;
+ newCtx->ReadSurface = newRead;
}
- *ctx = oldCtx;
- /* draw and read have been updated in _eglBindContextToSurfaces */
+ /* an old context or surface is not orphaned if it is still bound */
+ if (*ctx == newCtx)
+ *ctx = NULL;
+ if (*draw == newDraw || *draw == newRead)
+ *draw = NULL;
+ if (*read == newDraw || *read == newRead)
+ *read = NULL;
return EGL_TRUE;
}
diff --git a/src/egl/main/eglmode.c b/src/egl/main/eglmode.c
index 37594cdb42..ed107d5d7a 100644
--- a/src/egl/main/eglmode.c
+++ b/src/egl/main/eglmode.c
@@ -25,7 +25,7 @@ _eglLookupMode(EGLModeMESA mode, _EGLDisplay *disp)
{
EGLint scrnum;
- if (!disp->Screens)
+ if (!disp || !disp->Screens)
return NULL;
/* loop over all screens on the display */
diff --git a/src/egl/main/eglscreen.c b/src/egl/main/eglscreen.c
index 8b8966f3ff..9e39335cc7 100644
--- a/src/egl/main/eglscreen.c
+++ b/src/egl/main/eglscreen.c
@@ -69,7 +69,7 @@ _eglLookupScreen(EGLScreenMESA screen, _EGLDisplay *display)
{
EGLint i;
- if (!display->Screens)
+ if (!display || !display->Screens)
return NULL;
for (i = 0; i < display->Screens->Size; i++) {