Module: Mesa
Branch: master
Commit: 9e1248d0752e692714b58ef1f2211ec7e172c8cf
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9e1248d0752e692714b58ef1f2211ec7e172c8cf

Author: Tomasz Figa <[email protected]>
Date:   Fri Jul 15 16:53:50 2016 +0900

egl/android: Stop leaking DRI images

Current implementation of the DRI image loader does not free the images
created in get_back_bo() and so leaks memory. Moreover, it creates a new
image every time the DRI driver queries for buffers, even if the backing
native buffer has not changed. leaking memory again.

This patch adds missing call to destroyImage() in droid_enqueue_buffer()
and a check if image is already created to get_back_bo() to fix the
above.

Cc: "11.2 12.0" <[email protected]>
Signed-off-by: Tomasz Figa <[email protected]>
Reviewed-by: Eric Anholt <[email protected]>
Reviewed-by: Emil Velikov <[email protected]>

---

 src/egl/drivers/dri2/platform_android.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index 37616f9..e3d5f0b 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -162,6 +162,8 @@ droid_window_dequeue_buffer(struct dri2_egl_surface 
*dri2_surf)
 static EGLBoolean
 droid_window_enqueue_buffer(_EGLDisplay *disp, struct dri2_egl_surface 
*dri2_surf)
 {
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+
    /* To avoid blocking other EGL calls, release the display mutex before
     * we enter droid_window_enqueue_buffer() and re-acquire the mutex upon
     * return.
@@ -192,6 +194,12 @@ droid_window_enqueue_buffer(_EGLDisplay *disp, struct 
dri2_egl_surface *dri2_sur
    dri2_surf->buffer = NULL;
 
    mtx_lock(&disp->Mutex);
+
+   if (dri2_surf->dri_image) {
+      dri2_dpy->image->destroyImage(dri2_surf->dri_image);
+      dri2_surf->dri_image = NULL;
+   }
+
    return EGL_TRUE;
 }
 
@@ -377,6 +385,9 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
    int fourcc, pitch;
    int offset = 0, fd;
 
+   if (dri2_surf->dri_image)
+          return 0;
+
    if (!dri2_surf->buffer)
       return -1;
 

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to