From ecc1f560094d715bf940b09583b7c1ee8b5774d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 20 Oct 2016 14:14:14 +0800 Subject: [PATCH] cogl: Expose API for creating texture from EGLImage Later to be used by mutter to create EGLImage's from Wayland buffers. https://bugzilla.gnome.org/show_bug.cgi?id=773629 --- cogl/cogl/cogl-texture-2d-private.h | 17 ----------------- cogl/cogl/cogl-texture-2d.c | 22 +++++++++++----------- cogl/cogl/cogl-texture-2d.h | 17 +++++++++++++++++ cogl/cogl/winsys/cogl-winsys-egl-x11.c | 13 +++++++------ 4 files changed, 35 insertions(+), 34 deletions(-) diff --git a/cogl/cogl/cogl-texture-2d-private.h b/cogl/cogl/cogl-texture-2d-private.h index 27847af64..3723e4cd4 100644 --- a/cogl/cogl/cogl-texture-2d-private.h +++ b/cogl/cogl/cogl-texture-2d-private.h @@ -36,10 +36,6 @@ #include "cogl-texture-private.h" #include "cogl-texture-2d.h" -#ifdef COGL_HAS_EGL_SUPPORT -#include "cogl-egl-defines.h" -#endif - struct _CoglTexture2D { CoglTexture _parent; @@ -70,19 +66,6 @@ CoglTexture2D * _cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp, CoglBool can_convert_in_place); -#if defined (COGL_HAS_EGL_SUPPORT) && defined (EGL_KHR_image_base) -/* NB: The reason we require the width, height and format to be passed - * even though they may seem redundant is because GLES 1/2 don't - * provide a way to query these properties. */ -CoglTexture2D * -_cogl_egl_texture_2d_new_from_image (CoglContext *ctx, - int width, - int height, - CoglPixelFormat format, - EGLImageKHR image, - CoglError **error); -#endif - CoglTexture2D * _cogl_texture_2d_create_base (CoglContext *ctx, int width, diff --git a/cogl/cogl/cogl-texture-2d.c b/cogl/cogl/cogl-texture-2d.c index 447d33b30..dbfc09003 100644 --- a/cogl/cogl/cogl-texture-2d.c +++ b/cogl/cogl/cogl-texture-2d.c @@ -236,12 +236,12 @@ cogl_texture_2d_new_from_data (CoglContext *ctx, * even though they may seem redundant is because GLES 1/2 don't * provide a way to query these properties. */ CoglTexture2D * -_cogl_egl_texture_2d_new_from_image (CoglContext *ctx, - int width, - int height, - CoglPixelFormat format, - EGLImageKHR image, - CoglError **error) +cogl_egl_texture_2d_new_from_image (CoglContext *ctx, + int width, + int height, + CoglPixelFormat format, + EGLImageKHR image, + CoglError **error) { CoglTextureLoader *loader; CoglTexture2D *tex; @@ -430,11 +430,11 @@ cogl_wayland_texture_2d_new_from_buffer (CoglContext *ctx, EGL_WAYLAND_BUFFER_WL, buffer, NULL); - tex = _cogl_egl_texture_2d_new_from_image (ctx, - width, height, - internal_format, - image, - error); + tex = cogl_egl_texture_2d_new_from_image (ctx, + width, height, + internal_format, + image, + error); _cogl_egl_destroy_image (ctx, image); return tex; } diff --git a/cogl/cogl/cogl-texture-2d.h b/cogl/cogl/cogl-texture-2d.h index ee6c9d748..0da74abcf 100644 --- a/cogl/cogl/cogl-texture-2d.h +++ b/cogl/cogl/cogl-texture-2d.h @@ -40,6 +40,10 @@ #include "cogl-context.h" #include "cogl-bitmap.h" +#ifdef COGL_HAS_EGL_SUPPORT +#include "cogl-egl-defines.h" +#endif + COGL_BEGIN_DECLS /** @@ -227,6 +231,19 @@ cogl_texture_2d_new_from_data (CoglContext *ctx, CoglTexture2D * cogl_texture_2d_new_from_bitmap (CoglBitmap *bitmap); +#if defined (COGL_HAS_EGL_SUPPORT) && defined (EGL_KHR_image_base) +/* NB: The reason we require the width, height and format to be passed + * even though they may seem redundant is because GLES 1/2 don't + * provide a way to query these properties. */ +CoglTexture2D * +cogl_egl_texture_2d_new_from_image (CoglContext *ctx, + int width, + int height, + CoglPixelFormat format, + EGLImageKHR image, + CoglError **error); +#endif + COGL_END_DECLS #endif /* __COGL_TEXTURE_2D_H */ diff --git a/cogl/cogl/winsys/cogl-winsys-egl-x11.c b/cogl/cogl/winsys/cogl-winsys-egl-x11.c index b7e4e629d..c660f3428 100644 --- a/cogl/cogl/winsys/cogl-winsys-egl-x11.c +++ b/cogl/cogl/winsys/cogl-winsys-egl-x11.c @@ -48,6 +48,7 @@ #include "cogl-texture-pixmap-x11-private.h" #include "cogl-texture-2d-private.h" +#include "cogl-texture-2d.h" #include "cogl-error-private.h" #include "cogl-poll-private.h" @@ -741,12 +742,12 @@ _cogl_winsys_texture_pixmap_x11_create (CoglTexturePixmapX11 *tex_pixmap) COGL_PIXEL_FORMAT_RGB_888); egl_tex_pixmap->texture = COGL_TEXTURE ( - _cogl_egl_texture_2d_new_from_image (ctx, - tex->width, - tex->height, - texture_format, - egl_tex_pixmap->image, - NULL)); + cogl_egl_texture_2d_new_from_image (ctx, + tex->width, + tex->height, + texture_format, + egl_tex_pixmap->image, + NULL)); tex_pixmap->winsys = egl_tex_pixmap;