sync with latest EGL_MESA_screen_surface spec (EGLScreenMESA handles)
This commit is contained in:
@@ -55,51 +55,34 @@ demoInitialize(_EGLDriver *drv, EGLDisplay dpy, EGLint *major, EGLint *minor)
|
|||||||
_EGLScreen *scrn;
|
_EGLScreen *scrn;
|
||||||
EGLint i;
|
EGLint i;
|
||||||
|
|
||||||
disp->NumScreens = 1;
|
/* Create a screen */
|
||||||
disp->Screens = (_EGLScreen *) calloc(disp->NumScreens, sizeof(_EGLScreen));
|
scrn = _eglNewScreen();
|
||||||
scrn = disp->Screens + 0;
|
_eglAddScreen(disp, scrn);
|
||||||
scrn->NumModes = 4;
|
|
||||||
scrn->Modes = (_EGLMode *) calloc(scrn->NumModes, sizeof(_EGLMode));
|
|
||||||
scrn->Modes[0].Width = 1600;
|
|
||||||
scrn->Modes[0].Height = 1200;
|
|
||||||
scrn->Modes[0].Depth = 32;
|
|
||||||
scrn->Modes[0].RefreshRate = 72 * 1000;
|
|
||||||
scrn->Modes[1].Width = 1280;
|
|
||||||
scrn->Modes[1].Height = 1024;
|
|
||||||
scrn->Modes[1].Depth = 32;
|
|
||||||
scrn->Modes[1].RefreshRate = 72 * 1000;
|
|
||||||
scrn->Modes[2].Width = 1280;
|
|
||||||
scrn->Modes[2].Height = 1024;
|
|
||||||
scrn->Modes[2].Depth = 16;
|
|
||||||
scrn->Modes[2].RefreshRate = 72 * 1000;
|
|
||||||
scrn->Modes[3].Width = 1024;
|
|
||||||
scrn->Modes[3].Height = 768;
|
|
||||||
scrn->Modes[3].Depth = 16;
|
|
||||||
scrn->Modes[3].RefreshRate = 72 * 1000;
|
|
||||||
for (i = 0; i < scrn->NumModes; i++)
|
|
||||||
scrn->Modes[i].Handle = i + 1;
|
|
||||||
|
|
||||||
/* Create list of visual configs - this is a silly example */
|
/* Create the screen's modes - silly example */
|
||||||
disp->NumConfigs = 4;
|
_eglAddMode(scrn, 1600, 1200, 32, 72 * 1000);
|
||||||
disp->Configs = (_EGLConfig *) calloc(disp->NumConfigs, sizeof(_EGLConfig));
|
_eglAddMode(scrn, 1280, 1024, 32, 72 * 1000);
|
||||||
for (i = 0; i < disp->NumConfigs; i++) {
|
_eglAddMode(scrn, 1280, 1024, 16, 72 * 1000);
|
||||||
_EGLConfig *config = disp->Configs + i;
|
_eglAddMode(scrn, 1024, 768, 32, 72 * 1000);
|
||||||
_eglInitConfig(config, i + 1);
|
|
||||||
SET_CONFIG_ATTRIB(config, EGL_RED_SIZE, 8);
|
|
||||||
SET_CONFIG_ATTRIB(config, EGL_GREEN_SIZE, 8);
|
|
||||||
SET_CONFIG_ATTRIB(config, EGL_BLUE_SIZE, 8);
|
|
||||||
SET_CONFIG_ATTRIB(config, EGL_ALPHA_SIZE, 8);
|
|
||||||
SET_CONFIG_ATTRIB(config, EGL_BUFFER_SIZE, 32);
|
|
||||||
|
|
||||||
|
/* Create the display's visual configs - silly example */
|
||||||
|
for (i = 0; i < 4; i++) {
|
||||||
|
_EGLConfig config;
|
||||||
|
_eglInitConfig(&config, i + 1);
|
||||||
|
SET_CONFIG_ATTRIB(&config, EGL_RED_SIZE, 8);
|
||||||
|
SET_CONFIG_ATTRIB(&config, EGL_GREEN_SIZE, 8);
|
||||||
|
SET_CONFIG_ATTRIB(&config, EGL_BLUE_SIZE, 8);
|
||||||
|
SET_CONFIG_ATTRIB(&config, EGL_ALPHA_SIZE, 8);
|
||||||
|
SET_CONFIG_ATTRIB(&config, EGL_BUFFER_SIZE, 32);
|
||||||
if (i & 1) {
|
if (i & 1) {
|
||||||
SET_CONFIG_ATTRIB(config, EGL_DEPTH_SIZE, 32);
|
SET_CONFIG_ATTRIB(&config, EGL_DEPTH_SIZE, 32);
|
||||||
}
|
}
|
||||||
if (i & 2) {
|
if (i & 2) {
|
||||||
SET_CONFIG_ATTRIB(config, EGL_STENCIL_SIZE, 8);
|
SET_CONFIG_ATTRIB(&config, EGL_STENCIL_SIZE, 8);
|
||||||
}
|
}
|
||||||
|
SET_CONFIG_ATTRIB(&config, EGL_SURFACE_TYPE,
|
||||||
SET_CONFIG_ATTRIB(config, EGL_SURFACE_TYPE,
|
|
||||||
(EGL_WINDOW_BIT | EGL_PIXMAP_BIT | EGL_PBUFFER_BIT));
|
(EGL_WINDOW_BIT | EGL_PIXMAP_BIT | EGL_PBUFFER_BIT));
|
||||||
|
_eglAddConfig(disp, &config);
|
||||||
}
|
}
|
||||||
|
|
||||||
drv->Initialized = EGL_TRUE;
|
drv->Initialized = EGL_TRUE;
|
||||||
|
@@ -370,24 +370,24 @@ void (* APIENTRY eglGetProcAddress(const char *procname))()
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
EGLBoolean APIENTRY
|
EGLBoolean APIENTRY
|
||||||
eglChooseModeMESA(EGLDisplay dpy, EGLint screen_number,
|
eglChooseModeMESA(EGLDisplay dpy, EGLScreenMESA screen,
|
||||||
const EGLint *attrib_list, EGLModeMESA *modes,
|
const EGLint *attrib_list, EGLModeMESA *modes,
|
||||||
EGLint modes_size, EGLint *num_modes)
|
EGLint modes_size, EGLint *num_modes)
|
||||||
{
|
{
|
||||||
_EGLDriver *drv = _eglLookupDriver(dpy);
|
_EGLDriver *drv = _eglLookupDriver(dpy);
|
||||||
if (drv)
|
if (drv)
|
||||||
return drv->ChooseModeMESA(drv, dpy, screen_number, attrib_list, modes, modes_size, num_modes);
|
return drv->ChooseModeMESA(drv, dpy, screen, attrib_list, modes, modes_size, num_modes);
|
||||||
else
|
else
|
||||||
return EGL_FALSE;
|
return EGL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EGLBoolean APIENTRY
|
EGLBoolean APIENTRY
|
||||||
eglGetModesMESA(EGLDisplay dpy, EGLint screen_number, EGLModeMESA *modes, EGLint mode_size, EGLint *num_mode)
|
eglGetModesMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *modes, EGLint mode_size, EGLint *num_mode)
|
||||||
{
|
{
|
||||||
_EGLDriver *drv = _eglLookupDriver(dpy);
|
_EGLDriver *drv = _eglLookupDriver(dpy);
|
||||||
if (drv)
|
if (drv)
|
||||||
return drv->GetModesMESA(drv, dpy, screen_number, modes, mode_size, num_mode);
|
return drv->GetModesMESA(drv, dpy, screen, modes, mode_size, num_mode);
|
||||||
else
|
else
|
||||||
return EGL_FALSE;
|
return EGL_FALSE;
|
||||||
}
|
}
|
||||||
@@ -404,6 +404,17 @@ eglGetModeAttribMESA(EGLDisplay dpy, EGLModeMESA mode, EGLint attribute, EGLint
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EGLBoolean
|
||||||
|
eglGetScreensMESA(EGLDisplay dpy, EGLScreenMESA *screens, EGLint max_screens, EGLint *num_screens)
|
||||||
|
{
|
||||||
|
_EGLDriver *drv = _eglLookupDriver(dpy);
|
||||||
|
if (drv)
|
||||||
|
return drv->GetScreensMESA(drv, dpy, screens, max_screens, num_screens);
|
||||||
|
else
|
||||||
|
return EGL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
EGLSurface
|
EGLSurface
|
||||||
eglCreateScreenSurfaceMESA(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)
|
eglCreateScreenSurfaceMESA(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)
|
||||||
{
|
{
|
||||||
@@ -419,42 +430,21 @@ eglShowSurfaceMESA(EGLDisplay dpy, EGLint screen, EGLSurface surface)
|
|||||||
|
|
||||||
|
|
||||||
EGLBoolean
|
EGLBoolean
|
||||||
eglScreenModeMESA(EGLDisplay dpy, EGLint screen_number, EGLModeMESA mode)
|
eglScreenModeMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA mode)
|
||||||
{
|
{
|
||||||
return EGL_FALSE;
|
return EGL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EGLBoolean
|
EGLBoolean
|
||||||
eglScreenAttribsMESA(EGLDisplay dpy, EGLint screen, const EGLint *attrib_list)
|
eglQueryScreenSurfaceMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLSurface *surface)
|
||||||
{
|
{
|
||||||
return EGL_FALSE;
|
return EGL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EGLBoolean
|
EGLBoolean
|
||||||
eglQueryDisplayMESA(EGLDisplay dpy, EGLint attribute, EGLint *value)
|
eglQueryScreenMESA( EGLDisplay dpy, EGLScreenMESA screen, EGLint attribute, EGLint *value)
|
||||||
{
|
|
||||||
return EGL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
EGLBoolean
|
|
||||||
eglQueryScreenSurfaceMESA(EGLDisplay dpy, EGLint screen_number, EGLSurface *surface)
|
|
||||||
{
|
|
||||||
return EGL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
EGLBoolean
|
|
||||||
eglQueryScreenModeMESA(EGLDisplay dpy, EGLint screen_number, EGLModeMESA *mode)
|
|
||||||
{
|
|
||||||
return EGL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
EGLBoolean
|
|
||||||
eglQueryScreenMESA( EGLDisplay dpy, EGLint screen_number, EGLint attribute, EGLint *value)
|
|
||||||
{
|
{
|
||||||
return EGL_FALSE;
|
return EGL_FALSE;
|
||||||
}
|
}
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "eglconfig.h"
|
#include "eglconfig.h"
|
||||||
@@ -51,6 +52,31 @@ _eglLookupConfig(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the given _EGLConifg to the given display.
|
||||||
|
*/
|
||||||
|
_EGLConfig *
|
||||||
|
_eglAddConfig(_EGLDisplay *display, const _EGLConfig *config)
|
||||||
|
{
|
||||||
|
_EGLConfig *newConfigs;
|
||||||
|
EGLint n;
|
||||||
|
|
||||||
|
n = display->NumConfigs;
|
||||||
|
|
||||||
|
newConfigs = (_EGLConfig *) realloc(display->Configs,
|
||||||
|
(n + 1) * sizeof(_EGLConfig));
|
||||||
|
if (newConfigs) {
|
||||||
|
display->Configs = newConfigs;
|
||||||
|
display->Configs[n] = *config; /* copy struct */
|
||||||
|
display->NumConfigs++;
|
||||||
|
return display->Configs + n;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse the attrib_list to fill in the fields of the given _egl_config
|
* Parse the attrib_list to fill in the fields of the given _egl_config
|
||||||
|
@@ -29,6 +29,10 @@ extern _EGLConfig *
|
|||||||
_eglLookupConfig(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config);
|
_eglLookupConfig(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config);
|
||||||
|
|
||||||
|
|
||||||
|
extern _EGLConfig *
|
||||||
|
_eglAddConfig(_EGLDisplay *display, const _EGLConfig *config);
|
||||||
|
|
||||||
|
|
||||||
extern EGLBoolean
|
extern EGLBoolean
|
||||||
_eglParseConfigAttribs(_EGLConfig *config, const EGLint *attrib_list);
|
_eglParseConfigAttribs(_EGLConfig *config, const EGLint *attrib_list);
|
||||||
|
|
||||||
|
@@ -13,7 +13,7 @@ struct _egl_display
|
|||||||
_EGLDriver *Driver;
|
_EGLDriver *Driver;
|
||||||
|
|
||||||
EGLint NumScreens;
|
EGLint NumScreens;
|
||||||
_EGLScreen *Screens; /* array [NumScreens] */
|
_EGLScreen **Screens; /* array [NumScreens] */
|
||||||
|
|
||||||
EGLint NumConfigs;
|
EGLint NumConfigs;
|
||||||
_EGLConfig *Configs; /* array [NumConfigs] */
|
_EGLConfig *Configs; /* array [NumConfigs] */
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
#include "egldriver.h"
|
#include "egldriver.h"
|
||||||
#include "eglglobals.h"
|
#include "eglglobals.h"
|
||||||
#include "eglmode.h"
|
#include "eglmode.h"
|
||||||
|
#include "eglscreen.h"
|
||||||
#include "eglsurface.h"
|
#include "eglsurface.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -181,8 +182,16 @@ _eglInitDriverFallbacks(_EGLDriver *drv)
|
|||||||
drv->WaitNative = _eglWaitNative;
|
drv->WaitNative = _eglWaitNative;
|
||||||
|
|
||||||
/* EGL_MESA_screen */
|
/* EGL_MESA_screen */
|
||||||
|
drv->ChooseModeMESA = _eglChooseModeMESA;
|
||||||
drv->GetModesMESA = _eglGetModesMESA;
|
drv->GetModesMESA = _eglGetModesMESA;
|
||||||
drv->GetModeAttribMESA = _eglGetModeAttribMESA;
|
drv->GetModeAttribMESA = _eglGetModeAttribMESA;
|
||||||
|
drv->GetScreensMESA = _eglGetScreensMESA;
|
||||||
|
drv->CreateScreenSurfaceMESA = _eglCreateScreenSurfaceMESA;
|
||||||
|
drv->ShowSurfaceMESA = _eglShowSurfaceMESA;
|
||||||
|
drv->ScreenPositionMESA = _eglScreenPositionMESA;
|
||||||
|
drv->QueryScreenMESA = _eglQueryScreenMESA;
|
||||||
|
drv->QueryScreenSurfaceMESA = _eglQueryScreenSurfaceMESA;
|
||||||
|
drv->QueryScreenModeMESA = _eglQueryScreenModeMESA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -40,10 +40,16 @@ typedef EGLBoolean (*WaitNative_t)(_EGLDriver *drv, EGLDisplay dpy, EGLint engin
|
|||||||
|
|
||||||
|
|
||||||
/* EGL_MESA_screen extension */
|
/* EGL_MESA_screen extension */
|
||||||
typedef EGLBoolean (*ChooseModeMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number, const EGLint *attrib_list, EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes);
|
typedef EGLBoolean (*ChooseModeMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, const EGLint *attrib_list, EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes);
|
||||||
typedef EGLBoolean (*GetModesMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number, EGLModeMESA *modes, EGLint mode_size, EGLint *num_mode);
|
typedef EGLBoolean (*GetModesMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *modes, EGLint mode_size, EGLint *num_mode);
|
||||||
typedef EGLBoolean (*GetModeAttribMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLModeMESA mode, EGLint attribute, EGLint *value);
|
typedef EGLBoolean (*GetModeAttribMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLModeMESA mode, EGLint attribute, EGLint *value);
|
||||||
|
typedef EGLBoolean (*GetScreensMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA *screens, EGLint max_screens, EGLint *num_screens);
|
||||||
|
typedef EGLSurface (*CreateScreenSurfaceMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
|
||||||
|
typedef EGLBoolean (*ShowSurfaceMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLSurface surface);
|
||||||
|
typedef EGLBoolean (*ScreenPositionMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLint x, EGLint y);
|
||||||
|
typedef EGLBoolean (*QueryScreenMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLint attribute, EGLint *value);
|
||||||
|
typedef EGLBoolean (*QueryScreenSurfaceMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLSurface *surface);
|
||||||
|
typedef EGLBoolean (*QueryScreenModeMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *mode);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -96,6 +102,13 @@ struct _egl_driver
|
|||||||
ChooseModeMESA_t ChooseModeMESA;
|
ChooseModeMESA_t ChooseModeMESA;
|
||||||
GetModesMESA_t GetModesMESA;
|
GetModesMESA_t GetModesMESA;
|
||||||
GetModeAttribMESA_t GetModeAttribMESA;
|
GetModeAttribMESA_t GetModeAttribMESA;
|
||||||
|
GetScreensMESA_t GetScreensMESA;
|
||||||
|
CreateScreenSurfaceMESA_t CreateScreenSurfaceMESA;
|
||||||
|
ShowSurfaceMESA_t ShowSurfaceMESA;
|
||||||
|
ScreenPositionMESA_t ScreenPositionMESA;
|
||||||
|
QueryScreenMESA_t QueryScreenMESA;
|
||||||
|
QueryScreenSurfaceMESA_t QueryScreenSurfaceMESA;
|
||||||
|
QueryScreenModeMESA_t QueryScreenModeMESA;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -16,6 +16,7 @@ _eglInitGlobals(void)
|
|||||||
_eglGlobal.Displays = _eglNewHashTable();
|
_eglGlobal.Displays = _eglNewHashTable();
|
||||||
_eglGlobal.Contexts = _eglNewHashTable();
|
_eglGlobal.Contexts = _eglNewHashTable();
|
||||||
_eglGlobal.Surfaces = _eglNewHashTable();
|
_eglGlobal.Surfaces = _eglNewHashTable();
|
||||||
|
_eglGlobal.FreeScreenHandle = 1;
|
||||||
_eglGlobal.CurrentContext = EGL_NO_CONTEXT;
|
_eglGlobal.CurrentContext = EGL_NO_CONTEXT;
|
||||||
_eglGlobal.LastError = EGL_SUCCESS;
|
_eglGlobal.LastError = EGL_SUCCESS;
|
||||||
_eglGlobal.Initialized = EGL_TRUE;
|
_eglGlobal.Initialized = EGL_TRUE;
|
||||||
@@ -49,3 +50,16 @@ _eglError(EGLint errCode, const char *msg)
|
|||||||
fprintf(stderr, "EGL Error 0x%x in %s\n", errCode, msg);
|
fprintf(stderr, "EGL Error 0x%x in %s\n", errCode, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a new screen handle/ID.
|
||||||
|
* NOTE: we never reuse these!
|
||||||
|
*/
|
||||||
|
EGLScreenMESA
|
||||||
|
_eglAllocScreenHandle(void)
|
||||||
|
{
|
||||||
|
EGLScreenMESA s = _eglGlobal.FreeScreenHandle;
|
||||||
|
_eglGlobal.FreeScreenHandle++;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
@@ -13,6 +13,8 @@ struct _egl_global
|
|||||||
_EGLHashtable *Contexts;
|
_EGLHashtable *Contexts;
|
||||||
_EGLHashtable *Surfaces;
|
_EGLHashtable *Surfaces;
|
||||||
|
|
||||||
|
EGLScreenMESA FreeScreenHandle;
|
||||||
|
|
||||||
EGLint LastError;
|
EGLint LastError;
|
||||||
|
|
||||||
/* XXX this should be per-thread someday */
|
/* XXX this should be per-thread someday */
|
||||||
@@ -35,4 +37,8 @@ extern void
|
|||||||
_eglError(EGLint errCode, const char *msg);
|
_eglError(EGLint errCode, const char *msg);
|
||||||
|
|
||||||
|
|
||||||
|
extern EGLScreenMESA
|
||||||
|
_eglAllocScreenHandle(void);
|
||||||
|
|
||||||
|
|
||||||
#endif /* EGLGLOBALS_INCLUDED */
|
#endif /* EGLGLOBALS_INCLUDED */
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
#include <assert.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include "egldisplay.h"
|
#include "egldisplay.h"
|
||||||
#include "egldriver.h"
|
#include "egldriver.h"
|
||||||
#include "eglmode.h"
|
#include "eglmode.h"
|
||||||
@@ -8,30 +10,76 @@
|
|||||||
#define MIN2(A, B) (((A) < (B)) ? (A) : (B))
|
#define MIN2(A, B) (((A) < (B)) ? (A) : (B))
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given an EGLModeMESA handle, return the corresponding _EGLMode object
|
||||||
|
* or null if non-existant.
|
||||||
|
*/
|
||||||
_EGLMode *
|
_EGLMode *
|
||||||
_eglLookupMode(EGLDisplay dpy, EGLModeMESA mode)
|
_eglLookupMode(EGLDisplay dpy, EGLModeMESA mode)
|
||||||
{
|
{
|
||||||
const _EGLDisplay *disp = _eglLookupDisplay(dpy);
|
const _EGLDisplay *disp = _eglLookupDisplay(dpy);
|
||||||
EGLint scrnum;
|
EGLint scrnum;
|
||||||
|
|
||||||
|
/* loop over all screens on the display */
|
||||||
for (scrnum = 0; scrnum < disp->NumScreens; scrnum++) {
|
for (scrnum = 0; scrnum < disp->NumScreens; scrnum++) {
|
||||||
const _EGLScreen *scrn = disp->Screens + scrnum;
|
const _EGLScreen *scrn = disp->Screens[scrnum];
|
||||||
EGLint i;
|
EGLint i;
|
||||||
|
/* search list of modes for handle */
|
||||||
for (i = 0; i < scrn->NumModes; i++) {
|
for (i = 0; i < scrn->NumModes; i++) {
|
||||||
if (scrn->Modes[i].Handle == mode) {
|
if (scrn->Modes[i].Handle == mode) {
|
||||||
return scrn->Modes + i;
|
return scrn->Modes + i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new mode with the given attributes (width, height, depth, refreshRate)
|
||||||
|
* to the given screen.
|
||||||
|
* Assign a new mode ID/handle to the mode as well.
|
||||||
|
* \return pointer to the new _EGLMode
|
||||||
|
*/
|
||||||
|
_EGLMode *
|
||||||
|
_eglAddMode(_EGLScreen *screen, EGLint width, EGLint height,
|
||||||
|
EGLint depth, EGLint refreshRate)
|
||||||
|
{
|
||||||
|
EGLint n;
|
||||||
|
_EGLMode *newModes;
|
||||||
|
|
||||||
|
assert(screen);
|
||||||
|
assert(width > 0);
|
||||||
|
assert(height > 0);
|
||||||
|
assert(depth > 0);
|
||||||
|
assert(refreshRate > 0);
|
||||||
|
|
||||||
|
n = screen->NumModes;
|
||||||
|
newModes = (_EGLMode *) realloc(screen->Modes, (n+1) * sizeof(_EGLMode));
|
||||||
|
if (newModes) {
|
||||||
|
screen->Modes = newModes;
|
||||||
|
screen->Modes[n].Handle = n + 1;
|
||||||
|
screen->Modes[n].Width = width;
|
||||||
|
screen->Modes[n].Height = height;
|
||||||
|
screen->Modes[n].Depth = depth;
|
||||||
|
screen->Modes[n].RefreshRate = refreshRate;
|
||||||
|
screen->Modes[n].Stereo = EGL_FALSE;
|
||||||
|
screen->NumModes++;
|
||||||
|
return screen->Modes + n;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search for the EGLMode that best matches the given attribute list.
|
* Search for the EGLMode that best matches the given attribute list.
|
||||||
*/
|
*/
|
||||||
EGLBoolean
|
EGLBoolean
|
||||||
_eglChooseModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number,
|
_eglChooseModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen,
|
||||||
const EGLint *attrib_list, EGLModeMESA *modes,
|
const EGLint *attrib_list, EGLModeMESA *modes,
|
||||||
EGLint modes_size, EGLint *num_modes)
|
EGLint modes_size, EGLint *num_modes)
|
||||||
{
|
{
|
||||||
@@ -70,10 +118,10 @@ _eglChooseModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number,
|
|||||||
* Return all possible modes for the given screen
|
* Return all possible modes for the given screen
|
||||||
*/
|
*/
|
||||||
EGLBoolean
|
EGLBoolean
|
||||||
_eglGetModesMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number,
|
_eglGetModesMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen,
|
||||||
EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes)
|
EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes)
|
||||||
{
|
{
|
||||||
_EGLScreen *scrn = _eglLookupScreen(dpy, screen_number);
|
_EGLScreen *scrn = _eglLookupScreen(dpy, screen);
|
||||||
EGLint i;
|
EGLint i;
|
||||||
|
|
||||||
if (!scrn) {
|
if (!scrn) {
|
||||||
|
@@ -3,9 +3,13 @@
|
|||||||
|
|
||||||
#include "egltypedefs.h"
|
#include "egltypedefs.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data structure which corresponds to an EGLModeMESA.
|
||||||
|
*/
|
||||||
struct _egl_mode
|
struct _egl_mode
|
||||||
{
|
{
|
||||||
EGLConfig Handle; /* the public/opaque handle which names this mode */
|
EGLModeMESA Handle; /* the public/opaque handle which names this mode */
|
||||||
EGLint Width, Height; /* size in pixels */
|
EGLint Width, Height; /* size in pixels */
|
||||||
EGLint Depth; /* bits per pixel */
|
EGLint Depth; /* bits per pixel */
|
||||||
EGLint RefreshRate; /* rate * 1000.0 */
|
EGLint RefreshRate; /* rate * 1000.0 */
|
||||||
@@ -21,14 +25,19 @@ extern _EGLMode *
|
|||||||
_eglLookupMode(EGLDisplay dpy, EGLModeMESA mode);
|
_eglLookupMode(EGLDisplay dpy, EGLModeMESA mode);
|
||||||
|
|
||||||
|
|
||||||
|
extern _EGLMode *
|
||||||
|
_eglAddMode(_EGLScreen *screen, EGLint width, EGLint height,
|
||||||
|
EGLint depth, EGLint refreshRate);
|
||||||
|
|
||||||
|
|
||||||
extern EGLBoolean
|
extern EGLBoolean
|
||||||
_eglChooseModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number,
|
_eglChooseModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen,
|
||||||
const EGLint *attrib_list, EGLModeMESA *modes,
|
const EGLint *attrib_list, EGLModeMESA *modes,
|
||||||
EGLint modes_size, EGLint *num_modes);
|
EGLint modes_size, EGLint *num_modes);
|
||||||
|
|
||||||
|
|
||||||
extern EGLBoolean
|
extern EGLBoolean
|
||||||
_eglGetModesMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number,
|
_eglGetModesMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen,
|
||||||
EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes);
|
EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes);
|
||||||
|
|
||||||
|
|
||||||
|
@@ -2,14 +2,13 @@
|
|||||||
* Ideas for screen management extension to EGL.
|
* Ideas for screen management extension to EGL.
|
||||||
*
|
*
|
||||||
* Each EGLDisplay has one or more screens (CRTs, Flat Panels, etc).
|
* Each EGLDisplay has one or more screens (CRTs, Flat Panels, etc).
|
||||||
* The number of screens can be queried with eglQueryDisplay(EGL_SCREEN_COUNT).
|
* The screens' handles can be obtained with eglGetScreensMESA().
|
||||||
*
|
*
|
||||||
* A new kind of EGLSurface is possible- one which can be directly scanned
|
* A new kind of EGLSurface is possible- one which can be directly scanned
|
||||||
* out on a screen. Such a surface is created with eglCreateScreenSurface().
|
* out on a screen. Such a surface is created with eglCreateScreenSurface().
|
||||||
*
|
*
|
||||||
* To actually display a screen surface on a screen, the eglShowSurface()
|
* To actually display a screen surface on a screen, the eglShowSurface()
|
||||||
* function is called.
|
* function is called.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@@ -21,16 +20,84 @@
|
|||||||
#include "eglscreen.h"
|
#include "eglscreen.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a new _EGLScreen object.
|
||||||
|
*/
|
||||||
_EGLScreen *
|
_EGLScreen *
|
||||||
_eglLookupScreen(EGLDisplay dpy, GLint screenNumber)
|
_eglNewScreen(void)
|
||||||
{
|
{
|
||||||
_EGLDisplay *disp = _eglLookupDisplay(dpy);
|
return (_EGLScreen *) calloc(1, sizeof(_EGLScreen));
|
||||||
if (!disp || screenNumber < 0 || screenNumber >= disp->NumScreens) {
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a public screen handle, return the internal _EGLScreen object.
|
||||||
|
*/
|
||||||
|
_EGLScreen *
|
||||||
|
_eglLookupScreen(EGLDisplay dpy, EGLScreenMESA screen)
|
||||||
|
{
|
||||||
|
EGLint i;
|
||||||
|
_EGLDisplay *display = _eglLookupDisplay(dpy);
|
||||||
|
|
||||||
|
if (!display)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < display->NumScreens; i++) {
|
||||||
|
if (display->Screens[i]->Handle == screen)
|
||||||
|
return display->Screens[i];
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the given _EGLScreen to the display's list of screens.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
_eglAddScreen(_EGLDisplay *display, _EGLScreen *screen)
|
||||||
|
{
|
||||||
|
EGLint n;
|
||||||
|
|
||||||
|
assert(display);
|
||||||
|
assert(screen);
|
||||||
|
|
||||||
|
screen->Handle = _eglAllocScreenHandle();
|
||||||
|
n = display->NumScreens;
|
||||||
|
display->Screens = realloc(display->Screens, (n+1) * sizeof(_EGLScreen *));
|
||||||
|
display->Screens[n] = screen;
|
||||||
|
display->NumScreens++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
EGLBoolean
|
||||||
|
_eglGetScreensMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA *screens,
|
||||||
|
EGLint max_screens, EGLint *num_screens)
|
||||||
|
{
|
||||||
|
_EGLDisplay *display = _eglLookupDisplay(dpy);
|
||||||
|
EGLint n;
|
||||||
|
|
||||||
|
if (!display) {
|
||||||
|
_eglError(EGL_BAD_DISPLAY, "eglGetScreensMESA");
|
||||||
|
return EGL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (display->NumScreens > max_screens) {
|
||||||
|
n = max_screens;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return disp->Screens + screenNumber;
|
n = display->NumScreens;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (screens) {
|
||||||
|
EGLint i;
|
||||||
|
for (i = 0; i < n; i++)
|
||||||
|
screens[i] = display->Screens[i]->Handle;
|
||||||
|
}
|
||||||
|
if (num_screens)
|
||||||
|
*num_screens = n;
|
||||||
|
|
||||||
|
return EGL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -87,10 +154,10 @@ _eglCreateScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config,
|
|||||||
* this with code that _really_ shows the surface.
|
* this with code that _really_ shows the surface.
|
||||||
*/
|
*/
|
||||||
EGLBoolean
|
EGLBoolean
|
||||||
_eglShowSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number,
|
_eglShowSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen,
|
||||||
EGLSurface surface)
|
EGLSurface surface)
|
||||||
{
|
{
|
||||||
_EGLScreen *scrn = _eglLookupScreen(dpy, screen_number);
|
_EGLScreen *scrn = _eglLookupScreen(dpy, screen);
|
||||||
_EGLMode *mode;
|
_EGLMode *mode;
|
||||||
|
|
||||||
if (!scrn) {
|
if (!scrn) {
|
||||||
@@ -139,10 +206,10 @@ _eglShowSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number,
|
|||||||
* this with code that _really_ sets the mode.
|
* this with code that _really_ sets the mode.
|
||||||
*/
|
*/
|
||||||
EGLBoolean
|
EGLBoolean
|
||||||
_eglScreenModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number,
|
_eglScreenModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen,
|
||||||
EGLModeMESA mode)
|
EGLModeMESA mode)
|
||||||
{
|
{
|
||||||
_EGLScreen *scrn = _eglLookupScreen(dpy, screen_number);
|
_EGLScreen *scrn = _eglLookupScreen(dpy, screen);
|
||||||
|
|
||||||
if (!scrn) {
|
if (!scrn) {
|
||||||
_eglError(EGL_BAD_SCREEN_MESA, "eglScreenModeMESA");
|
_eglError(EGL_BAD_SCREEN_MESA, "eglScreenModeMESA");
|
||||||
@@ -160,9 +227,9 @@ _eglScreenModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number,
|
|||||||
*/
|
*/
|
||||||
EGLBoolean
|
EGLBoolean
|
||||||
_eglScreenPositionMESA(_EGLDriver *drv, EGLDisplay dpy,
|
_eglScreenPositionMESA(_EGLDriver *drv, EGLDisplay dpy,
|
||||||
EGLint screen_number, EGLint x, EGLint y)
|
EGLScreenMESA screen, EGLint x, EGLint y)
|
||||||
{
|
{
|
||||||
_EGLScreen *scrn = _eglLookupScreen(dpy, screen_number);
|
_EGLScreen *scrn = _eglLookupScreen(dpy, screen);
|
||||||
if (!scrn) {
|
if (!scrn) {
|
||||||
_eglError(EGL_BAD_SCREEN_MESA, "eglScreenPositionMESA");
|
_eglError(EGL_BAD_SCREEN_MESA, "eglScreenPositionMESA");
|
||||||
return EGL_FALSE;
|
return EGL_FALSE;
|
||||||
@@ -175,31 +242,14 @@ _eglScreenPositionMESA(_EGLDriver *drv, EGLDisplay dpy,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EGLBoolean
|
|
||||||
_eglQueryDisplayMESA(_EGLDriver *drv, EGLDisplay dpy,
|
|
||||||
EGLint attribute, EGLint *value)
|
|
||||||
{
|
|
||||||
const _EGLDisplay *display = _eglLookupDisplay(dpy);
|
|
||||||
switch (attribute) {
|
|
||||||
case EGL_SCREEN_COUNT_MESA:
|
|
||||||
*value = display->NumScreens;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
_eglError(EGL_BAD_ATTRIBUTE, "eglQueryDisplayMESA");
|
|
||||||
return EGL_FALSE;
|
|
||||||
}
|
|
||||||
return EGL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query a screen's current surface.
|
* Query a screen's current surface.
|
||||||
*/
|
*/
|
||||||
EGLBoolean
|
EGLBoolean
|
||||||
_eglQueryScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy,
|
_eglQueryScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy,
|
||||||
EGLint screen_number, EGLSurface *surface)
|
EGLScreenMESA screen, EGLSurface *surface)
|
||||||
{
|
{
|
||||||
const _EGLScreen *scrn = _eglLookupScreen(dpy, screen_number);
|
const _EGLScreen *scrn = _eglLookupScreen(dpy, screen);
|
||||||
if (scrn->CurrentSurface)
|
if (scrn->CurrentSurface)
|
||||||
*surface = scrn->CurrentSurface->Handle;
|
*surface = scrn->CurrentSurface->Handle;
|
||||||
else
|
else
|
||||||
@@ -212,10 +262,10 @@ _eglQueryScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy,
|
|||||||
* Query a screen's current mode.
|
* Query a screen's current mode.
|
||||||
*/
|
*/
|
||||||
EGLBoolean
|
EGLBoolean
|
||||||
_eglQueryScreenModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number,
|
_eglQueryScreenModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen,
|
||||||
EGLModeMESA *mode)
|
EGLModeMESA *mode)
|
||||||
{
|
{
|
||||||
const _EGLScreen *scrn = _eglLookupScreen(dpy, screen_number);
|
const _EGLScreen *scrn = _eglLookupScreen(dpy, screen);
|
||||||
if (scrn->CurrentMode)
|
if (scrn->CurrentMode)
|
||||||
*mode = scrn->CurrentMode->Handle;
|
*mode = scrn->CurrentMode->Handle;
|
||||||
else
|
else
|
||||||
@@ -225,10 +275,10 @@ _eglQueryScreenModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number,
|
|||||||
|
|
||||||
|
|
||||||
EGLBoolean
|
EGLBoolean
|
||||||
_eglQueryScreenMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number,
|
_eglQueryScreenMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen,
|
||||||
EGLint attribute, EGLint *value)
|
EGLint attribute, EGLint *value)
|
||||||
{
|
{
|
||||||
const _EGLScreen *scrn = _eglLookupScreen(dpy, screen_number);
|
const _EGLScreen *scrn = _eglLookupScreen(dpy, screen);
|
||||||
|
|
||||||
if (!scrn) {
|
if (!scrn) {
|
||||||
_eglError(EGL_BAD_SCREEN_MESA, "eglQueryScreenMESA");
|
_eglError(EGL_BAD_SCREEN_MESA, "eglQueryScreenMESA");
|
||||||
|
@@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
struct _egl_screen
|
struct _egl_screen
|
||||||
{
|
{
|
||||||
|
EGLScreenMESA Handle; /* The public/opaque handle which names this object */
|
||||||
|
|
||||||
_EGLMode *CurrentMode;
|
_EGLMode *CurrentMode;
|
||||||
_EGLSurface *CurrentSurface;
|
_EGLSurface *CurrentSurface;
|
||||||
EGLint OriginX, OriginY;
|
EGLint OriginX, OriginY;
|
||||||
@@ -18,7 +20,19 @@ struct _egl_screen
|
|||||||
|
|
||||||
|
|
||||||
extern _EGLScreen *
|
extern _EGLScreen *
|
||||||
_eglLookupScreen(EGLDisplay dpy, GLint screenNumber);
|
_eglNewScreen(void);
|
||||||
|
|
||||||
|
|
||||||
|
extern _EGLScreen *
|
||||||
|
_eglLookupScreen(EGLDisplay dpy, EGLScreenMESA screen);
|
||||||
|
|
||||||
|
|
||||||
|
extern void
|
||||||
|
_eglAddScreen(_EGLDisplay *display, _EGLScreen *screen);
|
||||||
|
|
||||||
|
|
||||||
|
extern EGLBoolean
|
||||||
|
_eglGetScreensMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA *screens, EGLint max_screens, EGLint *num_screens);
|
||||||
|
|
||||||
|
|
||||||
extern EGLSurface
|
extern EGLSurface
|
||||||
@@ -26,15 +40,15 @@ _eglCreateScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, c
|
|||||||
|
|
||||||
|
|
||||||
extern EGLBoolean
|
extern EGLBoolean
|
||||||
_eglShowSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen, EGLSurface surface);
|
_eglShowSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLSurface surface);
|
||||||
|
|
||||||
|
|
||||||
extern EGLBoolean
|
extern EGLBoolean
|
||||||
_eglScreenModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number, EGLModeMESA mode);
|
_eglScreenModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA mode);
|
||||||
|
|
||||||
|
|
||||||
extern EGLBoolean
|
extern EGLBoolean
|
||||||
_eglScreenPositionMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number, EGLint x, EGLint y);
|
_eglScreenPositionMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLint x, EGLint y);
|
||||||
|
|
||||||
|
|
||||||
extern EGLBoolean
|
extern EGLBoolean
|
||||||
@@ -43,15 +57,15 @@ _eglQueryDisplayMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint attribute, EGLint *
|
|||||||
|
|
||||||
extern EGLBoolean
|
extern EGLBoolean
|
||||||
_eglQueryScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy,
|
_eglQueryScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy,
|
||||||
EGLint screen_number, EGLSurface *surface);
|
EGLScreenMESA screen, EGLSurface *surface);
|
||||||
|
|
||||||
|
|
||||||
extern EGLBoolean
|
extern EGLBoolean
|
||||||
_eglQueryScreenModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number, EGLModeMESA *mode);
|
_eglQueryScreenModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *mode);
|
||||||
|
|
||||||
|
|
||||||
extern EGLBoolean
|
extern EGLBoolean
|
||||||
_eglQueryScreenMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number, EGLint attribute, EGLint *value);
|
_eglQueryScreenMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLint attribute, EGLint *value);
|
||||||
|
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
|
Reference in New Issue
Block a user