To share common get and create dri_image_front code.

In preparation to adding of new platform which uses this helper.

v2:
 - Remove unneeded ifdef magic
 - 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 <elong...@gmail.com>
---
 src/egl/drivers/dri2/egl_dri2.c         | 34 ++++++++++++++++++++++++++++++++
 src/egl/drivers/dri2/egl_dri2.h         |  3 +++
 src/egl/drivers/dri2/platform_android.c | 35 +--------------------------------
 3 files changed, 38 insertions(+), 34 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 67ae33cdc9..fd55dba7de 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1139,6 +1139,40 @@ 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)
+{
+   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;
+      }
+   }
+
+   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 83b9e368b2..0f4ef763bd 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -478,6 +478,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);
diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index c98802774c..ef55a6d085 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -388,39 +388,6 @@ update_buffers(struct dri2_egl_surface *dri2_surf)
    return 0;
 }
 
-static int
-get_front_bo(struct dri2_egl_surface *dri2_surf, unsigned int format)
-{
-   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;
-      }
-   }
-
-   return 0;
-}
-
 static int
 get_back_bo(struct dri2_egl_surface *dri2_surf)
 {
@@ -512,7 +479,7 @@ droid_image_get_buffers(__DRIdrawable *driDrawable,
       return 0;
 
    if (buffer_mask & __DRI_IMAGE_BUFFER_FRONT) {
-      if (get_front_bo(dri2_surf, format) < 0)
+      if (dri2_egl_surface_get_image_front(dri2_surf, format) < 0)
          return 0;
 
       if (dri2_surf->dri_image_front) {
-- 
2.14.2

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to