Hi all,

While working on EGL and its drivers, I found that I always have to
perform a lookup to convert an EGL handle (EGLDisplay, EGLContext, etc.)
to its internal data structure (_EGLDisplay, _EGLContext, etc.).  After
the lookup, I also have to error check the result and set proper error
code.

Existing drivers sometime do not check the result, or do not to set the
error code.  Even the default implementation in EGL core forgets to do
so here and there.  I think it is a sign that lookup and error checking
is better to be done in EGL core, or more specifically, in the EGL API
entry points.

Take eglQueryString for example, instead of

  const char * EGLAPIENTRY
  eglQueryString(EGLDisplay dpy, EGLint name)
  {
     _EGLDriver *drv = _eglLookupDriver(dpy);
     if (drv)
        return drv->API.QueryString(drv, dpy, name);
     else
        return NULL;
  }

I would like to change the driver API such that the way it is called
becomes 

     _EGLDisplay *disp = _eglLookupDisplay(disp);
     _EGLDriver *drv = _eglCheckDisplay(disp); /* check for bad display */
     if (!drv) return NULL;
     /* pass in disp, not dpy */
     return drv->API.QueryString(drv, disp, name);

The benefits are that

* Error checking is always done in eglapi.c
* The rest of EGL core and drivers only see the internal data structures
* No need to lookup again and again in different functions
* No need to error check in drivers


And while at it, I want to change the prototypes of _EGLDriver and
_eglMain at the same time.  There are two goals

* _eglMain is called only once to create an _EGLDriver.  And,
* An _EGLDriver can drive many _EGLDisplay

For the former, _eglMain no longer needs to take a display.  For the
latter, some fields of _EGLDriver are to be moved to _EGLDisplay to
become per-display.  Two new hooks, Probe and Unload, are added to
_EGLDriver.

The motivation is to make a display to be able to be initialized and
terminated repeatedly, as required by the spec.  There are many ways for
this, but I want to use it as a chance to update the driver API.  It
also leaves room for better driver/display matching (the Probe hook).

I already started some primitive work.  The planned change to the API
can be found in the attachment in patch form.  Please let me know your
ideas.

-- 
Regards,
olv

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to