diff options
author | Chad Versace <[email protected]> | 2014-01-28 11:41:46 -0800 |
---|---|---|
committer | Chad Versace <[email protected]> | 2014-03-17 15:36:03 -0700 |
commit | 90502b18b2b868250ab7e9189810ca42b3c812a1 (patch) | |
tree | d8c18fecf90bdf2665c1cb6e1d14e3e2a81aea0a /src/egl/drivers/dri2 | |
parent | 38848b6217377064665e28441648352c2688edf3 (diff) |
egl/dri2: Move dri2_egl_display virtual funcs to vtbl
dri2_egl_display has only one virtual function, 'authenticate'. Define
dri2_egl_display::vtbl and move 'authenticate' there.
This prepares for the EGL platform extensions, which will add many
more virtual functions to dri2_egl_display.
Reviewed-by: Ian Romanick <[email protected]>
Signed-off-by: Chad Versace <[email protected]>
Diffstat (limited to 'src/egl/drivers/dri2')
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2.c | 2 | ||||
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2.h | 8 | ||||
-rw-r--r-- | src/egl/drivers/dri2/platform_android.c | 9 | ||||
-rw-r--r-- | src/egl/drivers/dri2/platform_drm.c | 10 | ||||
-rw-r--r-- | src/egl/drivers/dri2/platform_wayland.c | 10 | ||||
-rw-r--r-- | src/egl/drivers/dri2/platform_x11.c | 20 |
6 files changed, 52 insertions, 7 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index f304075b520..7e5fdc0f9a9 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -1880,7 +1880,7 @@ dri2_bind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp, return EGL_FALSE; wl_drm_callbacks.authenticate = - (int(*)(void *, uint32_t)) dri2_dpy->authenticate; + (int(*)(void *, uint32_t)) dri2_dpy->vtbl->authenticate; ret = drmGetCap(dri2_dpy->fd, DRM_CAP_PRIME, &cap); if (ret == 0 && cap == (DRM_PRIME_CAP_IMPORT | DRM_PRIME_CAP_EXPORT) && diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h index dfc5927e3d8..4da0c5b3466 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h @@ -84,8 +84,14 @@ struct dri2_egl_driver void (*glFlush)(void); }; +struct dri2_egl_display_vtbl { + int (*authenticate)(_EGLDisplay *disp, uint32_t id); +}; + struct dri2_egl_display { + const struct dri2_egl_display_vtbl *vtbl; + int dri2_major; int dri2_minor; __DRIscreen *dri_screen; @@ -134,8 +140,6 @@ struct dri2_egl_display int formats; uint32_t capabilities; #endif - - int (*authenticate) (_EGLDisplay *disp, uint32_t id); }; struct dri2_egl_context diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c index cc19a611349..3a8f6bbe8d7 100644 --- a/src/egl/drivers/dri2/platform_android.c +++ b/src/egl/drivers/dri2/platform_android.c @@ -652,6 +652,10 @@ droid_log(EGLint level, const char *msg) } } +static struct dri2_egl_display_vtbl droid_display_vtbl = { + .authenticate = NULL, +}; + EGLBoolean dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *dpy) { @@ -716,6 +720,11 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *dpy) droid_init_driver_functions(drv); + /* Fill vtbl last to prevent accidentally calling virtual function during + * initialization. + */ + dri2_dpy->vtbl = &droid_display_vtbl; + return EGL_TRUE; cleanup_screen: diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c index a2b387d1b35..c082df775c9 100644 --- a/src/egl/drivers/dri2/platform_drm.c +++ b/src/egl/drivers/dri2/platform_drm.c @@ -440,6 +440,10 @@ dri2_drm_authenticate(_EGLDisplay *disp, uint32_t id) return drmAuthMagic(dri2_dpy->fd, id); } +static struct dri2_egl_display_vtbl dri2_drm_display_vtbl = { + .authenticate = dri2_drm_authenticate, +}; + EGLBoolean dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp) { @@ -543,11 +547,15 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp) #ifdef HAVE_WAYLAND_PLATFORM disp->Extensions.WL_bind_wayland_display = EGL_TRUE; #endif - dri2_dpy->authenticate = dri2_drm_authenticate; /* we're supporting EGL 1.4 */ disp->VersionMajor = 1; disp->VersionMinor = 4; + /* Fill vtbl last to prevent accidentally calling virtual function during + * initialization. + */ + dri2_dpy->vtbl = &dri2_drm_display_vtbl; + return EGL_TRUE; } diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c index a9c067f906b..d56630c4072 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -952,6 +952,10 @@ dri2_setup_swap_interval(struct dri2_egl_display *dri2_dpy) } } +static struct dri2_egl_display_vtbl dri2_wl_display_vtbl = { + .authenticate = dri2_wayland_authenticate, +}; + EGLBoolean dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp) { @@ -1062,7 +1066,6 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp) disp->Extensions.WL_bind_wayland_display = EGL_TRUE; disp->Extensions.WL_create_wayland_buffer_from_image = EGL_TRUE; disp->Extensions.EXT_buffer_age = EGL_TRUE; - dri2_dpy->authenticate = dri2_wayland_authenticate; disp->Extensions.EXT_swap_buffers_with_damage = EGL_TRUE; @@ -1070,6 +1073,11 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp) disp->VersionMajor = 1; disp->VersionMinor = 4; + /* Fill vtbl last to prevent accidentally calling virtual function during + * initialization. + */ + dri2_dpy->vtbl = &dri2_wl_display_vtbl; + return EGL_TRUE; cleanup_driver: diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c index d878b772d82..b5df0f990c8 100644 --- a/src/egl/drivers/dri2/platform_x11.c +++ b/src/egl/drivers/dri2/platform_x11.c @@ -985,6 +985,14 @@ dri2_x11_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp, } } +static struct dri2_egl_display_vtbl dri2_x11_swrast_display_vtbl = { + .authenticate = NULL, +}; + +static struct dri2_egl_display_vtbl dri2_x11_display_vtbl = { + .authenticate = dri2_x11_authenticate, +}; + static EGLBoolean dri2_initialize_x11_swrast(_EGLDriver *drv, _EGLDisplay *disp) { @@ -1044,6 +1052,11 @@ dri2_initialize_x11_swrast(_EGLDriver *drv, _EGLDisplay *disp) disp->VersionMajor = 1; disp->VersionMinor = 4; + /* Fill vtbl last to prevent accidentally calling virtual function during + * initialization. + */ + dri2_dpy->vtbl = &dri2_x11_swrast_display_vtbl; + return EGL_TRUE; cleanup_configs: @@ -1209,12 +1222,15 @@ dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay *disp) goto cleanup_configs; } - dri2_dpy->authenticate = dri2_x11_authenticate; - /* we're supporting EGL 1.4 */ disp->VersionMajor = 1; disp->VersionMinor = 4; + /* Fill vtbl last to prevent accidentally calling virtual function during + * initialization. + */ + dri2_dpy->vtbl = &dri2_x11_display_vtbl; + return EGL_TRUE; cleanup_configs: |