| From 5fdbcf3ea4b5f81b4aa7a03ff2bd130a6bb2a022 Mon Sep 17 00:00:00 2001 |
| From: Jia Rong <jia.rong@mediatek.com> |
| Date: Thu, 3 May 2018 09:06:15 +0800 |
| Subject: [PATCH] weston: add surface overlay assignment interface |
| |
| add surface overlay assignment interface |
| Test: OK |
| |
| Change-Id: I970797b6c3fe59567590639c2fe1e65784f296aa |
| Signed-off-by: Jia Rong <jia.rong@mediatek.com> |
| CR-Id: AUTO00016576 |
| --- |
| Makefile.am | 6 +- |
| clients/simple-configure-mtk.c | 17 +++++ |
| compositor/main.c | 6 ++ |
| libweston/compositor-drm.c | 6 ++ |
| libweston/compositor.h | 12 ++++ |
| libweston/weston-configure-mtk.c | 126 ++++++++++++++++++++++++++++++++++++++ |
| libweston/weston-configure-mtk.h | 54 ++++++++++++++++ |
| protocol/weston-configure-mtk.xml | 30 +++++++++ |
| 8 files changed, 256 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 576b4a1..cf92198 100644 |
| --- a/Makefile.am |
| +++ b/Makefile.am |
| @@ -108,6 +108,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 \ |
| @@ -666,7 +668,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/clients/simple-configure-mtk.c b/clients/simple-configure-mtk.c |
| index f94497e..8b146ff 100644 |
| --- a/clients/simple-configure-mtk.c |
| +++ b/clients/simple-configure-mtk.c |
| @@ -24,6 +24,7 @@ |
| #include "xdg-shell-unstable-v6-client-protocol.h" |
| #include "linux-dmabuf-unstable-v1-client-protocol.h" |
| #include "fullscreen-shell-unstable-v1-client-protocol.h" |
| +#include "weston-configure-mtk-client-protocol.h" |
| |
| #include <shared/platform.h> |
| |
| @@ -55,6 +56,7 @@ struct display { |
| struct wl_cursor *default_cursor; |
| struct wl_surface *cursor_surface; |
| struct window *window; |
| + struct config_switch *config_switch; |
| }; |
| |
| struct geometry { |
| @@ -92,6 +94,7 @@ struct window { |
| int fullscreen, opaque, buffer_size, overlay, format; |
| enum wl_output_transform transform; |
| int drm_card_fd; |
| + struct config_switch_set *switch_set; |
| }; |
| |
| struct img_texture { |
| @@ -591,6 +594,8 @@ create_surface(struct window *window) |
| display->cursor_surface = |
| wl_compositor_create_surface(display->compositor); |
| |
| + window->switch_set = config_switch_connect(display->config_switch, window->surface); |
| + |
| if (display->shell) { |
| window->xdg_surface = |
| zxdg_shell_v6_get_xdg_surface(display->shell, |
| @@ -991,6 +996,10 @@ registry_handle_global(void *data, struct wl_registry *registry, |
| d->dmabuf = wl_registry_bind(registry, name, |
| &zwp_linux_dmabuf_v1_interface, 1); |
| zwp_linux_dmabuf_v1_add_listener(d->dmabuf, &dmabuf_listener, d); |
| + } else if (strcmp(interface, "config_switch") == 0) { |
| + d->config_switch = |
| + wl_registry_bind(registry, name, |
| + &config_switch_interface, 1); |
| } |
| } |
| |
| @@ -1208,6 +1217,14 @@ main(int argc, char **argv) |
| fprintf(stderr, "error: fail to get drm_card_fd !\n"); |
| return -1; |
| } |
| + /* |
| + * setting sprite_switch = 0, indicate not walk overlay |
| + * setting sprite_switch = 1, indicate walk overlay |
| + */ |
| + if(window.overlay) |
| + config_switch_set_sprite_switch(window.switch_set, 1); |
| + else |
| + config_switch_set_sprite_switch(window.switch_set, 0); |
| |
| sigint.sa_handler = signal_int; |
| sigemptyset(&sigint.sa_mask); |
| diff --git a/compositor/main.c b/compositor/main.c |
| index 72c3cd1..5a8fd55 100644 |
| --- a/compositor/main.c |
| +++ b/compositor/main.c |
| @@ -56,6 +56,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" |
| @@ -1879,6 +1880,11 @@ int main(int argc, char *argv[]) |
| |
| weston_pending_output_coldplug(ec); |
| |
| + if (config_switch_global_create(ec) < 0) { |
| + weston_log("fatal: failed to config_switch_global_create\n"); |
| + goto out; |
| + } |
| + |
| catch_signals(); |
| segv_compositor = ec; |
| |
| diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c |
| index 064d8c2..b5b103b 100644 |
| --- a/libweston/compositor-drm.c |
| +++ b/libweston/compositor-drm.c |
| @@ -2753,6 +2753,12 @@ drm_output_prepare_overlay_view(struct drm_output_state *output_state, |
| uint32_t format; |
| wl_fixed_t sx1, sy1, sx2, sy2; |
| |
| + /* |
| + * if switch controlled by client is off, then return. |
| + */ |
| + if ((!ev->surface->config_switch)||(!ev->surface->config_switch->sprites_switch)) |
| + return NULL; |
| + |
| if (b->sprites_are_broken) |
| return NULL; |
| |
| diff --git a/libweston/compositor.h b/libweston/compositor.h |
| index dea88dc..6470173 100644 |
| --- a/libweston/compositor.h |
| +++ b/libweston/compositor.h |
| @@ -1141,6 +1141,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; |
| @@ -1262,6 +1272,8 @@ 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,126 @@ |
| +#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,54 @@ |
| +/* |
| + * 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 |
| + |
| diff --git a/protocol/weston-configure-mtk.xml b/protocol/weston-configure-mtk.xml |
| index e19a2ad..120e904 100644 |
| --- a/protocol/weston-configure-mtk.xml |
| +++ b/protocol/weston-configure-mtk.xml |
| @@ -33,5 +33,35 @@ |
| </event> |
| </interface> |
| |
| + <interface name="config_switch_set" version="1"> |
| + <description summary="app interface for setting configure for the surface"/> |
| + |
| + <request name="sprite_switch"> |
| + <description summary="setting the surface configure"> |
| + This set view matched with the surface to show in overlay plane if |
| + overlay planes are available.Otherwise, it walk primary plane to |
| + render, and then send to drm to show. |
| + </description> |
| + <arg name="sprite_switch" type="int"/> |
| + </request> |
| + </interface> |
| + |
| + <interface name="config_switch" version="1"> |
| + <description summary="create app configure path for setting parameter"> |
| + This interface is exposed as a global singleton. |
| + This interface is implemented by server, it mainly provide channel to allow |
| + client to control some properties. |
| + </description> |
| + |
| + <request name="connect"> |
| + <description summary="connect to server for setting parameter"> |
| + This request gives client way to connect server.In fact, parameters set by |
| + app all through wl_surface because this is only way can be transmit by app. |
| + </description> |
| + <arg name="surface" type="object" interface="wl_surface" allow-null="true"/> |
| + <arg name="id" type="new_id" interface="config_switch_set"/> |
| + </request> |
| + </interface> |
| + |
| </protocol> |
| |
| -- |
| 1.9.1 |
| |