[mutter/wip/nielsdg/add-yuv-support: 28/28] WIP
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/nielsdg/add-yuv-support: 28/28] WIP
- Date: Mon, 26 Nov 2018 14:41:11 +0000 (UTC)
commit 554eb50b0a2f1735c9b10456f3d8f6d1d3916e90
Author: Niels De Graef <Niels DeGraef barco com>
Date: Mon Nov 26 15:40:47 2018 +0100
WIP
cogl/cogl/cogl-types.h | 11 +++++++
cogl/cogl/cogl.c | 63 +++++++++++++++++++++++++++++++++++++++
src/wayland/meta-wayland-buffer.c | 38 +++++++++++++++--------
3 files changed, 100 insertions(+), 12 deletions(-)
---
diff --git a/cogl/cogl/cogl-types.h b/cogl/cogl/cogl-types.h
index 7e3c2a971..ef9179ef0 100644
--- a/cogl/cogl/cogl-types.h
+++ b/cogl/cogl/cogl-types.h
@@ -408,6 +408,7 @@ typedef enum { /*< prefix=COGL_PIXEL_FORMAT >*/
/**
* cogl_pixel_format_get_n_planes:
+ * @format: The format for which to get the number of planes
*
* Returns the number of planes the given CoglPixelFormat specifies.
*/
@@ -416,6 +417,7 @@ cogl_pixel_format_get_n_planes (CoglPixelFormat format);
/**
* cogl_pixel_format_get_subsampling_factors:
+ * @format: The format to get the subsampling factors from.
*
* Returns the subsampling in both the horizontal as the vertical direction.
*/
@@ -424,6 +426,15 @@ cogl_pixel_format_get_subsampling_factors (CoglPixelFormat format,
guint *horizontal_factors,
guint *vertical_factors);
+/**
+ * cogl_pixel_format_get_components:
+ *
+ * XXX make some comments here about (consistently) uploading multiple textures
+ */
+void
+cogl_pixel_format_get_texture_components (CoglPixelFormat format,
+ CoglTextureComponents *components_out);
+
/**
* CoglFeatureFlags:
* @COGL_FEATURE_TEXTURE_RECTANGLE: ARB_texture_rectangle support
diff --git a/cogl/cogl/cogl.c b/cogl/cogl/cogl.c
index 964026180..653200b73 100644
--- a/cogl/cogl/cogl.c
+++ b/cogl/cogl/cogl.c
@@ -939,3 +939,66 @@ cogl_pixel_format_get_subsampling_factors (CoglPixelFormat format,
break;
}
}
+
+void
+cogl_pixel_format_get_texture_components (CoglPixelFormat format,
+ CoglTextureComponents *components_out)
+{
+ /* Check for Pre-YUV formats */
+ if (format & 0xf000)
+ {
+ switch (format)
+ {
+ /* 2 planes */
+ case COGL_PIXEL_FORMAT_NV12:
+ case COGL_PIXEL_FORMAT_NV21:
+ components_out[0] = COGL_TEXTURE_COMPONENTS_R;
+ components_out[1] = COGL_TEXTURE_COMPONENTS_RG;
+ break;
+
+ /* XXX TODO */
+ /* case COGL_PIXEL_FORMAT_XRGB88888_A8: */
+ /* case COGL_PIXEL_FORMAT_XBGR88888_A8: */
+ /* case COGL_PIXEL_FORMAT_RGBX88888_A8: */
+ /* case COGL_PIXEL_FORMAT_BGRX88888_A8: */
+ /* case COGL_PIXEL_FORMAT_RGB888_A8: */
+ /* case COGL_PIXEL_FORMAT_BGR888_A8: */
+ /* case COGL_PIXEL_FORMAT_RGB565_A8: */
+ /* case COGL_PIXEL_FORMAT_BGR565_A8: */
+
+ /* /1* 3 planes *1/ */
+ /* case COGL_PIXEL_FORMAT_YUV410: */
+ /* case COGL_PIXEL_FORMAT_YVU410: */
+ /* case COGL_PIXEL_FORMAT_YUV411: */
+ /* case COGL_PIXEL_FORMAT_YVU411: */
+ /* case COGL_PIXEL_FORMAT_YUV420: */
+ /* case COGL_PIXEL_FORMAT_YVU420: */
+ /* case COGL_PIXEL_FORMAT_YUV422: */
+ /* case COGL_PIXEL_FORMAT_YVU422: */
+ /* case COGL_PIXEL_FORMAT_YUV444: */
+ /* case COGL_PIXEL_FORMAT_YVU444: */
+
+ default:
+ /* XXX At this point, we might crash 'n burn */
+ g_assert_not_reached ();
+ components_out[0] = COGL_TEXTURE_COMPONENTS_RGB;
+ break;
+ }
+ }
+ else
+ {
+ if (format == COGL_PIXEL_FORMAT_ANY)
+ format = COGL_PIXEL_FORMAT_RGBA_8888_PRE;
+
+ if (format == COGL_PIXEL_FORMAT_A_8)
+ components_out[0] = COGL_TEXTURE_COMPONENTS_A;
+ else if (format == COGL_PIXEL_FORMAT_RG_88)
+ components_out[0] = COGL_TEXTURE_COMPONENTS_RG;
+ else if (format & COGL_DEPTH_BIT)
+ components_out[0] = COGL_TEXTURE_COMPONENTS_DEPTH;
+ else if (format & COGL_A_BIT)
+ components_out[0] = COGL_TEXTURE_COMPONENTS_RGBA;
+ else
+ components_out[0] = COGL_TEXTURE_COMPONENTS_RGB;
+ }
+}
diff --git a/src/wayland/meta-wayland-buffer.c b/src/wayland/meta-wayland-buffer.c
index 263826151..5360fab7d 100644
--- a/src/wayland/meta-wayland-buffer.c
+++ b/src/wayland/meta-wayland-buffer.c
@@ -171,10 +171,11 @@ shm_buffer_get_cogl_pixel_format (struct wl_shm_buffer *shm_buffer,
#if G_BYTE_ORDER == G_BIG_ENDIAN
case WL_SHM_FORMAT_ARGB8888:
format = COGL_PIXEL_FORMAT_ARGB_8888_PRE;
+ components[0] = COGL_TEXTURE_COMPONENTS_RGBA;
break;
case WL_SHM_FORMAT_XRGB8888:
format = COGL_PIXEL_FORMAT_ARGB_8888;
- components = COGL_TEXTURE_COMPONENTS_RGB;
+ components[0] = COGL_TEXTURE_COMPONENTS_RGB;
break;
#elif G_BYTE_ORDER == G_LITTLE_ENDIAN
case WL_SHM_FORMAT_ARGB8888:
@@ -182,27 +183,42 @@ shm_buffer_get_cogl_pixel_format (struct wl_shm_buffer *shm_buffer,
break;
case WL_SHM_FORMAT_XRGB8888:
format = COGL_PIXEL_FORMAT_BGRA_8888;
- components = COGL_TEXTURE_COMPONENTS_RGB;
+ components[0] = COGL_TEXTURE_COMPONENTS_RGB;
break;
#endif
case WL_SHM_FORMAT_NV12:
format = COGL_PIXEL_FORMAT_NV12;
- g_warning ("FORMAT IS NV12");
+ components[0] = COGL_TEXTURE_COMPONENTS_A;
+ components[1] = COGL_TEXTURE_COMPONENTS_RG;
break;
case WL_SHM_FORMAT_NV21:
- g_warning ("FORMAT IS NV21");
+ format = COGL_PIXEL_FORMAT_NV21;
+ components[0] = COGL_TEXTURE_COMPONENTS_A;
+ components[1] = COGL_TEXTURE_COMPONENTS_RG;
break;
case WL_SHM_FORMAT_YUV422:
- g_warning ("FORMAT IS YUV422");
+ format = COGL_PIXEL_FORMAT_YUV422;
+ components[0] = COGL_TEXTURE_COMPONENTS_A;
+ components[1] = COGL_TEXTURE_COMPONENTS_A;
+ components[2] = COGL_TEXTURE_COMPONENTS_A;
break;
case WL_SHM_FORMAT_YVU422:
- g_warning ("FORMAT IS YVU422");
+ format = COGL_PIXEL_FORMAT_YVU422;
+ components[0] = COGL_TEXTURE_COMPONENTS_A;
+ components[1] = COGL_TEXTURE_COMPONENTS_A;
+ components[2] = COGL_TEXTURE_COMPONENTS_A;
break;
case WL_SHM_FORMAT_YUV444:
- g_warning ("FORMAT IS YUV444");
+ format = COGL_PIXEL_FORMAT_YUV444;
+ components[0] = COGL_TEXTURE_COMPONENTS_A;
+ components[1] = COGL_TEXTURE_COMPONENTS_A;
+ components[2] = COGL_TEXTURE_COMPONENTS_A;
break;
case WL_SHM_FORMAT_YVU444:
- g_warning ("FORMAT IS YVU444");
+ format = COGL_PIXEL_FORMAT_YVU444;
+ components[0] = COGL_TEXTURE_COMPONENTS_A;
+ components[1] = COGL_TEXTURE_COMPONENTS_A;
+ components[2] = COGL_TEXTURE_COMPONENTS_A;
break;
default:
@@ -212,8 +228,6 @@ shm_buffer_get_cogl_pixel_format (struct wl_shm_buffer *shm_buffer,
if (format_out)
*format_out = format;
- if (components_out)
- *components_out = components;
}
static gboolean
@@ -226,7 +240,7 @@ shm_buffer_attach (MetaWaylandBuffer *buffer,
struct wl_shm_buffer *shm_buffer;
int stride, width, height;
CoglPixelFormat format;
- CoglTextureComponents components;
+ CoglTextureComponents components[3];
guint i, n_planes;
guint h_factors[3], v_factors[3];
gsize offset = 0;
@@ -274,7 +288,7 @@ shm_buffer_attach (MetaWaylandBuffer *buffer,
g_assert (bitmap);
plane = COGL_TEXTURE (cogl_texture_2d_new_from_bitmap (bitmap));
- cogl_texture_set_components (COGL_TEXTURE (plane), components);
+ cogl_texture_set_components (COGL_TEXTURE (plane), components[i]);
cogl_object_unref (bitmap);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]