<div dir="ltr">dri2_egl_surface_destroy_image_front and dri2_egl_surface_destroy_image_back are almost identical. Why don't you just create a dri2_surface_free_image(struct dri2_egl_surface *dri2_surf, __DRIimage **img) that you will call with both the front and back images? In addition, only platform_android has dri_image_back and dri_image_front -- please keep the pre-processor checks. You can, however, merge the dri_image_front (used by platform_android) and front (used by platform_surfaceless).<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 6, 2017 at 2:38 PM, Gwan-gyeong Mun <span dir="ltr"><<a href="mailto:elongbug@gmail.com" target="_blank">elongbug@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">To share common destroy dri_image_front code.<br>
<br>
In preparation to adding of new platform which uses this helper.<br>
<br>
v2:<br>
- Move dri_image_front to outside of android ifdef block for removing of<br>
ifdef magic on dri2_egl_surface_destroy_<wbr>image_front().<br>
- Fixes from Eric's review:<br>
a) Split out series of refactor for helpers to a separate series.<br>
b) Add the new helper function and use them to replace the old code in the<br>
same patch.<br>
<br>
Signed-off-by: Mun Gwan-gyeong <<a href="mailto:elongbug@gmail.com">elongbug@gmail.com</a>><br>
---<br>
src/egl/drivers/dri2/egl_dri2.<wbr>c | 12 ++++++++++++<br>
src/egl/drivers/dri2/egl_dri2.<wbr>h | 5 ++++-<br>
src/egl/drivers/dri2/platform_<wbr>android.c | 7 +------<br>
3 files changed, 17 insertions(+), 7 deletions(-)<br>
<br>
diff --git a/src/egl/drivers/dri2/egl_<wbr>dri2.c b/src/egl/drivers/dri2/egl_<wbr>dri2.c<br>
index bb4944358d..67ae33cdc9 100644<br>
--- a/src/egl/drivers/dri2/egl_<wbr>dri2.c<br>
+++ b/src/egl/drivers/dri2/egl_<wbr>dri2.c<br>
@@ -1127,6 +1127,18 @@ dri2_egl_surface_destroy_<wbr>image_back(struct dri2_egl_surface *dri2_surf)<br>
}<br>
}<br>
<br>
+void<br>
+dri2_egl_surface_destroy_<wbr>image_front(struct dri2_egl_surface *dri2_surf)<br>
+{<br>
+ struct dri2_egl_display *dri2_dpy =<br>
+ dri2_egl_display(dri2_surf-><wbr>base.Resource.Display);<br>
+<br>
+ if (dri2_surf->dri_image_front) {<br>
+ dri2_dpy->image->destroyImage(<wbr>dri2_surf->dri_image_front);<br>
+ dri2_surf->dri_image_front = NULL;<br>
+ }<br>
+}<br>
+<br>
/**<br>
* Called via eglTerminate(), drv->API.Terminate().<br>
*<br>
diff --git a/src/egl/drivers/dri2/egl_<wbr>dri2.h b/src/egl/drivers/dri2/egl_<wbr>dri2.h<br>
index 165749ebb1..83b9e368b2 100644<br>
--- a/src/egl/drivers/dri2/egl_<wbr>dri2.h<br>
+++ b/src/egl/drivers/dri2/egl_<wbr>dri2.h<br>
@@ -313,11 +313,11 @@ struct dri2_egl_surface<br>
} color_buffers[COLOR_BUFFERS_<wbr>SIZE], *back, *current;<br>
<br>
__DRIimage *dri_image_back;<br>
+ __DRIimage *dri_image_front;<br>
<br>
#ifdef HAVE_ANDROID_PLATFORM<br>
struct ANativeWindow *window;<br>
struct ANativeWindowBuffer *buffer;<br>
- __DRIimage *dri_image_front;<br>
#endif<br>
<br>
#if defined(HAVE_SURFACELESS_<wbr>PLATFORM)<br>
@@ -475,6 +475,9 @@ dri2_egl_surface_update_<wbr>buffer_age(struct dri2_egl_surface *dri2_surf);<br>
void<br>
dri2_egl_surface_destroy_<wbr>image_back(struct dri2_egl_surface *dri2_surf);<br>
<br>
+void<br>
+dri2_egl_surface_destroy_<wbr>image_front(struct dri2_egl_surface *dri2_surf);<br>
+<br>
EGLBoolean<br>
dri2_init_surface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,<br>
_EGLConfig *conf, const EGLint *attrib_list, EGLBoolean enable_out_fence);<br>
diff --git a/src/egl/drivers/dri2/<wbr>platform_android.c b/src/egl/drivers/dri2/<wbr>platform_android.c<br>
index 421395b5d7..c98802774c 100644<br>
--- a/src/egl/drivers/dri2/<wbr>platform_android.c<br>
+++ b/src/egl/drivers/dri2/<wbr>platform_android.c<br>
@@ -354,12 +354,7 @@ droid_destroy_surface(_<wbr>EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)<br>
}<br>
<br>
dri2_egl_surface_destroy_<wbr>image_back(dri2_surf);<br>
-<br>
- if (dri2_surf->dri_image_front) {<br>
- _eglLog(_EGL_DEBUG, "%s : %d : destroy dri_image_front", __func__, __LINE__);<br>
- dri2_dpy->image->destroyImage(<wbr>dri2_surf->dri_image_front);<br>
- dri2_surf->dri_image_front = NULL;<br>
- }<br>
+ dri2_egl_surface_destroy_<wbr>image_front(dri2_surf);<br>
<br>
dri2_dpy->core-><wbr>destroyDrawable(dri2_surf-><wbr>dri_drawable);<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.14.2<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div>