[Mesa-dev] [PATCH v2 5/8] egl: add dri2_egl_surface_destroy_image_back() helper (v2)
Gwan-gyeong Mun
elongbug at gmail.com
Fri Oct 6 21:38:32 UTC 2017
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.
Signed-off-by: Mun Gwan-gyeong <elongbug at gmail.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 a0f58ca8e4..bb4944358d 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1115,6 +1115,18 @@ dri2_egl_surface_update_buffer_age(struct dri2_egl_surface *dri2_surf)
dri2_surf->back->age = 1;
}
+void
+dri2_egl_surface_destroy_image_back(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_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 fe3880ef89..165749ebb1 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -312,10 +312,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
@@ -471,6 +472,9 @@ dri2_egl_surface_record_buffers_and_update_back_buffer(struct dri2_egl_surface *
void
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);
+
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 29ee12b140..421395b5d7 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -229,10 +229,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_egl_surface_destroy_image_back(dri2_surf);
return EGL_TRUE;
}
@@ -356,11 +353,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_egl_surface_destroy_image_back(dri2_surf);
if (dri2_surf->dri_image_front) {
_eglLog(_EGL_DEBUG, "%s : %d : destroy dri_image_front", __func__, __LINE__);
--
2.14.2
More information about the mesa-dev
mailing list