[Mesa-dev] [PATCH 04/11] gbm: Move private pointer from gbm_dri_surface to gbm_surface

Ander Conselvan de Oliveira conselvan2 at gmail.com
Tue Apr 8 13:28:41 PDT 2014


From: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira at intel.com>

This allows the pointer stored in dri2_surf in the EGL platform to be
changed to a generic gbm_surface pointer.
---
 src/egl/drivers/dri2/egl_dri2.h     |  2 +-
 src/egl/drivers/dri2/platform_drm.c | 37 ++++++++++++++++---------------------
 src/gbm/backends/dri/gbm_dri.c      |  8 ++++----
 src/gbm/backends/dri/gbm_driint.h   |  2 --
 src/gbm/main/gbmint.h               |  2 ++
 5 files changed, 23 insertions(+), 28 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index e62e265..990b246 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -235,7 +235,7 @@ struct dri2_egl_surface
 #endif
 
 #ifdef HAVE_DRM_PLATFORM
-   struct gbm_dri_surface *gbm_surf;
+   struct gbm_surface *gbm_surface;
 #endif
 
 #if defined(HAVE_WAYLAND_PLATFORM) || defined(HAVE_DRM_PLATFORM)
diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
index 9a7633a..70b26ea 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -40,10 +40,9 @@
 #include "loader.h"
 
 static struct gbm_bo *
