To share common destroy dri_image_back code. In preparation to adding of new platform which uses this helper.
v2: - Move dri_image_back to outside of android ifdef block for removing of ifdef magic on dri2_egl_surface_destroy_image_back(). - 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 <elong...@gmail.com> Reviewed-by: Emil Velikov <emil.veli...@collabora.com> --- src/egl/drivers/dri2/egl_dri2.c | 12 ++++++++++++ src/egl/drivers/dri2/egl_dri2.h | 6 +++++- src/egl/drivers/dri2/platform_android.c | 11 ++--------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index d381e52e86..dc2aecef88 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -1142,6 +1142,18 @@ dri2_surface_update_age(_EGLSurface *surf) dri2_surf->back->age = 1; } +void +dri2_surface_destroy_back_image(_EGLSurface *surf) +{ + struct dri2_egl_display *dri2_dpy = dri2_egl_display(surf->Resource.Display); + struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf); + + if (dri2_surf->dri_image_back) { + dri2_dpy->image->destroyImage(dri2_surf->dri_image_back); + dri2_surf->dri_image_back = NULL; + } +} + /** * 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 58f8082509..f13bdb6d12 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h @@ -303,10 +303,11 @@ struct dri2_egl_surface int age; } color_buffers[COLOR_BUFFERS_SIZE], *back, *current; + __DRIimage *dri_image_back; + #ifdef HAVE_ANDROID_PLATFORM struct ANativeWindow *window; struct ANativeWindowBuffer *buffer; - __DRIimage *dri_image_back; __DRIimage *dri_image_front; #endif @@ -460,6 +461,9 @@ dri2_surface_set_back_buffer(_EGLSurface *surf, void *buffer); void dri2_surface_update_age(_EGLSurface *surf); +void +dri2_surface_destroy_back_image(_EGLSurface *surf); + 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 45af871555..e0896ed1a0 100644 --- a/src/egl/drivers/dri2/platform_android.c +++ b/src/egl/drivers/dri2/platform_android.c @@ -228,10 +228,7 @@ droid_window_enqueue_buffer(_EGLDisplay *disp, struct dri2_egl_surface *dri2_sur mtx_lock(&disp->Mutex); - if (dri2_surf->dri_image_back) { - dri2_dpy->image->destroyImage(dri2_surf->dri_image_back); - dri2_surf->dri_image_back = NULL; - } + dri2_surface_destroy_back_image(&dri2_surf->base); return EGL_TRUE; } @@ -355,11 +352,7 @@ droid_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) dri2_surf->window->common.decRef(&dri2_surf->window->common); } - if (dri2_surf->dri_image_back) { - _eglLog(_EGL_DEBUG, "%s : %d : destroy dri_image_back", __func__, __LINE__); - dri2_dpy->image->destroyImage(dri2_surf->dri_image_back); - dri2_surf->dri_image_back = NULL; - } + dri2_surface_destroy_back_image(surf); if (dri2_surf->dri_image_front) { _eglLog(_EGL_DEBUG, "%s : %d : destroy dri_image_front", __func__, __LINE__); -- 2.14.2 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev