[Mesa-dev] [PATCH 12/12] egl/wayland: simplify and comment wl_buffer_release()

Emil Velikov emil.l.velikov at gmail.com
Thu Aug 3 18:29:38 UTC 2017


Simply the function a bit and add a comment explaining why we don't
simply destroy any buffer.

Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
 src/egl/drivers/dri2/platform_wayland.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index 7753f0f2c50..918e8393951 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -75,16 +75,16 @@ wl_buffer_release(void *data, struct wl_buffer *buffer)
    struct dri2_egl_surface *dri2_surf = data;
    int i;
 
-   for (i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); ++i)
-      if (dri2_surf->color_buffers[i].wl_buffer == buffer)
-         break;
-
-   if (i == ARRAY_SIZE(dri2_surf->color_buffers)) {
-      wl_buffer_destroy(buffer);
-      return;
+   /* Unlock the buffer if it's in our color_buffers[] list. It will be
+    * destroyed at a later stage. */
+   for (i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); ++i) {
+      if (dri2_surf->color_buffers[i].wl_buffer == buffer) {
+         dri2_surf->color_buffers[i].locked = false;
+         return;
+      }
    }
 
-   dri2_surf->color_buffers[i].locked = false;
+   wl_buffer_destroy(buffer);
 }
 
 static const struct wl_buffer_listener wl_buffer_listener = {
-- 
2.13.3



More information about the mesa-dev mailing list