[mutter] cogl/texture: Add EGLImage texture import flags



commit 7868ab761f774086df1278b08c0bec124f1cd5df
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Tue Jul 16 18:29:29 2019 +0200

    cogl/texture: Add EGLImage texture import flags
    
    The flags are 'none', and 'no-get-data' meaning get_data() is not
    supported.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/687

 cogl/cogl/cogl-texture-2d.c                | 2 ++
 cogl/cogl/cogl-texture-2d.h                | 7 +++++++
 cogl/cogl/cogl-texture-private.h           | 1 +
 cogl/cogl/driver/gl/cogl-texture-2d-gl.c   | 2 ++
 cogl/cogl/winsys/cogl-winsys-egl-x11.c     | 1 +
 src/backends/native/meta-renderer-native.c | 3 +++
 src/wayland/meta-wayland-buffer.c          | 3 +++
 src/wayland/meta-wayland-dma-buf.c         | 3 +++
 8 files changed, 22 insertions(+)
---
diff --git a/cogl/cogl/cogl-texture-2d.c b/cogl/cogl/cogl-texture-2d.c
index c5b44bf97..1adf719a3 100644
--- a/cogl/cogl/cogl-texture-2d.c
+++ b/cogl/cogl/cogl-texture-2d.c
@@ -241,6 +241,7 @@ cogl_egl_texture_2d_new_from_image (CoglContext *ctx,
                                     int height,
                                     CoglPixelFormat format,
                                     EGLImageKHR image,
+                                    CoglEglImageFlags flags,
                                     GError **error)
 {
   CoglTextureLoader *loader;
@@ -261,6 +262,7 @@ cogl_egl_texture_2d_new_from_image (CoglContext *ctx,
   loader->src.egl_image.width = width;
   loader->src.egl_image.height = height;
   loader->src.egl_image.format = format;
+  loader->src.egl_image.flags = flags;
 
   tex = _cogl_texture_2d_create_base (ctx, width, height, format, loader);
 
diff --git a/cogl/cogl/cogl-texture-2d.h b/cogl/cogl/cogl-texture-2d.h
index 5fc97179e..4dccd84a0 100644
--- a/cogl/cogl/cogl-texture-2d.h
+++ b/cogl/cogl/cogl-texture-2d.h
@@ -60,6 +60,12 @@ G_BEGIN_DECLS
 typedef struct _CoglTexture2D CoglTexture2D;
 #define COGL_TEXTURE_2D(X) ((CoglTexture2D *)X)
 
+typedef enum _CoglEglImageFlags
+{
+  COGL_EGL_IMAGE_FLAG_NONE = 0,
+  COGL_EGL_IMAGE_FLAG_NO_GET_DATA = 1 << 0,
+} CoglEglImageFlags;
+
 /**
  * cogl_texture_2d_get_gtype:
  *
@@ -219,6 +225,7 @@ cogl_egl_texture_2d_new_from_image (CoglContext *ctx,
                                     int height,
                                     CoglPixelFormat format,
                                     EGLImageKHR image,
+                                    CoglEglImageFlags flags,
                                     GError **error);
 
 typedef gboolean (*CoglTexture2DEGLImageExternalAlloc) (CoglTexture2D *tex_2d,
diff --git a/cogl/cogl/cogl-texture-private.h b/cogl/cogl/cogl-texture-private.h
index 481e436dd..006bf7514 100644
--- a/cogl/cogl/cogl-texture-private.h
+++ b/cogl/cogl/cogl-texture-private.h
@@ -182,6 +182,7 @@ typedef struct _CoglTextureLoader
       int width;
       int height;
       CoglPixelFormat format;
+      CoglEglImageFlags flags;
     } egl_image;
 #endif
 #if defined (COGL_HAS_EGL_SUPPORT)
diff --git a/cogl/cogl/driver/gl/cogl-texture-2d-gl.c b/cogl/cogl/driver/gl/cogl-texture-2d-gl.c
index 08f8b263c..04bac1b7b 100644
--- a/cogl/cogl/driver/gl/cogl-texture-2d-gl.c
+++ b/cogl/cogl/driver/gl/cogl-texture-2d-gl.c
@@ -320,6 +320,8 @@ allocate_from_egl_image (CoglTexture2D *tex_2d,
     }
 
   tex_2d->internal_format = internal_format;
+  tex_2d->is_get_data_supported =
+    !(loader->src.egl_image.flags & COGL_EGL_IMAGE_FLAG_NO_GET_DATA);
 
   _cogl_texture_set_allocated (tex,
                                internal_format,
diff --git a/cogl/cogl/winsys/cogl-winsys-egl-x11.c b/cogl/cogl/winsys/cogl-winsys-egl-x11.c
index 9735c7605..449a31f4b 100644
--- a/cogl/cogl/winsys/cogl-winsys-egl-x11.c
+++ b/cogl/cogl/winsys/cogl-winsys-egl-x11.c
@@ -801,6 +801,7 @@ _cogl_winsys_texture_pixmap_x11_create (CoglTexturePixmapX11 *tex_pixmap)
                                         tex->height,
                                         texture_format,
                                         egl_tex_pixmap->image,
+                                        COGL_EGL_IMAGE_FLAG_NONE,
                                         NULL));
 
   tex_pixmap->winsys = egl_tex_pixmap;
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
index 46dba6775..b491a54f8 100644
--- a/src/backends/native/meta-renderer-native.c
+++ b/src/backends/native/meta-renderer-native.c
@@ -1870,6 +1870,7 @@ copy_shared_framebuffer_primary_gpu (CoglOnscreen                        *onscre
   uint32_t offsets[1];
   uint64_t modifiers[1];
   CoglPixelFormat cogl_format;
+  CoglEglImageFlags flags;
   CoglTexture2D *cogl_tex;
   CoglOffscreen *cogl_fbo;
   int ret;
@@ -1919,11 +1920,13 @@ copy_shared_framebuffer_primary_gpu (CoglOnscreen                        *onscre
       return FALSE;
     }
 
+  flags = COGL_EGL_IMAGE_FLAG_NONE;
   cogl_tex = cogl_egl_texture_2d_new_from_image (cogl_context,
                                                  dumb_fb->width,
                                                  dumb_fb->height,
                                                  cogl_format,
                                                  egl_image,
+                                                 flags,
                                                  &error);
 
   meta_egl_destroy_image (egl, egl_display, egl_image, NULL);
diff --git a/src/wayland/meta-wayland-buffer.c b/src/wayland/meta-wayland-buffer.c
index f45679d3a..cdaad26eb 100644
--- a/src/wayland/meta-wayland-buffer.c
+++ b/src/wayland/meta-wayland-buffer.c
@@ -289,6 +289,7 @@ egl_image_buffer_attach (MetaWaylandBuffer  *buffer,
   int format, width, height, y_inverted;
   CoglPixelFormat cogl_format;
   EGLImageKHR egl_image;
+  CoglEglImageFlags flags;
   CoglTexture2D *texture_2d;
 
   if (buffer->egl_image.texture)
@@ -343,10 +344,12 @@ egl_image_buffer_attach (MetaWaylandBuffer  *buffer,
   if (egl_image == EGL_NO_IMAGE_KHR)
     return FALSE;
 
+  flags = COGL_EGL_IMAGE_FLAG_NONE;
   texture_2d = cogl_egl_texture_2d_new_from_image (cogl_context,
                                                    width, height,
                                                    cogl_format,
                                                    egl_image,
+                                                   flags,
                                                    error);
 
   meta_egl_destroy_image (egl, egl_display, egl_image, NULL);
diff --git a/src/wayland/meta-wayland-dma-buf.c b/src/wayland/meta-wayland-dma-buf.c
index cf6d97932..08045cfda 100644
--- a/src/wayland/meta-wayland-dma-buf.c
+++ b/src/wayland/meta-wayland-dma-buf.c
@@ -79,6 +79,7 @@ meta_wayland_dma_buf_realize_texture (MetaWaylandBuffer  *buffer,
   uint64_t modifiers[META_WAYLAND_DMA_BUF_MAX_FDS];
   CoglPixelFormat cogl_format;
   EGLImageKHR egl_image;
+  CoglEglImageFlags flags;
   CoglTexture2D *texture;
 
   if (buffer->dma_buf.texture)
@@ -134,11 +135,13 @@ meta_wayland_dma_buf_realize_texture (MetaWaylandBuffer  *buffer,
   if (egl_image == EGL_NO_IMAGE_KHR)
     return FALSE;
 
+  flags = COGL_EGL_IMAGE_FLAG_NONE;
   texture = cogl_egl_texture_2d_new_from_image (cogl_context,
                                                 dma_buf->width,
                                                 dma_buf->height,
                                                 cogl_format,
                                                 egl_image,
+                                                flags,
                                                 error);
 
   meta_egl_destroy_image (egl, egl_display, egl_image, NULL);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]