blob: 063dba6fa864c2d4406ea289291d5aeccea13b4a [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001From 949565b2683a3a67060698132a52ea26c75d9952 Mon Sep 17 00:00:00 2001
2From: Qian Hu <Qian.Hu@mediatek.com>
3Date: Tue, 24 Sep 2019 15:01:45 +0800
4Subject: [PATCH 8/8] [PATCH] weston: add surface overlay assignment interface
5
6add surface overlay assignment interface
7
8Signed-off-by: Qian Hu <Qian.Hu@mediatek.com>
9---
10 Makefile.am | 6 +-
11 compositor/main.c | 1 +
12 libweston/compositor.h | 11 ++++
13 libweston/weston-configure-mtk.c | 126 +++++++++++++++++++++++++++++++++++++++
14 libweston/weston-configure-mtk.h | 54 +++++++++++++++++
15 5 files changed, 197 insertions(+), 1 deletion(-)
16 create mode 100644 libweston/weston-configure-mtk.c
17 create mode 100644 libweston/weston-configure-mtk.h
18
19diff --git a/Makefile.am b/Makefile.am
20index 7efa5a0..008bdfe 100644
21--- a/Makefile.am
22+++ b/Makefile.am
23@@ -97,6 +97,8 @@ libweston_@LIBWESTON_MAJOR@_la_SOURCES = \
24 libweston/pixel-formats.c \
25 libweston/pixel-formats.h \
26 libweston/weston-screenshooter-mtk.c \
27+ libweston/weston-configure-mtk.c \
28+ libweston/weston-configure-mtk.h \
29 shared/helpers.h \
30 shared/matrix.c \
31 shared/matrix.h \
32@@ -677,7 +679,9 @@ nodist_weston_simple_configure_mtk_SOURCES = \
33 protocol/fullscreen-shell-unstable-v1-protocol.c \
34 protocol/fullscreen-shell-unstable-v1-client-protocol.h \
35 protocol/linux-dmabuf-unstable-v1-protocol.c \
36- protocol/linux-dmabuf-unstable-v1-client-protocol.h
37+ protocol/linux-dmabuf-unstable-v1-client-protocol.h \
38+ protocol/weston-configure-mtk-protocol.c \
39+ protocol/weston-configure-mtk-client-protocol.h
40 weston_simple_configure_mtk_CFLAGS = $(AM_CFLAGS) $(CLIENT_CFLAGS)
41 weston_simple_configure_mtk_LDADD = $(EGL_LIBS) $(LIBDRM_LIBS) libtoytoolkit.la
42 BUILT_SOURCES += protocol/linux-dmabuf-unstable-v1-client-protocol.h
43diff --git a/compositor/main.c b/compositor/main.c
44index b5b4fc5..21c501c 100644
45--- a/compositor/main.c
46+++ b/compositor/main.c
47@@ -52,6 +52,7 @@
48 #include "git-version.h"
49 #include "version.h"
50 #include "weston.h"
51+#include "../libweston/weston-configure-mtk.h"
52
53 #include "compositor-drm.h"
54 #include "compositor-headless.h"
55diff --git a/libweston/compositor.h b/libweston/compositor.h
56index 8736691..ba577b7 100644
57--- a/libweston/compositor.h
58+++ b/libweston/compositor.h
59@@ -1362,6 +1362,16 @@ struct weston_surface_state {
60 struct weston_buffer_viewport buffer_viewport;
61 };
62
63+/*
64+ * For setting whether the views on this surface walk
65+ * overlay path; on==>1, off==>0
66+*/
67+struct config_switch{
68+ struct wl_resource *resource;
69+ void *private;
70+ int sprites_switch;
71+};
72+
73 struct weston_surface_activation_data {
74 struct weston_surface *surface;
75 struct weston_seat *seat;
76@@ -1483,6 +1493,7 @@ struct weston_surface {
77
78 /* An list of per seat pointer constraints. */
79 struct wl_list pointer_constraints;
80+ struct config_switch *config_switch;
81 };
82
83 struct weston_subsurface {
84diff --git a/libweston/weston-configure-mtk.c b/libweston/weston-configure-mtk.c
85new file mode 100644
86index 0000000..185f91c
87--- /dev/null
88+++ b/libweston/weston-configure-mtk.c
89@@ -0,0 +1,126 @@
90+#include "config.h"
91+#include <fcntl.h>
92+#include <stdio.h>
93+#include <string.h>
94+#include <stdlib.h>
95+#include <stdint.h>
96+#include <limits.h>
97+#include <stdarg.h>
98+#include <assert.h>
99+#include <sys/ioctl.h>
100+#include <sys/mman.h>
101+#include <sys/wait.h>
102+#include <sys/socket.h>
103+#include <sys/utsname.h>
104+#include <sys/stat.h>
105+#include <unistd.h>
106+#include <math.h>
107+#include <linux/input.h>
108+#include <dlfcn.h>
109+#include <signal.h>
110+#include <setjmp.h>
111+#include <sys/time.h>
112+#include <time.h>
113+#include <errno.h>
114+
115+#include "timeline.h"
116+
117+#include "compositor.h"
118+//#include "scaler-server-protocol.h"
119+#include "shared/helpers.h"
120+#include "shared/os-compatibility.h"
121+#include "shared/timespec-util.h"
122+#include "git-version.h"
123+#include "version.h"
124+
125+#include "weston-configure-mtk.h"
126+#include "weston-configure-mtk-server-protocol.h"
127+
128+static void
129+config_set_sprite_switch(struct wl_client *client,
130+ struct wl_resource *resource,
131+ int32_t spr_switch)
132+{
133+ struct config_switch *configure = wl_resource_get_user_data(resource);
134+
135+ configure->sprites_switch = spr_switch;
136+}
137+
138+static const struct config_switch_set_interface switch_set_interface = {
139+ config_set_sprite_switch,
140+};
141+
142+static struct config_switch *
143+config_interface_create(struct weston_surface *surface)
144+{
145+ struct config_switch *config_switch;
146+
147+ config_switch = zalloc(sizeof *config_switch);
148+ if (config_switch == NULL)
149+ return NULL;
150+
151+ config_switch->private = (void *)surface;
152+ surface->config_switch = config_switch;
153+
154+ return config_switch;
155+}
156+
157+static void
158+config_switch_connect(struct wl_client *client, struct wl_resource *resource,
159+ struct wl_resource *wl_surface, uint32_t id)
160+{
161+ struct config_switch *config_switch = wl_resource_get_user_data(resource);
162+ struct weston_surface *surface = wl_resource_get_user_data(wl_surface);
163+
164+ config_switch = config_interface_create(surface);
165+ if (config_switch == NULL) {
166+ wl_resource_post_no_memory(resource);
167+ return;
168+ }
169+
170+ config_switch->resource =
171+ wl_resource_create(client, &config_switch_set_interface,
172+ wl_resource_get_version(resource), id);
173+ if (config_switch->resource == NULL) {
174+ wl_resource_post_no_memory(resource);
175+ return;
176+ }
177+ wl_resource_set_implementation(config_switch->resource, &switch_set_interface,
178+ config_switch, NULL);
179+}
180+
181+static const struct config_switch_interface switch_interface = {
182+ config_switch_connect,
183+};
184+
185+static void
186+bind_config_switch(struct wl_client *client,
187+ void *data, uint32_t version, uint32_t id)
188+{
189+ struct weston_compositor *compositor = data;
190+ struct wl_resource *resource;
191+
192+ resource = wl_resource_create(client, &config_switch_interface,
193+ MIN(version, 1), id);
194+ if (resource == NULL) {
195+ wl_client_post_no_memory(client);
196+ return;
197+ }
198+
199+ wl_resource_set_implementation(resource, &switch_interface,
200+ compositor, NULL);
201+}
202+
203+WL_EXPORT int
204+config_switch_global_create(struct weston_compositor *ec)
205+{
206+ if(!ec)
207+ return -1;
208+ if (!wl_global_create(ec->wl_display, &config_switch_interface, 1,
209+ ec, bind_config_switch)){
210+ fprintf(stderr, "error: failed to config_switch_global_create: %s\n", dlerror());
211+ return -1;
212+ }
213+ return 0;
214+}
215+
216diff --git a/libweston/weston-configure-mtk.h b/libweston/weston-configure-mtk.h
217new file mode 100644
218index 0000000..0f093fe
219--- /dev/null
220+++ b/libweston/weston-configure-mtk.h
221@@ -0,0 +1,54 @@
222+/*
223+ * Copyright © 2008-2011 Kristian Høgsberg
224+ * Copyright © 2012 Collabora, Ltd.
225+ *
226+ * Permission is hereby granted, free of charge, to any person obtaining
227+ * a copy of this software and associated documentation files (the
228+ * "Software"), to deal in the Software without restriction, including
229+ * without limitation the rights to use, copy, modify, merge, publish,
230+ * distribute, sublicense, and/or sell copies of the Software, and to
231+ * permit persons to whom the Software is furnished to do so, subject to
232+ * the following conditions:
233+ *
234+ * The above copyright notice and this permission notice (including the
235+ * next paragraph) shall be included in all copies or substantial
236+ * portions of the Software.
237+ *
238+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
239+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
240+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
241+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
242+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
243+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
244+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
245+ * SOFTWARE.
246+ */
247+
248+#ifndef _APP_CONFIGURE_EXTENSION_H_
249+#define _APP_CONFIGURE_EXTENSION_H_
250+
251+#ifdef __cplusplus
252+extern "C" {
253+#endif
254+
255+#include <stdbool.h>
256+#include <time.h>
257+#include <pixman.h>
258+#include <xkbcommon/xkbcommon.h>
259+
260+#include <wayland-server.h>
261+
262+#include "version.h"
263+#include "matrix.h"
264+#include "config-parser.h"
265+#include "zalloc.h"
266+#include "timeline-object.h"
267+
268+int config_switch_global_create(struct weston_compositor *ec);
269+
270+#ifdef __cplusplus
271+}
272+#endif
273+
274+#endif
275+
276--
2772.6.4
278