diff options
author | Paulo Zanoni <[email protected]> | 2019-05-01 15:42:26 -0700 |
---|---|---|
committer | Eric Engestrom <[email protected]> | 2019-05-14 12:41:14 +0000 |
commit | 04ecda3b3c85b5a3a52f4fa1a3e0f88c17231408 (patch) | |
tree | e0c74a7d73426ea424399e85fd37a863516bf645 /src | |
parent | 9520e7c1e9206f94f73bb143483147e4600122ec (diff) |
egl: store the native surface pointer in struct _egl_surface
Each platform stores this in a different place:
- platform_drm uses dri2_surf->gbm_surf->base
- platform_android uses dri2_surf->window
- platform_wayland uses dri2_surf->wl_win
- platform_x11 uses dri2_surf->drawable
- platform_x11_dri3 uses dri3_surf->loader_drawable.drawable
- haiku doesn't even store it!
We need access to the native surface since the specification asks us
to refuse creating a new surface if there's already an EGLSurface
associated with native_surface.
An alternative to this patch would be to create a new
API.GetNativeWindow callback that each platform would have to
implement. While that's something we can definitely do, I prefer
this approach.
Reviewed-by: Tapani Pälli <[email protected]>
Reviewed-by: Eric Engestrom <[email protected]>
Signed-off-by: Paulo Zanoni <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2.c | 5 | ||||
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2.h | 3 | ||||
-rw-r--r-- | src/egl/drivers/dri2/platform_android.c | 3 | ||||
-rw-r--r-- | src/egl/drivers/dri2/platform_drm.c | 2 | ||||
-rw-r--r-- | src/egl/drivers/dri2/platform_surfaceless.c | 3 | ||||
-rw-r--r-- | src/egl/drivers/dri2/platform_wayland.c | 2 | ||||
-rw-r--r-- | src/egl/drivers/dri2/platform_x11.c | 3 | ||||
-rw-r--r-- | src/egl/drivers/dri2/platform_x11_dri3.c | 3 | ||||
-rw-r--r-- | src/egl/drivers/haiku/egl_haiku.cpp | 2 | ||||
-rw-r--r-- | src/egl/main/eglsurface.c | 5 | ||||
-rw-r--r-- | src/egl/main/eglsurface.h | 5 |
11 files changed, 24 insertions, 12 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index d584bccdebe..09d6315b19e 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -1354,7 +1354,8 @@ dri2_destroy_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx) EGLBoolean dri2_init_surface(_EGLSurface *surf, _EGLDisplay *disp, EGLint type, - _EGLConfig *conf, const EGLint *attrib_list, EGLBoolean enable_out_fence) + _EGLConfig *conf, const EGLint *attrib_list, + EGLBoolean enable_out_fence, void *native_surface) { struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf); struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); @@ -1368,7 +1369,7 @@ dri2_init_surface(_EGLSurface *surf, _EGLDisplay *disp, EGLint type, dri2_surf->enable_out_fence = enable_out_fence; } - return _eglInitSurface(surf, disp, type, conf, attrib_list); + return _eglInitSurface(surf, disp, type, conf, attrib_list, native_surface); } static void diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h index aa143deb867..4918517b572 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h @@ -535,7 +535,8 @@ dri2_egl_surface_free_local_buffers(struct dri2_egl_surface *dri2_surf); EGLBoolean dri2_init_surface(_EGLSurface *surf, _EGLDisplay *disp, EGLint type, - _EGLConfig *conf, const EGLint *attrib_list, EGLBoolean enable_out_fence); + _EGLConfig *conf, const EGLint *attrib_list, + EGLBoolean enable_out_fence, void *native_surface); void dri2_fini_surface(_EGLSurface *surf); diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c index e9ea9e6002b..fece214d939 100644 --- a/src/egl/drivers/dri2/platform_android.c +++ b/src/egl/drivers/dri2/platform_android.c @@ -354,7 +354,8 @@ droid_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, return NULL; } - if (!dri2_init_surface(&dri2_surf->base, disp, type, conf, attrib_list, true)) + if (!dri2_init_surface(&dri2_surf->base, disp, type, conf, attrib_list, + true, native_window)) goto cleanup_surface; if (type == EGL_WINDOW_BIT) { diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c index c1ab1c9b0f6..7d916fe92b7 100644 --- a/src/egl/drivers/dri2/platform_drm.c +++ b/src/egl/drivers/dri2/platform_drm.c @@ -149,7 +149,7 @@ dri2_drm_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp, } if (!dri2_init_surface(&dri2_surf->base, disp, EGL_WINDOW_BIT, conf, - attrib_list, false)) + attrib_list, false, native_surface)) goto cleanup_surf; config = dri2_get_dri_config(dri2_conf, EGL_WINDOW_BIT, diff --git a/src/egl/drivers/dri2/platform_surfaceless.c b/src/egl/drivers/dri2/platform_surfaceless.c index fefb2b449d0..27b1d44ebec 100644 --- a/src/egl/drivers/dri2/platform_surfaceless.c +++ b/src/egl/drivers/dri2/platform_surfaceless.c @@ -124,7 +124,8 @@ dri2_surfaceless_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, return NULL; } - if (!dri2_init_surface(&dri2_surf->base, disp, type, conf, attrib_list, false)) + if (!dri2_init_surface(&dri2_surf->base, disp, type, conf, attrib_list, + false, NULL)) goto cleanup_surface; config = dri2_get_dri_config(dri2_conf, type, diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c index 2a2c8214169..bf4f2530feb 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -287,7 +287,7 @@ dri2_wl_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp, } if (!dri2_init_surface(&dri2_surf->base, disp, EGL_WINDOW_BIT, conf, - attrib_list, false)) + attrib_list, false, native_window)) goto cleanup_surf; config = dri2_get_dri_config(dri2_conf, EGL_WINDOW_BIT, diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c index c8c676d2f00..1d5efc0126d 100644 --- a/src/egl/drivers/dri2/platform_x11.c +++ b/src/egl/drivers/dri2/platform_x11.c @@ -267,7 +267,8 @@ dri2_x11_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, return NULL; } - if (!dri2_init_surface(&dri2_surf->base, disp, type, conf, attrib_list, false)) + if (!dri2_init_surface(&dri2_surf->base, disp, type, conf, attrib_list, + false, native_surface)) goto cleanup_surf; dri2_surf->region = XCB_NONE; diff --git a/src/egl/drivers/dri2/platform_x11_dri3.c b/src/egl/drivers/dri2/platform_x11_dri3.c index 189212745ce..adcc884c5c2 100644 --- a/src/egl/drivers/dri2/platform_x11_dri3.c +++ b/src/egl/drivers/dri2/platform_x11_dri3.c @@ -155,7 +155,8 @@ dri3_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, return NULL; } - if (!dri2_init_surface(&dri3_surf->surf.base, disp, type, conf, attrib_list, false)) + if (!dri2_init_surface(&dri3_surf->surf.base, disp, type, conf, + attrib_list, false, native_surface)) goto cleanup_surf; if (type == EGL_PBUFFER_BIT) { diff --git a/src/egl/drivers/haiku/egl_haiku.cpp b/src/egl/drivers/haiku/egl_haiku.cpp index 517c264088a..6edd551b53d 100644 --- a/src/egl/drivers/haiku/egl_haiku.cpp +++ b/src/egl/drivers/haiku/egl_haiku.cpp @@ -89,7 +89,7 @@ haiku_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp, } if (!_eglInitSurface(&surface->surf, disp, EGL_WINDOW_BIT, - conf, attrib_list)) { + conf, attrib_list, native_window)) { free(surface); return NULL; } diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 7d96514f775..22257391d5c 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -334,7 +334,8 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list) */ EGLBoolean _eglInitSurface(_EGLSurface *surf, _EGLDisplay *disp, EGLint type, - _EGLConfig *conf, const EGLint *attrib_list) + _EGLConfig *conf, const EGLint *attrib_list, + void *native_surface) { const char *func; EGLint renderBuffer = EGL_BACK_BUFFER; @@ -421,6 +422,8 @@ _eglInitSurface(_EGLSurface *surf, _EGLDisplay *disp, EGLint type, surf->Height = MIN2(surf->Height, _EGL_MAX_PBUFFER_HEIGHT); } + surf->NativeSurface = native_surface; + return EGL_TRUE; } diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h index df8e2e6bdfb..903957a6eb3 100644 --- a/src/egl/main/eglsurface.h +++ b/src/egl/main/eglsurface.h @@ -170,12 +170,15 @@ struct _egl_surface EGLBoolean PostSubBufferSupportedNV; struct _egl_hdr_metadata HdrMetadata; + + void *NativeSurface; }; extern EGLBoolean _eglInitSurface(_EGLSurface *surf, _EGLDisplay *disp, EGLint type, - _EGLConfig *config, const EGLint *attrib_list); + _EGLConfig *config, const EGLint *attrib_list, + void *native_surface); extern EGLBoolean |