[Mesa-dev] [PATCH 07/12] FINISHME: egl: introduce dri2_create_dri_image() helper
Emil Velikov
emil.l.velikov at gmail.com
Thu Aug 3 18:29:33 UTC 2017
From: Emil Velikov <emil.velikov at collabora.com>
XXX: commit message
XXX: keep it inline or move to egl_dri2.c
XXX: fold createwithmodifiers - now or as follow-up
Cc: Daniel Stone <daniels at collabora.com>
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
Dan do you think it's a wise move to have this as a helper which tries
the withmodifiers call first and falls back to the normal createImage?
---
src/egl/drivers/dri2/egl_dri2.h | 16 ++++++++++++++++
src/egl/drivers/dri2/platform_android.c | 11 +----------
src/egl/drivers/dri2/platform_surfaceless.c | 18 +-----------------
src/egl/drivers/dri2/platform_wayland.c | 18 ++++--------------
4 files changed, 22 insertions(+), 41 deletions(-)
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 21bbc1fd966..bad72a72c2f 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -450,4 +450,20 @@ dri2_set_WL_bind_wayland_display(_EGLDriver *drv, _EGLDisplay *disp)
void
dri2_display_destroy(_EGLDisplay *disp);
+
+static inline __DRIimage *
+dri2_create_dri_image(struct dri2_egl_surface *dri2_surf, int format,
+ unsigned int use)
+{
+ struct dri2_egl_display *dri2_dpy =
+ dri2_egl_display(dri2_surf->base.Resource.Display);
+
+ return dri2_dpy->image->createImage(dri2_dpy->dri_screen,
+ dri2_surf->base.Width,
+ dri2_surf->base.Height,
+ format,
+ use,
+ dri2_surf);
+}
+
#endif /* EGL_DRI2_INCLUDED */
diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index 50a82486956..342f57dd94c 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -458,9 +458,6 @@ update_buffers(struct dri2_egl_surface *dri2_surf)
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;
@@ -472,13 +469,7 @@ get_front_bo(struct dri2_egl_surface *dri2_surf, unsigned int format)
*/
_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);
+ dri2_surf->dri_image_front = dri2_create_dri_image(dri2_surf, format, 0);
if (!dri2_surf->dri_image_front) {
_eglLog(_EGL_WARNING, "dri2_image_front allocation failed");
return -1;
diff --git a/src/egl/drivers/dri2/platform_surfaceless.c b/src/egl/drivers/dri2/platform_surfaceless.c
index 1091b4febdb..6e612f01a49 100644
--- a/src/egl/drivers/dri2/platform_surfaceless.c
+++ b/src/egl/drivers/dri2/platform_surfaceless.c
@@ -37,19 +37,6 @@
#include "egl_dri2_fallbacks.h"
#include "loader.h"
-static __DRIimage*
-surfaceless_alloc_image(struct dri2_egl_display *dri2_dpy,
- struct dri2_egl_surface *dri2_surf)
-{
- return dri2_dpy->image->createImage(
- dri2_dpy->dri_screen,
- dri2_surf->base.Width,
- dri2_surf->base.Height,
- dri2_surf->visual,
- 0,
- NULL);
-}
-
static void
surfaceless_free_images(struct dri2_egl_surface *dri2_surf)
{
@@ -71,8 +58,6 @@ surfaceless_image_get_buffers(__DRIdrawable *driDrawable,
struct __DRIimageList *buffers)
{
struct dri2_egl_surface *dri2_surf = loaderPrivate;
- struct dri2_egl_display *dri2_dpy =
- dri2_egl_display(dri2_surf->base.Resource.Display);
buffers->image_mask = 0;
buffers->front = NULL;
@@ -95,8 +80,7 @@ surfaceless_image_get_buffers(__DRIdrawable *driDrawable,
if (buffer_mask & __DRI_IMAGE_BUFFER_FRONT) {
if (!dri2_surf->front)
- dri2_surf->front =
- surfaceless_alloc_image(dri2_dpy, dri2_surf);
+ dri2_surf->front = dri2_create_dri_image(dri2_surf, dri2_surf->visual, 0);
buffers->image_mask |= __DRI_IMAGE_BUFFER_FRONT;
buffers->front = dri2_surf->front;
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index 38fdfe974fa..67be9683aca 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -426,13 +426,8 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
NULL);
} else {
dri2_surf->back->linear_copy =
- dri2_dpy->image->createImage(dri2_dpy->dri_screen,
- dri2_surf->base.Width,
- dri2_surf->base.Height,
- dri_image_format,
- use_flags |
- __DRI_IMAGE_USE_LINEAR,
- NULL);
+ dri2_create_dri_image(dri2_surf, dri_image_format,
+ use_flags | __DRI_IMAGE_USE_LINEAR);
}
if (dri2_surf->back->linear_copy == NULL)
return -1;
@@ -455,13 +450,8 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
NULL);
} else {
dri2_surf->back->dri_image =
- dri2_dpy->image->createImage(dri2_dpy->dri_screen,
- dri2_surf->base.Width,
- dri2_surf->base.Height,
- dri_image_format,
- dri2_dpy->is_different_gpu ?
- 0 : use_flags,
- NULL);
+ dri2_create_dri_image(dri2_surf, dri_image_format,
+ dri2_dpy->is_different_gpu ? 0 : use_flags);
}
dri2_surf->back->age = 0;
--
2.13.3
More information about the mesa-dev
mailing list