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 <tapani.palli@intel.com> Reviewed-by: Eric Engestrom <eric.engestrom@intel.com> Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
This commit is contained in:
parent
9520e7c1e9
commit
04ecda3b3c
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue