hc
2023-11-06 e3e12f52b214121840b44c91de5b3e5af5d3eb84
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
From 120336ede59536e996cb3ca43cd4e0703effeb7f Mon Sep 17 00:00:00 2001
From: Jeffy Chen <jeffy.chen@rock-chips.com>
Date: Thu, 28 Oct 2021 12:47:09 +0800
Subject: [PATCH 51/74] HACK: Use negative value for dynamic repaint window
 
Support using negative value for a vblank based dynamic repaint window:
When negative, repaint-window = vblank-duration - abs(repaint-window)
 
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
 compositor/main.c      | 2 +-
 libweston/compositor.c | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)
 
diff --git a/compositor/main.c b/compositor/main.c
index c89598b..3ca4a0a 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -1127,7 +1127,7 @@ weston_compositor_init_config(struct weston_compositor *ec,
     s = weston_config_get_section(config, "core", NULL, NULL);
     weston_config_section_get_int(s, "repaint-window", &repaint_msec,
                       ec->repaint_msec);
-    if (repaint_msec < -10 || repaint_msec > 1000) {
+    if (repaint_msec < -1000 || repaint_msec > 1000) {
         weston_log("Invalid repaint_window value in config: %d\n",
                repaint_msec);
     } else {
diff --git a/libweston/compositor.c b/libweston/compositor.c
index af69ab3..02cb51b 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -3288,10 +3288,17 @@ weston_output_finish_frame(struct weston_output *output,
 
     output->frame_time = *stamp;
 
-    timespec_add_nsec(&output->next_repaint, stamp, refresh_nsec);
+    /* HACK: Use negative value for dynamic repaint window */
+    if (compositor->repaint_msec > 0)
+        timespec_add_nsec(&output->next_repaint, stamp, refresh_nsec);
+
     timespec_add_msec(&output->next_repaint, &output->next_repaint,
               -compositor->repaint_msec);
     msec_rel = timespec_sub_to_msec(&output->next_repaint, &now);
+    if (msec_rel < 0) {
+        output->next_repaint = now;
+        msec_rel = 0;
+    }
 
     if (msec_rel < -1000 || msec_rel > 1000) {
         static bool warned;
-- 
2.20.1