[Mesa-dev] [PATCH v3 14/22] egl: add dri2_egl_surface_get_image_front() helper

Gwan-gyeong Mun elongbug at gmail.com
Wed Oct 4 06:50:26 UTC 2017


To share common get and create dri_image_front code.

Signed-off-by: Mun Gwan-gyeong <elongbug at gmail.com>
---
 src/egl/drivers/dri2/egl_dri2.c | 36 ++++++++++++++++++++++++++++++++++++
 src/egl/drivers/dri2/egl_dri2.h |  3 +++
 2 files changed, 39 insertions(+)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 4070a80b23..890ed8138f 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1167,6 +1167,42 @@ dri2_egl_surface_destroy_image_front(struct dri2_egl_surface *dri2_surf)
 #endif
 }
 
+int
+dri2_egl_surface_get_image_front(struct dri2_egl_surface *dri2_surf,
+                                 unsigned int format)
+{
+#if defined(HAVE_ANDROID_PLATFORM) || defined(HAVE_TIZEN_PLATFORM)
+   struct dri2_egl_display *dri2_dpy =
+      dri2_egl_display(dri2_surf->base.Resource.Display);
+
+   if (dri2_surf->dri_image_front)
+      return 0;
+
+   if (dri2_surf->base.Type == EGL_WINDOW_BIT) {
+      /* According current EGL spec, front buffer rendering
+       * for window surface is not supported now.
+       * and mesa doesn't have the implementation of this case.
+       * Add warning message, but not treat it as error.
+       */
+      _eglLog(_EGL_DEBUG, "DRI driver requested unsupported front buffer for window surface");
+   } else if (dri2_surf->base.Type == EGL_PBUFFER_BIT) {
+      dri2_surf->dri_image_front =
+         dri2_dpy->image->createImage(dri2_dpy->dri_screen,
+                                      dri2_surf->base.Width,
+                                      dri2_surf->base.Height,
+                                      format,
+                                      0,
+                                      dri2_surf);
+      if (!dri2_surf->dri_image_front) {
+         _eglLog(_EGL_WARNING, "dri2_image_front allocation failed");
+         return -1;
+      }
+   }
+#endif
+
+   return 0;
+}
+
 /**
  * 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 fbef031fb6..d24425dba1 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -512,6 +512,9 @@ 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);
 
+int
+dri2_egl_surface_get_image_front(struct dri2_egl_surface *dri2_surf,
+                                 unsigned int format);
 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