1*4882a593SmuzhiyunFrom 8950431969fd75d6c6aa349a0eed489fe999dfc8 Mon Sep 17 00:00:00 2001
2*4882a593SmuzhiyunFrom: Jeffy Chen <jeffy.chen@rock-chips.com>
3*4882a593SmuzhiyunDate: Wed, 1 Jun 2022 11:28:24 +0800
4*4882a593SmuzhiyunSubject: [PATCH 68/93] desktop-shell: Delay locking when having pending
5*4882a593Smuzhiyun fade-out animations
6*4882a593Smuzhiyun
7*4882a593SmuzhiyunAvoid "unexpectedly large timestamp jump" warning when resuming with
8*4882a593Smuzhiyunmulti-head.
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunSigned-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
11*4882a593Smuzhiyun---
12*4882a593Smuzhiyun desktop-shell/shell.c         | 14 +++++++++++++-
13*4882a593Smuzhiyun include/libweston/libweston.h |  1 +
14*4882a593Smuzhiyun 2 files changed, 14 insertions(+), 1 deletion(-)
15*4882a593Smuzhiyun
16*4882a593Smuzhiyundiff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
17*4882a593Smuzhiyunindex ff85ff7..2e88b99 100644
18*4882a593Smuzhiyun--- a/desktop-shell/shell.c
19*4882a593Smuzhiyun+++ b/desktop-shell/shell.c
20*4882a593Smuzhiyun@@ -3580,18 +3580,24 @@ shell_fade_done_for_output(struct weston_view_animation *animation, void *data)
21*4882a593Smuzhiyun {
22*4882a593Smuzhiyun 	struct shell_output *shell_output = data;
23*4882a593Smuzhiyun 	struct desktop_shell *shell = shell_output->shell;
24*4882a593Smuzhiyun+	struct weston_compositor *compositor = shell->compositor;
25*4882a593Smuzhiyun+
26*4882a593Smuzhiyun+	if (shell_output->fade.type == FADE_OUT)
27*4882a593Smuzhiyun+		shell->compositor->pending_fade_out --;
28*4882a593Smuzhiyun
29*4882a593Smuzhiyun 	if (!shell_output->fade.curtain)
30*4882a593Smuzhiyun 		return;
31*4882a593Smuzhiyun
32*4882a593Smuzhiyun 	shell_output->fade.animation = NULL;
33*4882a593Smuzhiyun+
34*4882a593Smuzhiyun 	switch (shell_output->fade.type) {
35*4882a593Smuzhiyun 	case FADE_IN:
36*4882a593Smuzhiyun 		weston_curtain_destroy(shell_output->fade.curtain);
37*4882a593Smuzhiyun 		shell_output->fade.curtain = NULL;
38*4882a593Smuzhiyun 		break;
39*4882a593Smuzhiyun 	case FADE_OUT:
40*4882a593Smuzhiyun-		lock(shell);
41*4882a593Smuzhiyun+		if (!compositor->pending_fade_out)
42*4882a593Smuzhiyun+			lock(shell);
43*4882a593Smuzhiyun 		break;
44*4882a593Smuzhiyun 	default:
45*4882a593Smuzhiyun 		break;
46*4882a593Smuzhiyun@@ -3705,6 +3711,9 @@ shell_fade(struct desktop_shell *shell, enum fade_type type)
47*4882a593Smuzhiyun 		} else if (shell_output->fade.animation) {
48*4882a593Smuzhiyun 			weston_fade_update(shell_output->fade.animation, tint);
49*4882a593Smuzhiyun 		} else {
50*4882a593Smuzhiyun+			if (type == FADE_OUT)
51*4882a593Smuzhiyun+				shell->compositor->pending_fade_out ++;
52*4882a593Smuzhiyun+
53*4882a593Smuzhiyun 			shell_output->fade.animation =
54*4882a593Smuzhiyun 				weston_fade_run(shell_output->fade.curtain->view,
55*4882a593Smuzhiyun 						1.0 - tint, tint, 300.0,
56*4882a593Smuzhiyun@@ -4371,6 +4380,9 @@ shell_output_destroy(struct shell_output *shell_output)
57*4882a593Smuzhiyun 	if (shell_output->fade.animation) {
58*4882a593Smuzhiyun 		weston_view_animation_destroy(shell_output->fade.animation);
59*4882a593Smuzhiyun 		shell_output->fade.animation = NULL;
60*4882a593Smuzhiyun+
61*4882a593Smuzhiyun+		if (shell_output->fade.type == FADE_OUT)
62*4882a593Smuzhiyun+			shell->compositor->pending_fade_out --;
63*4882a593Smuzhiyun 	}
64*4882a593Smuzhiyun
65*4882a593Smuzhiyun 	if (shell_output->fade.curtain) {
66*4882a593Smuzhiyundiff --git a/include/libweston/libweston.h b/include/libweston/libweston.h
67*4882a593Smuzhiyunindex bf8e20a..9d9c5c6 100644
68*4882a593Smuzhiyun--- a/include/libweston/libweston.h
69*4882a593Smuzhiyun+++ b/include/libweston/libweston.h
70*4882a593Smuzhiyun@@ -1342,6 +1342,7 @@ struct weston_compositor {
71*4882a593Smuzhiyun 	struct weston_output *prefer_output;
72*4882a593Smuzhiyun
73*4882a593Smuzhiyun 	bool warm_up;
74*4882a593Smuzhiyun+	uint32_t pending_fade_out;
75*4882a593Smuzhiyun };
76*4882a593Smuzhiyun
77*4882a593Smuzhiyun struct weston_solid_buffer_values {
78*4882a593Smuzhiyun--
79*4882a593Smuzhiyun2.20.1
80*4882a593Smuzhiyun
81