[Mesa-dev] [PATCH v3 06/22] egl: add dri2_egl_surface_record_buffers_and_update_back_buffer() helper
Gwan-gyeong Mun
elongbug at gmail.com
Wed Oct 4 06:50:18 UTC 2017
To share common record buffers and update back buffer code.
This records all the buffers created by ANativeWindow [Android] or
tpl_surface (tbm_surface_queue) [TIZEN] and update back buffer for updating
buffer's age in swap_buffers.
Signed-off-by: Mun Gwan-gyeong <elongbug at gmail.com>
---
src/egl/drivers/dri2/egl_dri2.c | 42 +++++++++++++++++++++++++++++++++++++++++
src/egl/drivers/dri2/egl_dri2.h | 5 +++++
2 files changed, 47 insertions(+)
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 8d4bfa8c1a..807403dc51 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1078,6 +1078,48 @@ dri2_egl_surface_free_outdated_buffers_and_update_size(struct dri2_egl_surface *
}
}
+void
+dri2_egl_surface_record_buffers_and_update_back_buffer(struct dri2_egl_surface *dri2_surf,
+ void *buf)
+{
+#if defined(HAVE_ANDROID_PLATFORM) || defined(HAVE_TIZEN_PLATFORM)
+ /* Record all the buffers created by ANativeWindow [Android] or
+ * tpl_surface (tbm_surface_queue) [TIZEN] and update back buffer for updating
+ * buffer's age in swap_buffers.
+ */
+
+#ifdef HAVE_ANDROID_PLATFORM
+ struct ANativeWindowBuffer *buffer = (struct ANativeWindowBuffer *)buf;
+#endif
+#ifdef HAVE_TIZEN_PLATFORM
+ tbm_surface_h buffer = (tbm_surface_h)buf;
+#endif
+ EGLBoolean updated = EGL_FALSE;
+
+ for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
+ if (!dri2_surf->color_buffers[i].buffer) {
+ dri2_surf->color_buffers[i].buffer = buffer;
+ dri2_surf->color_buffers[i].age = 0;
+ }
+ if (dri2_surf->color_buffers[i].buffer == buffer) {
+ dri2_surf->back = &dri2_surf->color_buffers[i];
+ updated = EGL_TRUE;
+ break;
+ }
+ }
+
+ if (!updated) {
+ /* In case of all the buffers were recreated, reset the color_buffers */
+ for (int i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
+ dri2_surf->color_buffers[i].buffer = NULL;
+ dri2_surf->color_buffers[i].age = 0;
+ }
+ dri2_surf->color_buffers[0].buffer = buffer;
+ dri2_surf->back = &dri2_surf->color_buffers[0];
+ }
+#endif
+}
+
/**
* 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 4d2348e584..c3529589ab 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -489,6 +489,11 @@ dri2_egl_surface_free_local_buffers(struct dri2_egl_surface *dri2_surf);
void
dri2_egl_surface_free_outdated_buffers_and_update_size(struct dri2_egl_surface *dri2_surf,
int width, int height);
+
+void
+dri2_egl_surface_record_buffers_and_update_back_buffer(struct dri2_egl_surface *dri2_surf,
+ void *buf);
+
EGLBoolean
dri2_init_surface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
_EGLConfig *conf, const EGLint *attrib_list, EGLBoolean enable_out_fence);
--
2.14.2
More information about the mesa-dev
mailing list