mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-30 20:50:09 +01:00
st/egl: reorganize backend initialization
Remove set_event_handler() and pass the event handler with native_get_XXX_platform(). Add init_screen() so that the pipe screen is created later. This way we don't need to pass user_data to create_display().
This commit is contained in:
parent
ac8f59b23e
commit
73df31eedd
14 changed files with 174 additions and 199 deletions
|
|
@ -87,7 +87,7 @@ egl_g3d_lookup_egl_image(struct native_display *ndpy, void *egl_image)
|
|||
return resource;
|
||||
}
|
||||
|
||||
static struct native_event_handler egl_g3d_native_event_handler = {
|
||||
static const struct native_event_handler egl_g3d_native_event_handler = {
|
||||
egl_g3d_invalid_surface,
|
||||
egl_g3d_new_drm_screen,
|
||||
egl_g3d_new_sw_screen,
|
||||
|
|
@ -110,40 +110,38 @@ egl_g3d_get_platform(_EGLDriver *drv, _EGLPlatformType plat)
|
|||
case _EGL_PLATFORM_WINDOWS:
|
||||
plat_name = "Windows";
|
||||
#ifdef HAVE_GDI_BACKEND
|
||||
nplat = native_get_gdi_platform();
|
||||
nplat = native_get_gdi_platform(&egl_g3d_native_event_handler);
|
||||
#endif
|
||||
break;
|
||||
case _EGL_PLATFORM_X11:
|
||||
plat_name = "X11";
|
||||
#ifdef HAVE_X11_BACKEND
|
||||
nplat = native_get_x11_platform();
|
||||
nplat = native_get_x11_platform(&egl_g3d_native_event_handler);
|
||||
#endif
|
||||
break;
|
||||
case _EGL_PLATFORM_WAYLAND:
|
||||
plat_name = "wayland";
|
||||
#ifdef HAVE_WAYLAND_BACKEND
|
||||
nplat = native_get_wayland_platform();
|
||||
nplat = native_get_wayland_platform(&egl_g3d_native_event_handler);
|
||||
#endif
|
||||
break;
|
||||
case _EGL_PLATFORM_DRM:
|
||||
plat_name = "DRM";
|
||||
#ifdef HAVE_DRM_BACKEND
|
||||
nplat = native_get_drm_platform();
|
||||
nplat = native_get_drm_platform(&egl_g3d_native_event_handler);
|
||||
#endif
|
||||
break;
|
||||
case _EGL_PLATFORM_FBDEV:
|
||||
plat_name = "FBDEV";
|
||||
#ifdef HAVE_FBDEV_BACKEND
|
||||
nplat = native_get_fbdev_platform();
|
||||
nplat = native_get_fbdev_platform(&egl_g3d_native_event_handler);
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (nplat)
|
||||
nplat->set_event_handler(&egl_g3d_native_event_handler);
|
||||
else
|
||||
if (!nplat)
|
||||
_eglLog(_EGL_WARNING, "unsupported platform %s", plat_name);
|
||||
|
||||
gdrv->platforms[plat] = nplat;
|
||||
|
|
@ -520,13 +518,20 @@ egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy)
|
|||
gdpy->loader = gdrv->loader;
|
||||
dpy->DriverData = gdpy;
|
||||
|
||||
_eglLog(_EGL_INFO, "use %s for display %p", nplat->name, dpy->PlatformDisplay);
|
||||
gdpy->native = nplat->create_display(dpy->PlatformDisplay,
|
||||
dpy->Options.UseFallback, (void *) dpy);
|
||||
_eglLog(_EGL_INFO, "use %s for display %p",
|
||||
nplat->name, dpy->PlatformDisplay);
|
||||
gdpy->native =
|
||||
nplat->create_display(dpy->PlatformDisplay, dpy->Options.UseFallback);
|
||||
if (!gdpy->native) {
|
||||
_eglError(EGL_NOT_INITIALIZED, "eglInitialize(no usable display)");
|
||||
goto fail;
|
||||
}
|
||||
gdpy->native->user_data = (void *) dpy;
|
||||
if (!gdpy->native->init_screen(gdpy->native)) {
|
||||
_eglError(EGL_NOT_INITIALIZED,
|
||||
"eglInitialize(failed to initialize screen)");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (gdpy->loader->profile_masks[ST_API_OPENGL] & ST_PROFILE_DEFAULT_MASK)
|
||||
dpy->ClientAPIs |= EGL_OPENGL_BIT;
|
||||
|
|
|
|||
|
|
@ -152,6 +152,11 @@ struct native_display {
|
|||
*/
|
||||
void *user_data;
|
||||
|
||||
/**
|
||||
* Initialize and create the pipe screen.
|
||||
*/
|
||||
boolean (*init_screen)(struct native_display *ndpy);
|
||||
|
||||
void (*destroy)(struct native_display *ndpy);
|
||||
|
||||
/**
|
||||
|
|
@ -259,26 +264,29 @@ ndpy_uninit(struct native_display *ndpy)
|
|||
struct native_platform {
|
||||
const char *name;
|
||||
|
||||
void (*set_event_handler)(struct native_event_handler *handler);
|
||||
struct native_display *(*create_display)(void *dpy,
|
||||
boolean use_sw,
|
||||
void *user_data);
|
||||
/**
|
||||
* Create the native display and usually establish a connection to the
|
||||
* display server.
|
||||
*
|
||||
* No event should be generated at this stage.
|
||||
*/
|
||||
struct native_display *(*create_display)(void *dpy, boolean use_sw);
|
||||
};
|
||||
|
||||
const struct native_platform *
|
||||
native_get_gdi_platform(void);
|
||||
native_get_gdi_platform(const struct native_event_handler *event_handler);
|
||||
|
||||
const struct native_platform *
|
||||
native_get_x11_platform(void);
|
||||
native_get_x11_platform(const struct native_event_handler *event_handler);
|
||||
|
||||
const struct native_platform *
|
||||
native_get_wayland_platform(void);
|
||||
native_get_wayland_platform(const struct native_event_handler *event_handler);
|
||||
|
||||
const struct native_platform *
|
||||
native_get_drm_platform(void);
|
||||
native_get_drm_platform(const struct native_event_handler *event_handler);
|
||||
|
||||
const struct native_platform *
|
||||
native_get_fbdev_platform(void);
|
||||
native_get_fbdev_platform(const struct native_event_handler *event_handler);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -249,9 +249,15 @@ drm_create_pixmap_surface(struct native_display *ndpy,
|
|||
return drm_display_create_surface_from_resource(ndpy, bo->resource);
|
||||
}
|
||||
|
||||
static boolean
|
||||
drm_display_init_screen(struct native_display *ndpy)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static struct native_display *
|
||||
drm_create_display(struct gbm_gallium_drm_device *gbmdrm,
|
||||
struct native_event_handler *event_handler, void *user_data)
|
||||
const struct native_event_handler *event_handler)
|
||||
{
|
||||
struct drm_display *drmdpy;
|
||||
|
||||
|
|
@ -267,10 +273,10 @@ drm_create_display(struct gbm_gallium_drm_device *gbmdrm,
|
|||
gbmdrm->lookup_egl_image_data = &drmdpy->base;
|
||||
|
||||
drmdpy->event_handler = event_handler;
|
||||
drmdpy->base.user_data = user_data;
|
||||
|
||||
drmdpy->base.screen = gbmdrm->screen;
|
||||
|
||||
drmdpy->base.init_screen = drm_display_init_screen;
|
||||
drmdpy->base.destroy = drm_display_destroy;
|
||||
drmdpy->base.get_param = drm_display_get_param;
|
||||
drmdpy->base.get_configs = drm_display_get_configs;
|
||||
|
|
@ -287,16 +293,10 @@ drm_create_display(struct gbm_gallium_drm_device *gbmdrm,
|
|||
return &drmdpy->base;
|
||||
}
|
||||
|
||||
static struct native_event_handler *drm_event_handler;
|
||||
|
||||
static void
|
||||
native_set_event_handler(struct native_event_handler *event_handler)
|
||||
{
|
||||
drm_event_handler = event_handler;
|
||||
}
|
||||
static const struct native_event_handler *drm_event_handler;
|
||||
|
||||
static struct native_display *
|
||||
native_create_display(void *dpy, boolean use_sw, void *user_data)
|
||||
native_create_display(void *dpy, boolean use_sw)
|
||||
{
|
||||
struct gbm_gallium_drm_device *gbm;
|
||||
int fd;
|
||||
|
|
@ -315,17 +315,17 @@ native_create_display(void *dpy, boolean use_sw, void *user_data)
|
|||
gbm->base.type != GBM_DRM_DRIVER_TYPE_GALLIUM)
|
||||
return NULL;
|
||||
|
||||
return drm_create_display(gbm, drm_event_handler, user_data);
|
||||
return drm_create_display(gbm, drm_event_handler);
|
||||
}
|
||||
|
||||
static const struct native_platform drm_platform = {
|
||||
"DRM", /* name */
|
||||
native_set_event_handler,
|
||||
native_create_display
|
||||
};
|
||||
|
||||
const struct native_platform *
|
||||
native_get_drm_platform(void)
|
||||
native_get_drm_platform(const struct native_event_handler *event_handler)
|
||||
{
|
||||
drm_event_handler = event_handler;
|
||||
return &drm_platform;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ struct drm_surface;
|
|||
struct drm_display {
|
||||
struct native_display base;
|
||||
|
||||
struct native_event_handler *event_handler;
|
||||
const struct native_event_handler *event_handler;
|
||||
|
||||
int fd;
|
||||
char *device_name;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ struct fbdev_display {
|
|||
struct native_display base;
|
||||
|
||||
int fd;
|
||||
struct native_event_handler *event_handler;
|
||||
const struct native_event_handler *event_handler;
|
||||
|
||||
struct fb_fix_screeninfo finfo;
|
||||
struct fb_var_screeninfo vinfo;
|
||||
|
|
@ -393,47 +393,35 @@ fbdev_display_init_configs(struct native_display *ndpy)
|
|||
}
|
||||
|
||||
static boolean
|
||||
fbdev_display_init(struct native_display *ndpy)
|
||||
fbdev_display_init_screen(struct native_display *ndpy)
|
||||
{
|
||||
struct fbdev_display *fbdpy = fbdev_display(ndpy);
|
||||
struct sw_winsys *ws;
|
||||
|
||||
if (ioctl(fbdpy->fd, FBIOGET_FSCREENINFO, &fbdpy->finfo))
|
||||
return FALSE;
|
||||
|
||||
if (ioctl(fbdpy->fd, FBIOGET_VSCREENINFO, &fbdpy->vinfo))
|
||||
return FALSE;
|
||||
|
||||
if (fbdpy->finfo.visual != FB_VISUAL_TRUECOLOR ||
|
||||
fbdpy->finfo.type != FB_TYPE_PACKED_PIXELS)
|
||||
return FALSE;
|
||||
|
||||
if (!fbdev_display_init_configs(&fbdpy->base) ||
|
||||
!fbdev_display_init_connectors(&fbdpy->base) ||
|
||||
!fbdev_display_init_modes(&fbdpy->base))
|
||||
return FALSE;
|
||||
|
||||
ws = fbdev_create_sw_winsys(fbdpy->fd, fbdpy->config.color_format);
|
||||
if (ws) {
|
||||
fbdpy->base.screen =
|
||||
fbdpy->event_handler->new_sw_screen(&fbdpy->base, ws);
|
||||
if (!ws)
|
||||
return FALSE;
|
||||
|
||||
fbdpy->base.screen = fbdpy->event_handler->new_sw_screen(&fbdpy->base, ws);
|
||||
if (!fbdpy->base.screen) {
|
||||
if (ws->destroy)
|
||||
ws->destroy(ws);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (fbdpy->base.screen) {
|
||||
if (!fbdpy->base.screen->is_format_supported(fbdpy->base.screen,
|
||||
fbdpy->config.color_format, PIPE_TEXTURE_2D, 0,
|
||||
PIPE_BIND_RENDER_TARGET)) {
|
||||
fbdpy->base.screen->destroy(fbdpy->base.screen);
|
||||
fbdpy->base.screen = NULL;
|
||||
}
|
||||
if (!fbdpy->base.screen->is_format_supported(fbdpy->base.screen,
|
||||
fbdpy->config.color_format, PIPE_TEXTURE_2D, 0,
|
||||
PIPE_BIND_RENDER_TARGET)) {
|
||||
fbdpy->base.screen->destroy(fbdpy->base.screen);
|
||||
fbdpy->base.screen = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return (fbdpy->base.screen != NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static struct native_display *
|
||||
fbdev_display_create(int fd, struct native_event_handler *event_handler,
|
||||
void *user_data)
|
||||
fbdev_display_create(int fd, const struct native_event_handler *event_handler)
|
||||
{
|
||||
struct fbdev_display *fbdpy;
|
||||
|
||||
|
|
@ -443,13 +431,23 @@ fbdev_display_create(int fd, struct native_event_handler *event_handler,
|
|||
|
||||
fbdpy->fd = fd;
|
||||
fbdpy->event_handler = event_handler;
|
||||
fbdpy->base.user_data = user_data;
|
||||
|
||||
if (!fbdev_display_init(&fbdpy->base)) {
|
||||
FREE(fbdpy);
|
||||
return NULL;
|
||||
}
|
||||
if (ioctl(fbdpy->fd, FBIOGET_FSCREENINFO, &fbdpy->finfo))
|
||||
goto fail;
|
||||
|
||||
if (ioctl(fbdpy->fd, FBIOGET_VSCREENINFO, &fbdpy->vinfo))
|
||||
goto fail;
|
||||
|
||||
if (fbdpy->finfo.visual != FB_VISUAL_TRUECOLOR ||
|
||||
fbdpy->finfo.type != FB_TYPE_PACKED_PIXELS)
|
||||
goto fail;
|
||||
|
||||
if (!fbdev_display_init_configs(&fbdpy->base) ||
|
||||
!fbdev_display_init_connectors(&fbdpy->base) ||
|
||||
!fbdev_display_init_modes(&fbdpy->base))
|
||||
goto fail;
|
||||
|
||||
fbdpy->base.init_screen = fbdev_display_init_screen;
|
||||
fbdpy->base.destroy = fbdev_display_destroy;
|
||||
fbdpy->base.get_param = fbdev_display_get_param;
|
||||
fbdpy->base.get_configs = fbdev_display_get_configs;
|
||||
|
|
@ -457,18 +455,16 @@ fbdev_display_create(int fd, struct native_event_handler *event_handler,
|
|||
fbdpy->base.modeset = &fbdev_display_modeset;
|
||||
|
||||
return &fbdpy->base;
|
||||
|
||||
fail:
|
||||
FREE(fbdpy);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct native_event_handler *fbdev_event_handler;
|
||||
|
||||
static void
|
||||
native_set_event_handler(struct native_event_handler *event_handler)
|
||||
{
|
||||
fbdev_event_handler = event_handler;
|
||||
}
|
||||
static const struct native_event_handler *fbdev_event_handler;
|
||||
|
||||
static struct native_display *
|
||||
native_create_display(void *dpy, boolean use_sw, void *user_data)
|
||||
native_create_display(void *dpy, boolean use_sw)
|
||||
{
|
||||
struct native_display *ndpy;
|
||||
int fd;
|
||||
|
|
@ -483,7 +479,7 @@ native_create_display(void *dpy, boolean use_sw, void *user_data)
|
|||
if (fd < 0)
|
||||
return NULL;
|
||||
|
||||
ndpy = fbdev_display_create(fd, fbdev_event_handler, user_data);
|
||||
ndpy = fbdev_display_create(fd, fbdev_event_handler);
|
||||
if (!ndpy)
|
||||
close(fd);
|
||||
|
||||
|
|
@ -492,12 +488,12 @@ native_create_display(void *dpy, boolean use_sw, void *user_data)
|
|||
|
||||
static const struct native_platform fbdev_platform = {
|
||||
"FBDEV", /* name */
|
||||
native_set_event_handler,
|
||||
native_create_display
|
||||
};
|
||||
|
||||
const struct native_platform *
|
||||
native_get_fbdev_platform(void)
|
||||
native_get_fbdev_platform(const struct native_event_handler *event_handler)
|
||||
{
|
||||
fbdev_event_handler = event_handler;
|
||||
return &fbdev_platform;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ struct gdi_display {
|
|||
struct native_display base;
|
||||
|
||||
HDC hDC;
|
||||
struct native_event_handler *event_handler;
|
||||
const struct native_event_handler *event_handler;
|
||||
|
||||
struct native_config *configs;
|
||||
int num_configs;
|
||||
|
|
@ -368,12 +368,30 @@ gdi_display_destroy(struct native_display *ndpy)
|
|||
FREE(gdpy);
|
||||
}
|
||||
|
||||
static boolean
|
||||
gdi_display_init_screen(struct native_display *ndpy)
|
||||
{
|
||||
struct gdi_display *gdpy = gdi_display(ndpy);
|
||||
struct sw_winsys *winsys;
|
||||
|
||||
winsys = gdi_create_sw_winsys();
|
||||
if (!winsys)
|
||||
return FALSE;
|
||||
|
||||
gdpy->base.screen = gdpy->event_handler->new_sw_screen(&gdpy->base, winsys);
|
||||
if (!gdpy->base.screen) {
|
||||
if (winsys->destroy)
|
||||
winsys->destroy(winsys);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static struct native_display *
|
||||
gdi_create_display(HDC hDC, struct native_event_handler *event_handler,
|
||||
void *user_data)
|
||||
gdi_create_display(HDC hDC, const struct native_event_handler *event_handler)
|
||||
{
|
||||
struct gdi_display *gdpy;
|
||||
struct sw_winsys *winsys;
|
||||
|
||||
gdpy = CALLOC_STRUCT(gdi_display);
|
||||
if (!gdpy)
|
||||
|
|
@ -381,22 +399,8 @@ gdi_create_display(HDC hDC, struct native_event_handler *event_handler,
|
|||
|
||||
gdpy->hDC = hDC;
|
||||
gdpy->event_handler = event_handler;
|
||||
gdpy->base.user_data = user_data;
|
||||
|
||||
winsys = gdi_create_sw_winsys();
|
||||
if (!winsys) {
|
||||
FREE(gdpy);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gdpy->base.screen = gdpy->event_handler->new_sw_screen(&gdpy->base, winsys);
|
||||
if (!gdpy->base.screen) {
|
||||
if (winsys->destroy)
|
||||
winsys->destroy(winsys);
|
||||
FREE(gdpy);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gdpy->base.init_screen = gdi_display_init_screen;
|
||||
gdpy->base.destroy = gdi_display_destroy;
|
||||
gdpy->base.get_param = gdi_display_get_param;
|
||||
|
||||
|
|
@ -406,28 +410,22 @@ gdi_create_display(HDC hDC, struct native_event_handler *event_handler,
|
|||
return &gdpy->base;
|
||||
}
|
||||
|
||||
static struct native_event_handler *gdi_event_handler;
|
||||
|
||||
static void
|
||||
native_set_event_handler(struct native_event_handler *event_handler)
|
||||
{
|
||||
gdi_event_handler = event_handler;
|
||||
}
|
||||
static const struct native_event_handler *gdi_event_handler;
|
||||
|
||||
static struct native_display *
|
||||
native_create_display(void *dpy, boolean use_sw, void *user_data)
|
||||
native_create_display(void *dpy, boolean use_sw)
|
||||
{
|
||||
return gdi_create_display((HDC) dpy, gdi_event_handler, user_data);
|
||||
return gdi_create_display((HDC) dpy, gdi_event_handler);
|
||||
}
|
||||
|
||||
static const struct native_platform gdi_platform = {
|
||||
"GDI", /* name */
|
||||
native_set_event_handler,
|
||||
native_create_display
|
||||
};
|
||||
|
||||
const struct native_platform *
|
||||
native_get_gdi_platform(void)
|
||||
native_get_gdi_platform(const struct native_event_handler *event_handler)
|
||||
{
|
||||
gdi_event_handler = event_handler;
|
||||
return &gdi_platform;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@
|
|||
struct wayland_drm_display {
|
||||
struct wayland_display base;
|
||||
|
||||
struct native_event_handler *event_handler;
|
||||
const struct native_event_handler *event_handler;
|
||||
|
||||
struct wl_drm *wl_drm;
|
||||
struct wl_drm *wl_server_drm; /* for EGL_WL_bind_wayland_display */
|
||||
|
|
@ -285,8 +285,7 @@ static struct native_display_wayland_bufmgr wayland_drm_display_wayland_bufmgr =
|
|||
|
||||
struct wayland_display *
|
||||
wayland_create_drm_display(struct wl_display *dpy,
|
||||
struct native_event_handler *event_handler,
|
||||
void *user_data)
|
||||
const struct native_event_handler *event_handler)
|
||||
{
|
||||
struct wayland_drm_display *drmdpy;
|
||||
|
||||
|
|
@ -295,7 +294,6 @@ wayland_create_drm_display(struct wl_display *dpy,
|
|||
return NULL;
|
||||
|
||||
drmdpy->event_handler = event_handler;
|
||||
drmdpy->base.base.user_data = user_data;
|
||||
|
||||
drmdpy->base.dpy = dpy;
|
||||
if (!drmdpy->base.dpy) {
|
||||
|
|
@ -303,10 +301,7 @@ wayland_create_drm_display(struct wl_display *dpy,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (!wayland_drm_display_init_screen(&drmdpy->base.base)) {
|
||||
wayland_drm_display_destroy(&drmdpy->base.base);
|
||||
return NULL;
|
||||
}
|
||||
drmdpy->base.base.init_screen = wayland_drm_display_init_screen;
|
||||
drmdpy->base.base.destroy = wayland_drm_display_destroy;
|
||||
drmdpy->base.base.buffer = &wayland_drm_display_buffer;
|
||||
drmdpy->base.base.wayland_bufmgr = &wayland_drm_display_wayland_bufmgr;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
struct wayland_shm_display {
|
||||
struct wayland_display base;
|
||||
|
||||
struct native_event_handler *event_handler;
|
||||
const struct native_event_handler *event_handler;
|
||||
struct wl_shm *wl_shm;
|
||||
};
|
||||
|
||||
|
|
@ -144,8 +144,7 @@ wayland_shm_display_init_screen(struct native_display *ndpy)
|
|||
|
||||
struct wayland_display *
|
||||
wayland_create_shm_display(struct wl_display *dpy,
|
||||
struct native_event_handler *event_handler,
|
||||
void *user_data)
|
||||
const struct native_event_handler *event_handler)
|
||||
{
|
||||
struct wayland_shm_display *shmdpy;
|
||||
|
||||
|
|
@ -154,7 +153,6 @@ wayland_create_shm_display(struct wl_display *dpy,
|
|||
return NULL;
|
||||
|
||||
shmdpy->event_handler = event_handler;
|
||||
shmdpy->base.base.user_data = user_data;
|
||||
|
||||
shmdpy->base.dpy = dpy;
|
||||
if (!shmdpy->base.dpy) {
|
||||
|
|
@ -162,11 +160,7 @@ wayland_create_shm_display(struct wl_display *dpy,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (!wayland_shm_display_init_screen(&shmdpy->base.base)) {
|
||||
wayland_shm_display_destroy(&shmdpy->base.base);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
shmdpy->base.base.init_screen = wayland_shm_display_init_screen;
|
||||
shmdpy->base.base.destroy = wayland_shm_display_destroy;
|
||||
shmdpy->base.create_buffer = wayland_create_shm_buffer;
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
#include "native_wayland.h"
|
||||
|
||||
static struct native_event_handler *wayland_event_handler;
|
||||
static const struct native_event_handler *wayland_event_handler;
|
||||
|
||||
static void
|
||||
sync_callback(void *data)
|
||||
|
|
@ -447,14 +447,8 @@ wayland_create_window_surface(struct native_display *ndpy,
|
|||
return &surface->base;
|
||||
}
|
||||
|
||||
static void
|
||||
native_set_event_handler(struct native_event_handler *event_handler)
|
||||
{
|
||||
wayland_event_handler = event_handler;
|
||||
}
|
||||
|
||||
static struct native_display *
|
||||
native_create_display(void *dpy, boolean use_sw, void *user_data)
|
||||
native_create_display(void *dpy, boolean use_sw)
|
||||
{
|
||||
struct wayland_display *display = NULL;
|
||||
boolean own_dpy = FALSE;
|
||||
|
|
@ -471,12 +465,10 @@ native_create_display(void *dpy, boolean use_sw, void *user_data)
|
|||
if (use_sw) {
|
||||
_eglLog(_EGL_INFO, "use software fallback");
|
||||
display = wayland_create_shm_display((struct wl_display *) dpy,
|
||||
wayland_event_handler,
|
||||
user_data);
|
||||
wayland_event_handler);
|
||||
} else {
|
||||
display = wayland_create_drm_display((struct wl_display *) dpy,
|
||||
wayland_event_handler,
|
||||
user_data);
|
||||
wayland_event_handler);
|
||||
}
|
||||
|
||||
if (!display)
|
||||
|
|
@ -495,13 +487,13 @@ native_create_display(void *dpy, boolean use_sw, void *user_data)
|
|||
|
||||
static const struct native_platform wayland_platform = {
|
||||
"wayland", /* name */
|
||||
native_set_event_handler,
|
||||
native_create_display
|
||||
};
|
||||
|
||||
const struct native_platform *
|
||||
native_get_wayland_platform(void)
|
||||
native_get_wayland_platform(const struct native_event_handler *event_handler)
|
||||
{
|
||||
wayland_event_handler = event_handler;
|
||||
return &wayland_platform;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,11 +103,10 @@ wayland_config(const struct native_config *nconf)
|
|||
|
||||
struct wayland_display *
|
||||
wayland_create_shm_display(struct wl_display *display,
|
||||
struct native_event_handler *event_handler,
|
||||
void *user_data);
|
||||
const struct native_event_handler *event_handler);
|
||||
|
||||
struct wayland_display *
|
||||
wayland_create_drm_display(struct wl_display *display,
|
||||
struct native_event_handler *event_handler,
|
||||
void *user_data);
|
||||
const struct native_event_handler *event_handler);
|
||||
|
||||
#endif /* _NATIVE_WAYLAND_H_ */
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ struct dri2_display {
|
|||
Display *dpy;
|
||||
boolean own_dpy;
|
||||
|
||||
struct native_event_handler *event_handler;
|
||||
const struct native_event_handler *event_handler;
|
||||
|
||||
struct x11_screen *xscr;
|
||||
int xscr_number;
|
||||
|
|
@ -870,8 +870,7 @@ static struct native_display_wayland_bufmgr dri2_display_wayland_bufmgr = {
|
|||
|
||||
struct native_display *
|
||||
x11_create_dri2_display(Display *dpy,
|
||||
struct native_event_handler *event_handler,
|
||||
void *user_data)
|
||||
const struct native_event_handler *event_handler)
|
||||
{
|
||||
struct dri2_display *dri2dpy;
|
||||
|
||||
|
|
@ -880,7 +879,6 @@ x11_create_dri2_display(Display *dpy,
|
|||
return NULL;
|
||||
|
||||
dri2dpy->event_handler = event_handler;
|
||||
dri2dpy->base.user_data = user_data;
|
||||
|
||||
dri2dpy->dpy = dpy;
|
||||
if (!dri2dpy->dpy) {
|
||||
|
|
@ -899,11 +897,6 @@ x11_create_dri2_display(Display *dpy,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (!dri2_display_init_screen(&dri2dpy->base)) {
|
||||
dri2_display_destroy(&dri2dpy->base);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dri2dpy->surfaces = util_hash_table_create(dri2_display_hash_table_hash,
|
||||
dri2_display_hash_table_compare);
|
||||
if (!dri2dpy->surfaces) {
|
||||
|
|
@ -911,6 +904,7 @@ x11_create_dri2_display(Display *dpy,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
dri2dpy->base.init_screen = dri2_display_init_screen;
|
||||
dri2dpy->base.destroy = dri2_display_destroy;
|
||||
dri2dpy->base.get_param = dri2_display_get_param;
|
||||
dri2dpy->base.get_configs = dri2_display_get_configs;
|
||||
|
|
|
|||
|
|
@ -30,16 +30,10 @@
|
|||
|
||||
#include "native_x11.h"
|
||||
|
||||
static struct native_event_handler *x11_event_handler;
|
||||
|
||||
static void
|
||||
native_set_event_handler(struct native_event_handler *event_handler)
|
||||
{
|
||||
x11_event_handler = event_handler;
|
||||
}
|
||||
static const struct native_event_handler *x11_event_handler;
|
||||
|
||||
static struct native_display *
|
||||
native_create_display(void *dpy, boolean use_sw, void *user_data)
|
||||
native_create_display(void *dpy, boolean use_sw)
|
||||
{
|
||||
struct native_display *ndpy = NULL;
|
||||
boolean force_sw;
|
||||
|
|
@ -48,12 +42,10 @@ native_create_display(void *dpy, boolean use_sw, void *user_data)
|
|||
|
||||
if (force_sw || use_sw) {
|
||||
_eglLog(_EGL_INFO, "use software fallback");
|
||||
ndpy = x11_create_ximage_display((Display *) dpy,
|
||||
x11_event_handler, user_data);
|
||||
ndpy = x11_create_ximage_display((Display *) dpy, x11_event_handler);
|
||||
}
|
||||
else {
|
||||
ndpy = x11_create_dri2_display((Display *) dpy,
|
||||
x11_event_handler, user_data);
|
||||
ndpy = x11_create_dri2_display((Display *) dpy, x11_event_handler);
|
||||
}
|
||||
|
||||
return ndpy;
|
||||
|
|
@ -61,12 +53,12 @@ native_create_display(void *dpy, boolean use_sw, void *user_data)
|
|||
|
||||
static const struct native_platform x11_platform = {
|
||||
"X11", /* name */
|
||||
native_set_event_handler,
|
||||
native_create_display
|
||||
};
|
||||
|
||||
const struct native_platform *
|
||||
native_get_x11_platform(void)
|
||||
native_get_x11_platform(const struct native_event_handler *event_handler)
|
||||
{
|
||||
x11_event_handler = event_handler;
|
||||
return &x11_platform;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,12 +31,10 @@
|
|||
|
||||
struct native_display *
|
||||
x11_create_ximage_display(Display *dpy,
|
||||
struct native_event_handler *event_handler,
|
||||
void *user_data);
|
||||
const struct native_event_handler *event_handler);
|
||||
|
||||
struct native_display *
|
||||
x11_create_dri2_display(Display *dpy,
|
||||
struct native_event_handler *event_handler,
|
||||
void *user_data);
|
||||
const struct native_event_handler *event_handler);
|
||||
|
||||
#endif /* _NATIVE_X11_H_ */
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ struct ximage_display {
|
|||
Display *dpy;
|
||||
boolean own_dpy;
|
||||
|
||||
struct native_event_handler *event_handler;
|
||||
const struct native_event_handler *event_handler;
|
||||
|
||||
struct x11_screen *xscr;
|
||||
int xscr_number;
|
||||
|
|
@ -484,13 +484,32 @@ ximage_display_destroy(struct native_display *ndpy)
|
|||
FREE(xdpy);
|
||||
}
|
||||
|
||||
static boolean
|
||||
ximage_display_init_screen(struct native_display *ndpy)
|
||||
{
|
||||
struct ximage_display *xdpy = ximage_display(ndpy);
|
||||
struct sw_winsys *winsys;
|
||||
|
||||
winsys = xlib_create_sw_winsys(xdpy->dpy);
|
||||
if (!winsys)
|
||||
return FALSE;
|
||||
|
||||
xdpy->base.screen =
|
||||
xdpy->event_handler->new_sw_screen(&xdpy->base, winsys);
|
||||
if (!xdpy->base.screen) {
|
||||
if (winsys->destroy)
|
||||
winsys->destroy(winsys);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
struct native_display *
|
||||
x11_create_ximage_display(Display *dpy,
|
||||
struct native_event_handler *event_handler,
|
||||
void *user_data)
|
||||
const struct native_event_handler *event_handler)
|
||||
{
|
||||
struct ximage_display *xdpy;
|
||||
struct sw_winsys *winsys = NULL;
|
||||
|
||||
xdpy = CALLOC_STRUCT(ximage_display);
|
||||
if (!xdpy)
|
||||
|
|
@ -507,22 +526,17 @@ x11_create_ximage_display(Display *dpy,
|
|||
}
|
||||
|
||||
xdpy->event_handler = event_handler;
|
||||
xdpy->base.user_data = user_data;
|
||||
|
||||
xdpy->xscr_number = DefaultScreen(xdpy->dpy);
|
||||
xdpy->xscr = x11_screen_create(xdpy->dpy, xdpy->xscr_number);
|
||||
if (!xdpy->xscr)
|
||||
goto fail;
|
||||
|
||||
winsys = xlib_create_sw_winsys(xdpy->dpy);
|
||||
if (!winsys)
|
||||
goto fail;
|
||||
|
||||
xdpy->base.screen =
|
||||
xdpy->event_handler->new_sw_screen(&xdpy->base, winsys);
|
||||
if (!xdpy->base.screen)
|
||||
goto fail;
|
||||
if (!xdpy->xscr) {
|
||||
if (xdpy->own_dpy)
|
||||
XCloseDisplay(xdpy->dpy);
|
||||
FREE(xdpy);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
xdpy->base.init_screen = ximage_display_init_screen;
|
||||
xdpy->base.destroy = ximage_display_destroy;
|
||||
xdpy->base.get_param = ximage_display_get_param;
|
||||
|
||||
|
|
@ -532,14 +546,4 @@ x11_create_ximage_display(Display *dpy,
|
|||
xdpy->base.create_pixmap_surface = ximage_display_create_pixmap_surface;
|
||||
|
||||
return &xdpy->base;
|
||||
|
||||
fail:
|
||||
if (winsys && winsys->destroy)
|
||||
winsys->destroy(winsys);
|
||||
if (xdpy->xscr)
|
||||
x11_screen_destroy(xdpy->xscr);
|
||||
if (xdpy->dpy && xdpy->own_dpy)
|
||||
XCloseDisplay(xdpy->dpy);
|
||||
FREE(xdpy);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue