blob: ad8562ce270485f3217b0ecdc7b7b49b0ea26745 [file] [log] [blame]
From 949565b2683a3a67060698132a52ea26c75d9952 Mon Sep 17 00:00:00 2001
From: Qian Hu <Qian.Hu@mediatek.com>
Date: Tue, 24 Sep 2019 15:01:45 +0800
Subject: [PATCH 8/8] [PATCH] weston: add surface overlay assignment interface
add surface overlay assignment interface
Signed-off-by: Qian Hu <Qian.Hu@mediatek.com>
---
Makefile.am | 6 +-
compositor/main.c | 1 +
libweston/compositor.h | 11 ++++
libweston/weston-configure-mtk.c | 126 +++++++++++++++++++++++++++++++++++++++
libweston/weston-configure-mtk.h | 54 +++++++++++++++++
5 files changed, 197 insertions(+), 1 deletion(-)
create mode 100644 libweston/weston-configure-mtk.c
create mode 100644 libweston/weston-configure-mtk.h
diff --git a/Makefile.am b/Makefile.am
index 7efa5a0..008bdfe 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -97,6 +97,8 @@ libweston_@LIBWESTON_MAJOR@_la_SOURCES = \
libweston/pixel-formats.c \
libweston/pixel-formats.h \
libweston/weston-screenshooter-mtk.c \
+ libweston/weston-configure-mtk.c \
+ libweston/weston-configure-mtk.h \
shared/helpers.h \
shared/matrix.c \
shared/matrix.h \
@@ -677,7 +679,9 @@ nodist_weston_simple_configure_mtk_SOURCES = \
protocol/fullscreen-shell-unstable-v1-protocol.c \
protocol/fullscreen-shell-unstable-v1-client-protocol.h \
protocol/linux-dmabuf-unstable-v1-protocol.c \
- protocol/linux-dmabuf-unstable-v1-client-protocol.h
+ protocol/linux-dmabuf-unstable-v1-client-protocol.h \
+ protocol/weston-configure-mtk-protocol.c \
+ protocol/weston-configure-mtk-client-protocol.h
weston_simple_configure_mtk_CFLAGS = $(AM_CFLAGS) $(CLIENT_CFLAGS)
weston_simple_configure_mtk_LDADD = $(EGL_LIBS) $(LIBDRM_LIBS) libtoytoolkit.la
BUILT_SOURCES += protocol/linux-dmabuf-unstable-v1-client-protocol.h
diff --git a/compositor/main.c b/compositor/main.c
index b5b4fc5..21c501c 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -52,6 +52,7 @@
#include "git-version.h"
#include "version.h"
#include "weston.h"
+#include "../libweston/weston-configure-mtk.h"
#include "compositor-drm.h"
#include "compositor-headless.h"
diff --git a/libweston/compositor.h b/libweston/compositor.h
index 8736691..ba577b7 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -1362,6 +1362,16 @@ struct weston_surface_state {
struct weston_buffer_viewport buffer_viewport;
};
+/*
+ * For setting whether the views on this surface walk
+ * overlay path; on==>1, off==>0
+*/
+struct config_switch{
+ struct wl_resource *resource;
+ void *private;
+ int sprites_switch;
+};
+
struct weston_surface_activation_data {
struct weston_surface *surface;
struct weston_seat *seat;
@@ -1483,6 +1493,7 @@ struct weston_surface {
/* An list of per seat pointer constraints. */
struct wl_list pointer_constraints;
+ struct config_switch *config_switch;
};
struct weston_subsurface {
diff --git a/libweston/weston-configure-mtk.c b/libweston/weston-configure-mtk.c
new file mode 100644
index 0000000..185f91c
--- /dev/null
+++ b/libweston/weston-configure-mtk.c
@@ -0,0 +1,125 @@
+#include "config.h"
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <assert.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+#include <sys/socket.h>
+#include <sys/utsname.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <math.h>
+#include <linux/input.h>
+#include <dlfcn.h>
+#include <signal.h>
+#include <setjmp.h>
+#include <sys/time.h>
+#include <time.h>
+#include <errno.h>
+
+#include "timeline.h"
+
+#include "compositor.h"
+//#include "scaler-server-protocol.h"
+#include "shared/helpers.h"
+#include "shared/os-compatibility.h"
+#include "shared/timespec-util.h"
+#include "git-version.h"
+#include "version.h"
+
+#include "weston-configure-mtk.h"
+#include "weston-configure-mtk-server-protocol.h"
+
+static void
+config_set_sprite_switch(struct wl_client *client,
+ struct wl_resource *resource,
+ int32_t spr_switch)
+{
+ struct config_switch *configure = wl_resource_get_user_data(resource);
+
+ configure->sprites_switch = spr_switch;
+}
+
+static const struct config_switch_set_interface switch_set_interface = {
+ config_set_sprite_switch,
+};
+
+static struct config_switch *
+config_interface_create(struct weston_surface *surface)
+{
+ struct config_switch *config_switch;
+
+ config_switch = zalloc(sizeof *config_switch);
+ if (config_switch == NULL)
+ return NULL;
+
+ config_switch->private = (void *)surface;
+ surface->config_switch = config_switch;
+
+ return config_switch;
+}
+
+static void
+config_switch_connect(struct wl_client *client, struct wl_resource *resource,
+ struct wl_resource *wl_surface, uint32_t id)
+{
+ struct config_switch *config_switch = wl_resource_get_user_data(resource);
+ struct weston_surface *surface = wl_resource_get_user_data(wl_surface);
+
+ config_switch = config_interface_create(surface);
+ if (config_switch == NULL) {
+ wl_resource_post_no_memory(resource);
+ return;
+ }
+
+ config_switch->resource =
+ wl_resource_create(client, &config_switch_set_interface,
+ wl_resource_get_version(resource), id);
+ if (config_switch->resource == NULL) {
+ wl_resource_post_no_memory(resource);
+ return;
+ }
+ wl_resource_set_implementation(config_switch->resource, &switch_set_interface,
+ config_switch, NULL);
+}
+
+static const struct config_switch_interface switch_interface = {
+ config_switch_connect,
+};
+
+static void
+bind_config_switch(struct wl_client *client,
+ void *data, uint32_t version, uint32_t id)
+{
+ struct weston_compositor *compositor = data;
+ struct wl_resource *resource;
+
+ resource = wl_resource_create(client, &config_switch_interface,
+ MIN(version, 1), id);
+ if (resource == NULL) {
+ wl_client_post_no_memory(client);
+ return;
+ }
+
+ wl_resource_set_implementation(resource, &switch_interface,
+ compositor, NULL);
+}
+
+WL_EXPORT int
+config_switch_global_create(struct weston_compositor *ec)
+{
+ if(!ec)
+ return -1;
+ if (!wl_global_create(ec->wl_display, &config_switch_interface, 1,
+ ec, bind_config_switch)){
+ fprintf(stderr, "error: failed to config_switch_global_create: %s\n", dlerror());
+ return -1;
+ }
+ return 0;
+}
diff --git a/libweston/weston-configure-mtk.h b/libweston/weston-configure-mtk.h
new file mode 100644
index 0000000..0f093fe
--- /dev/null
+++ b/libweston/weston-configure-mtk.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright © 2008-2011 Kristian Høgsberg
+ * Copyright © 2012 Collabora, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef _APP_CONFIGURE_EXTENSION_H_
+#define _APP_CONFIGURE_EXTENSION_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdbool.h>
+#include <time.h>
+#include <pixman.h>
+#include <xkbcommon/xkbcommon.h>
+
+#include <wayland-server.h>
+
+#include "version.h"
+#include "matrix.h"
+#include "config-parser.h"
+#include "zalloc.h"
+#include "timeline-object.h"
+
+int config_switch_global_create(struct weston_compositor *ec);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--
2.6.4