surfaceless: Fix swrast path.

We get a getDrawableInfo() call in the MakeCurrent path, which
platform_device was handling correctly by returning the pbuffer's
width/height but platform_surfaceless segfaulted for.  Reuse
platform_device's implementation.

Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
This commit is contained in:
Eric Anholt 2019-07-23 13:18:21 -07:00
parent 030aa6e184
commit 6a8d39dccd
4 changed files with 26 additions and 33 deletions

View file

@ -149,6 +149,29 @@ const __DRIuseInvalidateExtension use_invalidate = {
.base = { __DRI_USE_INVALIDATE, 1 }
};
static void
dri2_get_pbuffer_drawable_info(__DRIdrawable * draw,
int *x, int *y, int *w, int *h,
void *loaderPrivate)
{
struct dri2_egl_surface *dri2_surf = loaderPrivate;
*x = *y = 0;
*w = dri2_surf->base.Width;
*h = dri2_surf->base.Height;
}
/* HACK: technically we should have swrast_null, instead of these. We
* get away since only pbuffers are supported, thus the callbacks are
* unused.
*/
const __DRIswrastLoaderExtension swrast_pbuffer_loader_extension = {
.base = { __DRI_SWRAST_LOADER, 1 },
.getDrawableInfo = dri2_get_pbuffer_drawable_info,
.putImage = NULL,
.getImage = NULL,
};
static const EGLint dri2_to_egl_attribute_map[__DRI_ATTRIB_MAX] = {
[__DRI_ATTRIB_BUFFER_SIZE ] = EGL_BUFFER_SIZE,
[__DRI_ATTRIB_LEVEL] = EGL_LEVEL,

View file

@ -374,6 +374,7 @@ _EGL_DRIVER_TYPECAST(dri2_egl_sync, _EGLSync, obj)
extern const __DRIimageLookupExtension image_lookup_extension;
extern const __DRIuseInvalidateExtension use_invalidate;
extern const __DRIbackgroundCallableExtension background_callable_extension;
extern const __DRIswrastLoaderExtension swrast_pbuffer_loader_extension;
EGLBoolean
dri2_load_driver(_EGLDisplay *disp);

View file

@ -248,29 +248,6 @@ static const __DRIimageLoaderExtension image_loader_extension = {
.flushFrontBuffer = device_flush_front_buffer,
};
static void
device_get_drawable_info(__DRIdrawable * draw,
int *x, int *y, int *w, int *h,
void *loaderPrivate)
{
struct dri2_egl_surface *dri2_surf = loaderPrivate;
*x = *y = 0;
*w = dri2_surf->base.Width;
*h = dri2_surf->base.Height;
}
/* HACK: technically we should have swrast_null, instead of these. We
* get away since only pbuffers are supported, thus the callbacks are
* unused.
*/
static const __DRIswrastLoaderExtension swrast_loader_extension = {
.base = { __DRI_SWRAST_LOADER, 1 },
.getDrawableInfo = device_get_drawable_info,
.putImage = NULL,
.getImage = NULL,
};
static const __DRIextension *image_loader_extensions[] = {
&image_loader_extension.base,
&image_lookup_extension.base,
@ -278,9 +255,8 @@ static const __DRIextension *image_loader_extensions[] = {
NULL,
};
/* HACK: second part of the hack above. */
static const __DRIextension *swrast_loader_extensions[] = {
&swrast_loader_extension.base,
&swrast_pbuffer_loader_extension.base,
&image_lookup_extension.base,
&use_invalidate.base,
NULL,

View file

@ -242,13 +242,6 @@ static const __DRIimageLoaderExtension image_loader_extension = {
.flushFrontBuffer = surfaceless_flush_front_buffer,
};
static const __DRIswrastLoaderExtension swrast_loader_extension = {
.base = { __DRI_SWRAST_LOADER, 1 },
.getDrawableInfo = NULL,
.putImage = NULL,
.getImage = NULL,
};
static const __DRIextension *image_loader_extensions[] = {
&image_loader_extension.base,
&image_lookup_extension.base,
@ -257,7 +250,7 @@ static const __DRIextension *image_loader_extensions[] = {
};
static const __DRIextension *swrast_loader_extensions[] = {
&swrast_loader_extension.base,
&swrast_pbuffer_loader_extension.base,
&image_loader_extension.base,
&image_lookup_extension.base,
&use_invalidate.base,