-lock_front_buffer(struct gbm_surface *_surf)
+lock_front_buffer(struct gbm_surface *surf)
 {
-   struct gbm_dri_surface *surf = (struct gbm_dri_surface *) _surf;
-   struct dri2_egl_surface *dri2_surf = surf->dri_private;
+   struct dri2_egl_surface *dri2_surf = surf->priv;
    struct gbm_bo *bo;
 
    if (dri2_surf->current == NULL) {
@@ -59,10 +58,9 @@ lock_front_buffer(struct gbm_surface *_surf)
 }
 
 static void
-release_buffer(struct gbm_surface *_surf, struct gbm_bo *bo)
+release_buffer(struct gbm_surface *surf, struct gbm_bo *bo)
 {
-   struct gbm_dri_surface *surf = (struct gbm_dri_surface *) _surf;
-   struct dri2_egl_surface *dri2_surf = surf->dri_private;
+   struct dri2_egl_surface *dri2_surf = surf->priv;
    int i;
 
    for (i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
@@ -73,10 +71,9 @@ release_buffer(struct gbm_surface *_surf, struct gbm_bo *bo)
 }
 
 static int
-has_free_buffers(struct gbm_surface *_surf)
+has_free_buffers(struct gbm_surface *surf)
 {
-   struct gbm_dri_surface *surf = (struct gbm_dri_surface *) _surf;
-   struct dri2_egl_surface *dri2_surf = surf->dri_private;
+   struct dri2_egl_surface *dri2_surf = surf->priv;
    int i;
 
    for (i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++)
@@ -94,8 +91,7 @@ dri2_drm_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
    struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
    struct dri2_egl_config *dri2_conf = dri2_egl_config(conf);
    struct dri2_egl_surface *dri2_surf;
-   struct gbm_surface *window = native_window;
-   struct gbm_dri_surface *surf;
+   struct gbm_surface *surf = native_window;
 
    (void) drv;
 
@@ -110,13 +106,12 @@ dri2_drm_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
 
    switch (type) {
    case EGL_WINDOW_BIT:
-      if (!window)
+      if (!surf)
          return NULL;
-      surf = gbm_dri_surface(window);
-      dri2_surf->gbm_surf = surf;
-      dri2_surf->base.Width =  surf->base.width;
-      dri2_surf->base.Height = surf->base.height;
-      surf->dri_private = dri2_surf;
+      dri2_surf->gbm_surface = surf;
+      dri2_surf->base.Width =  surf->width;
+      dri2_surf->base.Height = surf->height;
+      surf->priv = dri2_surf;
       break;
    default:
       goto cleanup_surf;
@@ -125,7 +120,7 @@ dri2_drm_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
    dri2_surf->dri_drawable =
       (*dri2_dpy->dri2->createNewDrawable) (dri2_dpy->dri_screen,
 					    dri2_conf->dri_double_config,
-					    dri2_surf->gbm_surf);
+					    dri2_surf->gbm_surface);
 
    if (dri2_surf->dri_drawable == NULL) {
       _eglError(EGL_BAD_ALLOC, "dri2->createNewDrawable");
@@ -197,7 +192,7 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
 {
    struct dri2_egl_display *dri2_dpy =
       dri2_egl_display(dri2_surf->base.Resource.Display);
-   struct gbm_dri_surface *surf = dri2_surf->gbm_surf;
+   struct gbm_surface *surf = dri2_surf->gbm_surface;
    int i;
 
    if (dri2_surf->back == NULL) {
@@ -213,8 +208,8 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
       return -1;
    if (dri2_surf->back->bo == NULL)
       dri2_surf->back->bo = gbm_bo_create(&dri2_dpy->gbm_dri->base.base,
-					  surf->base.width, surf->base.height,
-					  surf->base.format, surf->base.flags);
+					  surf->width, surf->height,
+					  surf->format, surf->flags);
    if (dri2_surf->back->bo == NULL)
       return -1;
 
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index 9d08a97..cbb4c8c 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -76,7 +76,7 @@ dri_get_buffers(__DRIdrawable * driDrawable,
       return NULL;
 
    return dri->get_buffers(driDrawable, width, height, attachments,
-                           count, out_count, surf->dri_private);
+                           count, out_count, surf->base.priv);
 }
 
 static void
@@ -86,7 +86,7 @@ dri_flush_front_buffer(__DRIdrawable * driDrawable, void *data)
    struct gbm_dri_device *dri = gbm_dri_device(surf->base.gbm);
 
    if (dri->flush_front_buffer != NULL)
-      dri->flush_front_buffer(driDrawable, surf->dri_private);
+      dri->flush_front_buffer(driDrawable, surf->base.priv);
 }
 
 static __DRIbuffer *
@@ -103,7 +103,7 @@ dri_get_buffers_with_format(__DRIdrawable * driDrawable,
 
    return
       dri->get_buffers_with_format(driDrawable, width, height, attachments,
-                                   count, out_count, surf->dri_private);
+                                   count, out_count, surf->base.priv);
 }
 
 static int
@@ -121,7 +121,7 @@ image_get_buffers(__DRIdrawable *driDrawable,
       return 0;
 
    return dri->image_get_buffers(driDrawable, format, stamp,
-                                 surf->dri_private, buffer_mask, buffers);
+                                 surf->base.priv, buffer_mask, buffers);
 }
 
 static const __DRIuseInvalidateExtension use_invalidate = {
diff --git a/src/gbm/backends/dri/gbm_driint.h b/src/gbm/backends/dri/gbm_driint.h
index fdf694d..9ea2046 100644
--- a/src/gbm/backends/dri/gbm_driint.h
+++ b/src/gbm/backends/dri/gbm_driint.h
@@ -88,8 +88,6 @@ struct gbm_dri_bo {
 
 struct gbm_dri_surface {
    struct gbm_surface base;
-
-   void *dri_private;
 };
 
 static inline struct gbm_dri_device *
diff --git a/src/gbm/main/gbmint.h b/src/gbm/main/gbmint.h
index 31345e6..d7520ad 100644
--- a/src/gbm/main/gbmint.h
+++ b/src/gbm/main/gbmint.h
@@ -104,6 +104,8 @@ struct gbm_surface {
    uint32_t height;
    uint32_t format;
    uint32_t flags;
+
+   void *priv;
 };
 
 struct gbm_backend {
-- 
1.8.3.2



More information about the mesa-dev mailing list