mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 00:58:05 +02:00
egl: added args string to _eglMain()
This commit is contained in:
parent
e94d383b9b
commit
0c8908c411
8 changed files with 39 additions and 32 deletions
|
|
@ -286,7 +286,7 @@ demoMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw, EGLSurface rea
|
|||
* plug in API functions.
|
||||
*/
|
||||
_EGLDriver *
|
||||
_eglMain(_EGLDisplay *dpy)
|
||||
_eglMain(_EGLDisplay *dpy, const char *args)
|
||||
{
|
||||
DemoDriver *demo;
|
||||
|
||||
|
|
|
|||
|
|
@ -79,11 +79,11 @@ driver_name_from_card_number(int card, char *driverName, int maxDriverName)
|
|||
* This function, in turn, loads a specific DRI driver (ex: r200_dri.so).
|
||||
*/
|
||||
_EGLDriver *
|
||||
_eglMain(_EGLDisplay *dpy)
|
||||
_eglMain(_EGLDisplay *dpy, const char *args)
|
||||
{
|
||||
#if 1
|
||||
const char *displayString = (const char *) dpy->NativeDisplay;
|
||||
const int card = atoi(displayString + 1);
|
||||
const int card = atoi(args);
|
||||
_EGLDriver *driver = NULL;
|
||||
char driverName[1000];
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,9 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
|
|||
if (!dpyPriv) {
|
||||
return EGL_FALSE;
|
||||
}
|
||||
dpyPriv->Driver = _eglOpenDriver(dpyPriv, dpyPriv->DriverName);
|
||||
dpyPriv->Driver = _eglOpenDriver(dpyPriv,
|
||||
dpyPriv->DriverName,
|
||||
dpyPriv->DriverArgs);
|
||||
if (!dpyPriv->Driver) {
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,25 +11,14 @@
|
|||
#include "egldriver.h"
|
||||
#include "eglglobals.h"
|
||||
#include "eglhash.h"
|
||||
|
||||
|
||||
static char *
|
||||
my_strdup(const char *s)
|
||||
{
|
||||
if (s) {
|
||||
int l = strlen(s);
|
||||
char *s2 = malloc(l + 1);
|
||||
if (s2)
|
||||
strcpy(s2, s);
|
||||
return s2;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#include "eglstring.h"
|
||||
|
||||
|
||||
/**
|
||||
* Allocate a new _EGLDisplay object for the given nativeDisplay handle.
|
||||
* We'll also try to determine the device driver name at this time.
|
||||
*
|
||||
* Note that nativeDisplay may be an X Display ptr, or a string.
|
||||
*/
|
||||
_EGLDisplay *
|
||||
_eglNewDisplay(NativeDisplayType nativeDisplay)
|
||||
|
|
@ -46,7 +35,7 @@ _eglNewDisplay(NativeDisplayType nativeDisplay)
|
|||
dpy->Xdpy = (Display *) nativeDisplay;
|
||||
#endif
|
||||
|
||||
dpy->DriverName = my_strdup(_eglChooseDriver(dpy));
|
||||
dpy->DriverName = _eglstrdup(_eglChooseDriver(dpy));
|
||||
if (!dpy->DriverName) {
|
||||
free(dpy);
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ struct _egl_display
|
|||
EGLDisplay Handle;
|
||||
|
||||
const char *DriverName;
|
||||
const char *DriverArgs;
|
||||
_EGLDriver *Driver;
|
||||
|
||||
EGLint NumScreens;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include <assert.h>
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "eglconfig.h"
|
||||
#include "eglcontext.h"
|
||||
|
|
@ -15,6 +16,7 @@
|
|||
#include "egllog.h"
|
||||
#include "eglmode.h"
|
||||
#include "eglscreen.h"
|
||||
#include "eglstring.h"
|
||||
#include "eglsurface.h"
|
||||
|
||||
#if defined(_EGL_PLATFORM_X)
|
||||
|
|
@ -25,7 +27,7 @@
|
|||
/* XXX to do */
|
||||
#endif
|
||||
|
||||
const char *DefaultDriverName = "demodriver";
|
||||
const char *DefaultDriverName = ":0";
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -44,23 +46,36 @@ const char *DefaultDriverName = "demodriver";
|
|||
const char *
|
||||
_eglChooseDriver(_EGLDisplay *dpy)
|
||||
{
|
||||
const char *name = (const char *) dpy->NativeDisplay;
|
||||
const char *displayString = (const char *) dpy->NativeDisplay;
|
||||
const char *driverName = NULL;
|
||||
|
||||
if (!dpy->NativeDisplay) {
|
||||
if (!displayString) {
|
||||
/* choose a default */
|
||||
driverName = DefaultDriverName;
|
||||
displayString = DefaultDriverName;
|
||||
}
|
||||
else if (name && name[0] == ':' &&
|
||||
(name[1] >= '0' && name[1] <= '9') && !name[2]) {
|
||||
|
||||
/* extract default DriverArgs = whatever follows ':' */
|
||||
if (displayString[0] == '!' ||
|
||||
displayString[0] == ':') {
|
||||
const char *args = strchr(displayString, ':');
|
||||
if (args)
|
||||
dpy->DriverArgs = _eglstrdup(args + 1);
|
||||
}
|
||||
|
||||
|
||||
if (displayString && displayString[0] == ':' &&
|
||||
(displayString[1] >= '0' && displayString[1] <= '9') &&
|
||||
!displayString[2]) {
|
||||
/* XXX probe hardware here to determine which driver to open */
|
||||
driverName = "libEGLdri";
|
||||
}
|
||||
else if (name && name[0] == '!') {
|
||||
else if (displayString && displayString[0] == '!') {
|
||||
/* use specified driver name */
|
||||
driverName = name + 1;
|
||||
driverName = displayString + 1;
|
||||
}
|
||||
else {
|
||||
/* NativeDisplay is not a string! */
|
||||
|
||||
#if defined(_EGL_PLATFORM_X)
|
||||
driverName = _xeglChooseDriver(dpy);
|
||||
#elif defined(_EGL_PLATFORM_WINDOWS)
|
||||
|
|
@ -83,7 +98,7 @@ _eglChooseDriver(_EGLDisplay *dpy)
|
|||
* \return new _EGLDriver object.
|
||||
*/
|
||||
_EGLDriver *
|
||||
_eglOpenDriver(_EGLDisplay *dpy, const char *driverName)
|
||||
_eglOpenDriver(_EGLDisplay *dpy, const char *driverName, const char *args)
|
||||
{
|
||||
_EGLDriver *drv;
|
||||
_EGLMain_t mainFunc;
|
||||
|
|
@ -110,7 +125,7 @@ _eglOpenDriver(_EGLDisplay *dpy, const char *driverName)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
drv = mainFunc(dpy);
|
||||
drv = mainFunc(dpy, args);
|
||||
if (!drv) {
|
||||
dlclose(lib);
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ struct _egl_driver
|
|||
};
|
||||
|
||||
|
||||
extern _EGLDriver *_eglMain(_EGLDisplay *dpy);
|
||||
extern _EGLDriver *_eglMain(_EGLDisplay *dpy, const char *args);
|
||||
|
||||
|
||||
extern const char *
|
||||
|
|
@ -50,7 +50,7 @@ _eglChooseDriver(_EGLDisplay *dpy);
|
|||
|
||||
|
||||
extern _EGLDriver *
|
||||
_eglOpenDriver(_EGLDisplay *dpy, const char *DriverName);
|
||||
_eglOpenDriver(_EGLDisplay *dpy, const char *driverName, const char *args);
|
||||
|
||||
|
||||
extern EGLBoolean
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ typedef struct _egl_thread_info _EGLThreadInfo;
|
|||
|
||||
typedef void (*_EGLProc)();
|
||||
|
||||
typedef _EGLDriver *(*_EGLMain_t)(_EGLDisplay *dpy);
|
||||
typedef _EGLDriver *(*_EGLMain_t)(_EGLDisplay *dpy, const char *args);
|
||||
|
||||
|
||||
#endif /* EGLTYPEDEFS_INCLUDED */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue