commit 8fdf857
Michael Forney
·
2020-01-04 21:32:53 +0000 UTC
parent 8e0cbd8
compositor: Fix damage calculation on attach We only need to damage the region that was newly covered or uncovered during a resize.
1 files changed,
+25,
-9
+25,
-9
1@@ -1,6 +1,6 @@
2 /* swc: libswc/compositor.c
3 *
4- * Copyright (c) 2013, 2014 Michael Forney
5+ * Copyright (c) 2013-2020 Michael Forney
6 *
7 * Based in part upon compositor.c from weston, which is:
8 *
9@@ -292,8 +292,8 @@ renderer_flush_view(struct compositor_view *view)
10 /* Surface Views {{{ */
11
12 /**
13- * Adds damage from the region below a view, taking into account it's clip
14- * region, to the region specified by `damage'.
15+ * Adds the region below a view to the compositor's damaged region,
16+ * taking into account its clip region.
17 */
18 static void
19 damage_below_view(struct compositor_view *view)
20@@ -362,22 +362,38 @@ static int
21 attach(struct view *base, struct wld_buffer *buffer)
22 {
23 struct compositor_view *view = (void *)base;
24+ pixman_box32_t old_extents;
25+ pixman_region32_t old, new, both;
26 int ret;
27
28 if ((ret = renderer_attach(view, buffer)) < 0)
29 return ret;
30
31- if (view->visible && view->base.buffer) {
32- damage_below_view(view);
33- update(&view->base);
34- }
35+ /* Schedule updates on the screens the view was previously
36+ * visible on. */
37+ update(&view->base);
38
39 if (view_set_size_from_buffer(&view->base, buffer)) {
40+ /* The view was resized. */
41+ old_extents = view->extents;
42 update_extents(view);
43
44- if (view->visible && buffer) {
45+ if (view->visible) {
46+ /* Damage the region that was newly uncovered
47+ * or covered, minus the clip region. */
48+ pixman_region32_init_with_extents(&old, &old_extents);
49+ pixman_region32_init_with_extents(&new, &view->extents);
50+ pixman_region32_init(&both);
51+ pixman_region32_intersect(&both, &old, &new);
52+ pixman_region32_union(&new, &old, &new);
53+ pixman_region32_subtract(&new, &new, &both);
54+ pixman_region32_subtract(&new, &new, &view->clip);
55+ pixman_region32_union(&compositor.damage, &compositor.damage, &new);
56+ pixman_region32_fini(&old);
57+ pixman_region32_fini(&new);
58+ pixman_region32_fini(&both);
59+
60 view_update_screens(&view->base);
61- damage_below_view(view);
62 update(&view->base);
63 }
64 }