To share common destroy dri_image_front code. In preparation to adding of new platform which uses this helper.
v2: - Move dri_image_front to outside of android ifdef block for removing of ifdef magic on dri2_egl_surface_destroy_image_front(). - 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. Signed-off-by: Mun Gwan-gyeong <elong...@gmail.com> --- src/egl/drivers/dri2/egl_dri2.c | 12 ++++++++++++ src/egl/drivers/dri2/egl_dri2.h | 5 ++++- src/egl/drivers/dri2/platform_android.c | 7 +------ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index bb4944358d..67ae33cdc9 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -1127,6 +1127,18 @@ dri2_egl_surface_destroy_image_back(struct dri2_egl_surface *dri2_surf) } } +void +dri2_egl_surface_destroy_image_front(struct dri2_egl_surface *dri2_surf) +{ + struct dri2_egl_display *dri2_dpy = + dri2_egl_display(dri2_surf->base.Resource.Display); + + if (dri2_surf->dri_image_front) { + dri2_dpy->image->destroyImage(dri2_surf->dri_image_front); + dri2_surf->dri_image_front = 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 165749ebb1..83b9e368b2 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h @@ -313,11 +313,11 @@ struct dri2_egl_surface } color_buffers[COLOR_BUFFERS_SIZE], *back, *current; __DRIimage *dri_image_back; + __DRIimage *dri_image_front; #ifdef HAVE_ANDROID_PLATFORM struct ANativeWindow *window; struct ANativeWindowBuffer *buffer; - __DRIimage *dri_image_front; #endif #if defined(HAVE_SURFACELESS_PLATFORM) @@ -475,6 +475,9 @@ dri2_egl_surface_update_buffer_age(struct dri2_egl_surface *dri2_surf); void dri2_egl_surface_destroy_image_back(struct dri2_egl_surface *dri2_surf); +void +dri2_egl_surface_destroy_image_front(struct dri2_egl_surface *dri2_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 421395b5d7..c98802774c 100644 --- a/src/egl/drivers/dri2/platform_android.c +++ b/src/egl/drivers/dri2/platform_android.c @@ -354,12 +354,7 @@ droid_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) } dri2_egl_surface_destroy_image_back(dri2_surf); - - if (dri2_surf->dri_image_front) { - _eglLog(_EGL_DEBUG, "%s : %d : destroy dri_image_front", __func__, __LINE__); - dri2_dpy->image->destroyImage(dri2_surf->dri_image_front); - dri2_surf->dri_image_front = NULL; - } + dri2_egl_surface_destroy_image_front(dri2_surf); dri2_dpy->core->destroyDrawable(dri2_surf->dri_drawable); -- 2.14.2 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev