[Mesa-dev] [PATCH v4 1/9] egl: add dri2_surface_fixup() helper (v3)

Gwan-gyeong Mun elongbug at gmail.com
Thu Nov 2 22:10:46 UTC 2017


From: "Mun, Gwan-gyeong" <elongbug at gmail.com>

To share common free outdated buffers and update size code.
This compares width and height arguments with current egl surface dimension,
if the compared surface dimension is differ, then it free local buffers and
updates dimension.

In preparation to adding of new platform which uses this helper.

v2: Fixes from Eric's review:
   a) Split out series of refactor for helpers to a separate series.
   b) Add the new helper function and use them to replace the old code in the
      same patch.

v3: Fixes from Emil and Gurchetan's review
  - Follow the naming convention which prevents too verbose name of functions.
    a) use a dri2_surface_$action_$object naming convention
    b) change a first argument type "struct dri2_egl_surface" to "_EGLSurface".

Signed-off-by: Mun Gwan-gyeong <elongbug at gmail.com>
Reviewed-by: Emil Velikov <emil.velikov at collabora.com>
---
 src/egl/drivers/dri2/egl_dri2.c         | 13 +++++++++++++
 src/egl/drivers/dri2/egl_dri2.h         |  3 +++
 src/egl/drivers/dri2/platform_android.c |  8 ++------
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 503450542e..238e299aed 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1079,6 +1079,19 @@ dri2_egl_surface_free_local_buffers(struct dri2_egl_surface *dri2_surf)
    }
 }
 
+void
+dri2_surface_fixup(_EGLSurface *surf, int width, int height)
+{
+   struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
+
+   /* free outdated buffers and update the surface size */
+   if (surf->Width != width || surf->Height != height) {
+      dri2_egl_surface_free_local_buffers(dri2_surf);
+      surf->Width = width;
+      surf->Height = height;
+   }
+}
+
 /**
  * Called via eglTerminate(), drv->API.Terminate().
  *
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index cd2487ab22..208a03d73a 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -455,6 +455,9 @@ dri2_egl_surface_alloc_local_buffer(struct dri2_egl_surface *dri2_surf,
 void
 dri2_egl_surface_free_local_buffers(struct dri2_egl_surface *dri2_surf);
 
+void
+dri2_surface_fixup(_EGLSurface *surf, int width, int height);
+
 EGLBoolean
 dri2_init_surface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
         _EGLConfig *conf, const EGLint *attrib_list, EGLBoolean enable_out_fence);
diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index e390365b8b..d00a3333a2 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -414,12 +414,8 @@ update_buffers(struct dri2_egl_surface *dri2_surf)
    }
 
    /* free outdated buffers and update the surface size */
-   if (dri2_surf->base.Width != dri2_surf->buffer->width ||
-       dri2_surf->base.Height != dri2_surf->buffer->height) {
-      dri2_egl_surface_free_local_buffers(dri2_surf);
-      dri2_surf->base.Width = dri2_surf->buffer->width;
-      dri2_surf->base.Height = dri2_surf->buffer->height;
-   }
+   dri2_surface_fixup(&dri2_surf->base, dri2_surf->buffer->width,
+                      dri2_surf->buffer->height);
 
    return 0;
 }
-- 
2.15.0



More information about the mesa-dev mailing list