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

View File

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

View File

@ -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 */

View File

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