From d548bf41d3a0fe443494f94f745d1fe49e5e432c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sun, 27 Nov 2005 23:57:19 +0000 Subject: Redo _eglInitSurface() so it can be used with all surface types. Redo _eglInitContext() to do error checking, attribute list parsing, etc. --- src/egl/main/eglscreen.c | 63 ++++++++++-------------------------------------- 1 file changed, 13 insertions(+), 50 deletions(-) (limited to 'src/egl/main/eglscreen.c') diff --git a/src/egl/main/eglscreen.c b/src/egl/main/eglscreen.c index e213e9a847..c4cc8bfe1a 100644 --- a/src/egl/main/eglscreen.c +++ b/src/egl/main/eglscreen.c @@ -106,67 +106,30 @@ _eglGetScreensMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA *screens, /** - * Initialize the given _EGLSurface object. Do error checking. - * Assign it an EGLSurface handle and insert into hash table. - * \return EGLSurface handle or EGL_NO_SURFACE if error. + * Example function - drivers should do a proper implementation. */ EGLSurface -_eglInitScreenSurface(_EGLSurface *surf, _EGLDriver *drv, EGLDisplay dpy, - EGLConfig config, const EGLint *attrib_list) +_eglCreateScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, + const EGLint *attrib_list) { - EGLint width = 0, height = 0; - EGLint i; +#if 0 /* THIS IS JUST EXAMPLE CODE */ + _EGLSurface *surf; - for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { - switch (attrib_list[i]) { - case EGL_WIDTH: - width = attrib_list[++i]; - break; - case EGL_HEIGHT: - height = attrib_list[++i]; - break; - default: - _eglError(EGL_BAD_ATTRIBUTE, "eglCreateScreenSurfaceMESA"); - return EGL_NO_SURFACE; - } - } + surf = (_EGLSurface *) calloc(1, sizeof(_EGLSurface)); + if (!surf) + return EGL_NO_SURFACE; - if (width <= 0 || height <= 0) { - _eglError(EGL_BAD_ATTRIBUTE, - "eglCreateScreenSurfaceMESA(width or height)"); + if (!_eglInitSurface(drv, dpy, surf, EGL_SCREEN_BIT_MESA, + config, attrib_list)) { + free(surf); return EGL_NO_SURFACE; } - _eglInitSurface(surf); - surf->Width = width; - surf->Height = height; - surf->Type = EGL_SCREEN_BIT_MESA; - surf->Config = _eglLookupConfig(drv, dpy, config); - - /* insert into hash table */ _eglSaveSurface(surf); - assert(surf->Handle); return surf->Handle; -} - - -/** - * Create a drawing surface which can be directly displayed on a screen. - */ -EGLSurface -_eglCreateScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, - const EGLint *attrib_list) -{ - _EGLSurface *surf; - EGLSurface surface; - - surf = (_EGLSurface *) malloc(sizeof(_EGLSurface)); - surface = _eglInitScreenSurface(surf, drv, dpy, config, attrib_list); - if (surface == EGL_NO_SURFACE) - free(surf); - - return surface; +#endif + return EGL_NO_SURFACE; } -- cgit v1.2.3