1
0
Fork 0

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
This commit is contained in:
Jonas Ådahl 2019-07-16 18:29:29 +02:00 committed by Georges Basile Stavracas Neto
parent e6c8939c30
commit 7868ab761f
8 changed files with 22 additions and 0 deletions

View file

@ -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);

View file

@ -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,

View file

@ -182,6 +182,7 @@ typedef struct _CoglTextureLoader
int width;
int height;
CoglPixelFormat format;
CoglEglImageFlags flags;
} egl_image;
#endif
#if defined (COGL_HAS_EGL_SUPPORT)

View file

@ -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,

View file

@ -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;

View file

@ -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);

View file

@ -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);

View file

@ -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);