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. 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 | 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 dc2aecef88..ed0fff199d 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -1154,6 +1154,18 @@ dri2_surface_destroy_back_image(_EGLSurface *surf) } } +void +dri2_surface_destroy_front_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_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 f13bdb6d12..6415fb22e6 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h @@ -304,11 +304,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) @@ -464,6 +464,9 @@ dri2_surface_update_age(_EGLSurface *surf); void dri2_surface_destroy_back_image(_EGLSurface *surf); +void +dri2_surface_destroy_front_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 e0896ed1a0..0b84f7221d 100644 --- a/src/egl/drivers/dri2/platform_android.c +++ b/src/egl/drivers/dri2/platform_android.c @@ -353,12 +353,7 @@ droid_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) } dri2_surface_destroy_back_image(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_surface_destroy_front_image(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