[mutter/wip/nielsdg/add-yuv-support: 2/2] WIP
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/nielsdg/add-yuv-support: 2/2] WIP
- Date: Tue, 4 Jun 2019 12:42:43 +0000 (UTC)
commit 681cdefc4c6f04933b3a1359aace223ecda155c8
Author: Niels De Graef <niels degraef barco com>
Date: Tue Jun 4 14:42:19 2019 +0200
WIP
cogl/cogl/cogl-pixel-format.c | 30 ++++++++++++++++++++++++++++++
cogl/cogl/cogl-pixel-format.h | 4 ++++
cogl/cogl/cogl-texture-2d.c | 5 +++++
cogl/cogl/cogl-texture-2d.h | 1 +
cogl/cogl/winsys/cogl-winsys-egl-x11.c | 1 +
src/wayland/meta-wayland-buffer.c | 3 +++
src/wayland/meta-wayland-dma-buf.c | 3 +++
7 files changed, 47 insertions(+)
---
diff --git a/cogl/cogl/cogl-pixel-format.c b/cogl/cogl/cogl-pixel-format.c
index 7f934d6a4..87c836290 100644
--- a/cogl/cogl/cogl-pixel-format.c
+++ b/cogl/cogl/cogl-pixel-format.c
@@ -35,6 +35,7 @@
#include <stdlib.h>
#include "cogl-pixel-format.h"
+#include "cogl-texture.h"
/* An entry to map CoglPixelFormats to their respective properties */
typedef struct _CoglPixelFormatInfo
@@ -748,3 +749,32 @@ cogl_pixel_format_to_string (CoglPixelFormat format)
g_assert_not_reached ();
}
+
+void
+cogl_pixel_format_get_cogl_components (CoglPixelFormat format,
+ guint *components_out)
+{
+ switch (format)
+ {
+ case COGL_PIXEL_FORMAT_NV12:
+ components_out[0] = COGL_TEXTURE_COMPONENTS_A;
+ components_out[1] = COGL_TEXTURE_COMPONENTS_RG;
+ break;
+ case COGL_PIXEL_FORMAT_NV21:
+ components_out[0] = COGL_TEXTURE_COMPONENTS_A;
+ components_out[1] = COGL_TEXTURE_COMPONENTS_RG;
+ break;
+ case COGL_PIXEL_FORMAT_YUV422:
+ components_out[0] = COGL_TEXTURE_COMPONENTS_A;
+ components_out[1] = COGL_TEXTURE_COMPONENTS_A;
+ components_out[2] = COGL_TEXTURE_COMPONENTS_A;
+ break;
+ case COGL_PIXEL_FORMAT_YUV444:
+ components_out[0] = COGL_TEXTURE_COMPONENTS_A;
+ components_out[1] = COGL_TEXTURE_COMPONENTS_A;
+ components_out[2] = COGL_TEXTURE_COMPONENTS_A;
+ break;
+ default:
+ components_out[0] = COGL_TEXTURE_COMPONENTS_RGBA;
+ }
+}
diff --git a/cogl/cogl/cogl-pixel-format.h b/cogl/cogl/cogl-pixel-format.h
index e1857f2ce..517bb2e96 100644
--- a/cogl/cogl/cogl-pixel-format.h
+++ b/cogl/cogl/cogl-pixel-format.h
@@ -397,6 +397,10 @@ cogl_pixel_format_get_bits_per_pixel (CoglPixelFormat format, guint *bpp_out);
const char *
cogl_pixel_format_to_string (CoglPixelFormat format);
+void
+cogl_pixel_format_get_cogl_components (CoglPixelFormat format,
+ guint *components_out);
+
G_END_DECLS
#endif /* __COGL_PIXEL_FORMAT_H__ */
diff --git a/cogl/cogl/cogl-texture-2d.c b/cogl/cogl/cogl-texture-2d.c
index 24fc426a7..7b559d60d 100644
--- a/cogl/cogl/cogl-texture-2d.c
+++ b/cogl/cogl/cogl-texture-2d.c
@@ -240,6 +240,7 @@ cogl_egl_texture_2d_new_from_image (CoglContext *ctx,
int width,
int height,
CoglPixelFormat format,
+ CoglTextureComponents components,
EGLImageKHR image,
CoglError **error)
{
@@ -264,6 +265,9 @@ cogl_egl_texture_2d_new_from_image (CoglContext *ctx,
tex = _cogl_texture_2d_create_base (ctx, width, height, format, loader);
+ /* Make sure we've set the right components before allocating */
+ cogl_texture_set_components (COGL_TEXTURE (tex), components);
+
if (!cogl_texture_allocate (COGL_TEXTURE (tex), error))
{
cogl_object_unref (tex);
@@ -434,6 +438,7 @@ cogl_wayland_texture_2d_new_from_buffer (CoglContext *ctx,
tex = cogl_egl_texture_2d_new_from_image (ctx,
width, height,
internal_format,
+ COGL_TEXTURE_COMPONENTS_RGBA,
image,
error);
_cogl_egl_destroy_image (ctx, image);
diff --git a/cogl/cogl/cogl-texture-2d.h b/cogl/cogl/cogl-texture-2d.h
index e649f24f7..f96e715b1 100644
--- a/cogl/cogl/cogl-texture-2d.h
+++ b/cogl/cogl/cogl-texture-2d.h
@@ -218,6 +218,7 @@ cogl_egl_texture_2d_new_from_image (CoglContext *ctx,
int width,
int height,
CoglPixelFormat format,
+ CoglTextureComponents components,
EGLImageKHR image,
CoglError **error);
diff --git a/cogl/cogl/winsys/cogl-winsys-egl-x11.c b/cogl/cogl/winsys/cogl-winsys-egl-x11.c
index 4f0a12543..ed07c7091 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->width,
tex->height,
texture_format,
+ COGL_TEXTURE_COMPONENTS_RGBA,
egl_tex_pixmap->image,
NULL));
diff --git a/src/wayland/meta-wayland-buffer.c b/src/wayland/meta-wayland-buffer.c
index 0a7c81f89..e208155bb 100644
--- a/src/wayland/meta-wayland-buffer.c
+++ b/src/wayland/meta-wayland-buffer.c
@@ -330,6 +330,7 @@ egl_image_buffer_attach (MetaWaylandBuffer *buffer,
EGLDisplay egl_display = cogl_egl_context_get_egl_display (cogl_context);
int format, width, height, y_inverted;
CoglPixelFormat cogl_format;
+ CoglTextureComponents components[3];
guint i, n_planes;
GPtrArray *planes;
@@ -387,6 +388,7 @@ egl_image_buffer_attach (MetaWaylandBuffer *buffer,
}
n_planes = cogl_pixel_format_get_n_planes (cogl_format);
+ cogl_pixel_format_get_cogl_components (cogl_format, components);
planes = g_ptr_array_new_full (n_planes, cogl_object_unref);
/* Each EGLImage is a plane in the final texture */
@@ -414,6 +416,7 @@ egl_image_buffer_attach (MetaWaylandBuffer *buffer,
texture_2d = cogl_egl_texture_2d_new_from_image (cogl_context,
width, height,
cogl_format,
+ components[i],
egl_img,
error);
diff --git a/src/wayland/meta-wayland-dma-buf.c b/src/wayland/meta-wayland-dma-buf.c
index 877cab736..4b497418d 100644
--- a/src/wayland/meta-wayland-dma-buf.c
+++ b/src/wayland/meta-wayland-dma-buf.c
@@ -211,6 +211,7 @@ meta_wayland_dma_buf_realize_texture (MetaWaylandBuffer *buffer,
EGLDisplay egl_display = cogl_egl_context_get_egl_display (cogl_context);
MetaWaylandDmaBufBuffer *dma_buf = buffer->dma_buf.dma_buf;
CoglPixelFormat cogl_format;
+ CoglTextureComponents components[3];
GPtrArray *planes;
guint i = 0, n_planes = 1;
@@ -227,6 +228,7 @@ meta_wayland_dma_buf_realize_texture (MetaWaylandBuffer *buffer,
}
n_planes = cogl_pixel_format_get_n_planes (cogl_format);
+ cogl_pixel_format_get_cogl_components (cogl_format, components);
planes = g_ptr_array_new_full (n_planes, cogl_object_unref);
/* Each EGLImage is a plane in the final CoglMultiPlaneTexture */
@@ -248,6 +250,7 @@ meta_wayland_dma_buf_realize_texture (MetaWaylandBuffer *buffer,
dma_buf->width,
dma_buf->height,
cogl_format,
+ components[i],
egl_img,
error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]