1From f9c928db24c24031e01129e20226da1f7c3ec2ed Mon Sep 17 00:00:00 2001
2From: Jeffy Chen <jeffy.chen@rock-chips.com>
3Date: Fri, 3 Jul 2020 14:23:45 +0800
4Subject: [PATCH 17/79] pixman-renderer: Support yuv formats
5
6Support yuy2/yv12/i420/nv12/nv16.
7
8Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
9---
10 libweston/pixel-formats.c | 11 +++++++++++
11 meson.build               | 10 ++++++++++
12 2 files changed, 21 insertions(+)
13
14diff --git a/libweston/pixel-formats.c b/libweston/pixel-formats.c
15index 9064cb6..172e6cc 100644
16--- a/libweston/pixel-formats.c
17+++ b/libweston/pixel-formats.c
18@@ -337,6 +337,7 @@ static const struct pixel_format_info pixel_format_table[] = {
19 		SAMPLER_TYPE(EGL_TEXTURE_Y_XUXV_WL),
20 		.num_planes = 1,
21 		.hsub = 2,
22+		PIXMAN_FMT(yuy2),
23 	},
24 	{
25 		DRM_FORMAT(YVYU),
26@@ -366,6 +367,9 @@ static const struct pixel_format_info pixel_format_table[] = {
27 		.num_planes = 2,
28 		.hsub = 2,
29 		.vsub = 2,
30+#ifdef HAVE_PIXMAN_NV12
31+		PIXMAN_FMT(nv12),
32+#endif
33 	},
34 	{
35 		DRM_FORMAT(NV21),
36@@ -381,6 +385,9 @@ static const struct pixel_format_info pixel_format_table[] = {
37 		.num_planes = 2,
38 		.hsub = 2,
39 		.vsub = 1,
40+#ifdef HAVE_PIXMAN_NV16
41+		PIXMAN_FMT(nv16),
42+#endif
43 	},
44 	{
45 		DRM_FORMAT(NV61),
46@@ -437,6 +444,9 @@ static const struct pixel_format_info pixel_format_table[] = {
47 		.num_planes = 3,
48 		.hsub = 2,
49 		.vsub = 2,
50+#ifdef HAVE_PIXMAN_I420
51+		PIXMAN_FMT(i420),
52+#endif
53 	},
54 	{
55 		DRM_FORMAT(YVU420),
56@@ -445,6 +455,7 @@ static const struct pixel_format_info pixel_format_table[] = {
57 		.chroma_order = ORDER_VU,
58 		.hsub = 2,
59 		.vsub = 2,
60+		PIXMAN_FMT(yv12),
61 	},
62 	{
63 		DRM_FORMAT(YUV422),
64diff --git a/meson.build b/meson.build
65index feecd45..b8efc3b 100644
66--- a/meson.build
67+++ b/meson.build
68@@ -161,6 +161,16 @@ dep_libdrm = dependency('libdrm', version: '>= 2.4.95')
69 dep_libdrm_headers = dep_libdrm.partial_dependency(compile_args: true)
70 dep_threads = dependency('threads')
71
72+if cc.has_header_symbol('pixman.h', 'PIXMAN_nv12', dependencies : dep_pixman)
73+  config_h.set('HAVE_PIXMAN_NV12', 1)
74+endif
75+if cc.has_header_symbol('pixman.h', 'PIXMAN_i420', dependencies : dep_pixman)
76+  config_h.set('HAVE_PIXMAN_I420', 1)
77+endif
78+if cc.has_header_symbol('pixman.h', 'PIXMAN_nv16', dependencies : dep_pixman)
79+  config_h.set('HAVE_PIXMAN_NV16', 1)
80+endif
81+
82 dep_libdrm_version = dep_libdrm.version()
83 if dep_libdrm_version.version_compare('>=2.4.107')
84   message('Found libdrm with human format modifier support.')
85--
862.20.1
87
88