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
This commit is contained in:
Jonas Ådahl 2016-10-20 14:14:14 +08:00
parent 18b9cf8a85
commit ecc1f56009
4 changed files with 35 additions and 34 deletions

View File

@ -36,10 +36,6 @@
#include "cogl-texture-private.h" #include "cogl-texture-private.h"
#include "cogl-texture-2d.h" #include "cogl-texture-2d.h"
#ifdef COGL_HAS_EGL_SUPPORT
#include "cogl-egl-defines.h"
#endif
struct _CoglTexture2D struct _CoglTexture2D
{ {
CoglTexture _parent; CoglTexture _parent;
@ -70,19 +66,6 @@ CoglTexture2D *
_cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp, _cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp,
CoglBool can_convert_in_place); 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 * CoglTexture2D *
_cogl_texture_2d_create_base (CoglContext *ctx, _cogl_texture_2d_create_base (CoglContext *ctx,
int width, int width,

View File

@ -236,7 +236,7 @@ cogl_texture_2d_new_from_data (CoglContext *ctx,
* even though they may seem redundant is because GLES 1/2 don't * even though they may seem redundant is because GLES 1/2 don't
* provide a way to query these properties. */ * provide a way to query these properties. */
CoglTexture2D * CoglTexture2D *
_cogl_egl_texture_2d_new_from_image (CoglContext *ctx, cogl_egl_texture_2d_new_from_image (CoglContext *ctx,
int width, int width,
int height, int height,
CoglPixelFormat format, CoglPixelFormat format,
@ -430,7 +430,7 @@ cogl_wayland_texture_2d_new_from_buffer (CoglContext *ctx,
EGL_WAYLAND_BUFFER_WL, EGL_WAYLAND_BUFFER_WL,
buffer, buffer,
NULL); NULL);
tex = _cogl_egl_texture_2d_new_from_image (ctx, tex = cogl_egl_texture_2d_new_from_image (ctx,
width, height, width, height,
internal_format, internal_format,
image, image,

View File

@ -40,6 +40,10 @@
#include "cogl-context.h" #include "cogl-context.h"
#include "cogl-bitmap.h" #include "cogl-bitmap.h"
#ifdef COGL_HAS_EGL_SUPPORT
#include "cogl-egl-defines.h"
#endif
COGL_BEGIN_DECLS COGL_BEGIN_DECLS
/** /**
@ -227,6 +231,19 @@ cogl_texture_2d_new_from_data (CoglContext *ctx,
CoglTexture2D * CoglTexture2D *
cogl_texture_2d_new_from_bitmap (CoglBitmap *bitmap); 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 COGL_END_DECLS
#endif /* __COGL_TEXTURE_2D_H */ #endif /* __COGL_TEXTURE_2D_H */

View File

@ -48,6 +48,7 @@
#include "cogl-texture-pixmap-x11-private.h" #include "cogl-texture-pixmap-x11-private.h"
#include "cogl-texture-2d-private.h" #include "cogl-texture-2d-private.h"
#include "cogl-texture-2d.h"
#include "cogl-error-private.h" #include "cogl-error-private.h"
#include "cogl-poll-private.h" #include "cogl-poll-private.h"
@ -741,7 +742,7 @@ _cogl_winsys_texture_pixmap_x11_create (CoglTexturePixmapX11 *tex_pixmap)
COGL_PIXEL_FORMAT_RGB_888); COGL_PIXEL_FORMAT_RGB_888);
egl_tex_pixmap->texture = COGL_TEXTURE ( egl_tex_pixmap->texture = COGL_TEXTURE (
_cogl_egl_texture_2d_new_from_image (ctx, cogl_egl_texture_2d_new_from_image (ctx,
tex->width, tex->width,
tex->height, tex->height,
texture_format, texture_format,