surfaceless: Fix swrast path.
authorEric Anholt <eric@anholt.net>
Tue, 23 Jul 2019 20:18:21 +0000 (13:18 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 13 Aug 2019 17:29:34 +0000 (10:29 -0700)
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>
src/egl/drivers/dri2/egl_dri2.c
src/egl/drivers/dri2/egl_dri2.h
src/egl/drivers/dri2/platform_device.c
src/egl/drivers/dri2/platform_surfaceless.c

index 52babb53ff59f605d19b4c57426ffba8070756c8..8dd1890ee0770d654f1825eed6153d22a39c23ed 100644 (file)
@@ -149,6 +149,29 @@ const __DRIuseInvalidateExtension use_invalidate = {
    .base = { __DRI_USE_INVALIDATE, 1 }
 };
 
    .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,
 static const EGLint dri2_to_egl_attribute_map[__DRI_ATTRIB_MAX] = {
    [__DRI_ATTRIB_BUFFER_SIZE ]          = EGL_BUFFER_SIZE,
    [__DRI_ATTRIB_LEVEL]                 = EGL_LEVEL,
index 43c41bdeba21ff278b5bb35165f6ee50521532d1..bb3352f1b69cf976ce3fccfba156f835c492519d 100644 (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 __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);
 
 EGLBoolean
 dri2_load_driver(_EGLDisplay *disp);
index e7ae3a3aa2a71a5b04004f3a552da825678a2a45..a73ea41539634af0fefea7f0b3c8d79151304e1d 100644 (file)
@@ -248,29 +248,6 @@ static const __DRIimageLoaderExtension image_loader_extension = {
    .flushFrontBuffer = device_flush_front_buffer,
 };
 
    .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,
 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,
 };
 
    NULL,
 };
 
-/* HACK: second part of the hack above. */
 static const __DRIextension *swrast_loader_extensions[] = {
 static const __DRIextension *swrast_loader_extensions[] = {
-   &swrast_loader_extension.base,
+   &swrast_pbuffer_loader_extension.base,
    &image_lookup_extension.base,
    &use_invalidate.base,
    NULL,
    &image_lookup_extension.base,
    &use_invalidate.base,
    NULL,
index 142165807c3f521fb7de8c055b67948e025c296f..210f8188b96baec9aeaeb11f3ad05cc70e777e44 100644 (file)
@@ -242,13 +242,6 @@ static const __DRIimageLoaderExtension image_loader_extension = {
    .flushFrontBuffer = surfaceless_flush_front_buffer,
 };
 
    .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,
 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[] = {
 };
 
 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,
    &image_loader_extension.base,
    &image_lookup_extension.base,
    &use_invalidate.base,