summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Mader <robert.mader@collabora.com>2022-01-25 17:56:46 +0100
committerMarius Vlad <marius.vlad@collabora.com>2022-05-24 19:43:58 +0300
commit2fa690a9a96431e76242fed834b287555e1cfcea (patch)
treee72c6bbc8fbdfdd66958636258a5240b29e37cbd
parent673943d730a5800c033af119a98dff0112e9ed0e (diff)
downloadweston-2fa690a9a96431e76242fed834b287555e1cfcea.tar.gz
tests: Add test for synced subsurfaces and buffer damage
Changing `wl_surface_damage()` to `wl_surface_damage_buffer()` should not have an effect on the existing tests. The new test will fail without the commit "libweston/compositor: Cache buffer damage for synced subsurfaces" Signed-off-by: Robert Mader <robert.mader@collabora.com> (cherry picked from commit dc3b3493259ee55df2429af30d1ddf9e5e9a45d2)
-rw-r--r--tests/reference/subsurface_sync_damage_buffer-00.pngbin0 -> 825 bytes
-rw-r--r--tests/reference/subsurface_sync_damage_buffer-01.pngbin0 -> 858 bytes
-rw-r--r--tests/reference/subsurface_sync_damage_buffer-02.pngbin0 -> 857 bytes
-rw-r--r--tests/subsurface-shot-test.c69
4 files changed, 68 insertions, 1 deletions
diff --git a/tests/reference/subsurface_sync_damage_buffer-00.png b/tests/reference/subsurface_sync_damage_buffer-00.png
new file mode 100644
index 00000000..f127154c
--- /dev/null
+++ b/tests/reference/subsurface_sync_damage_buffer-00.png
Binary files differ
diff --git a/tests/reference/subsurface_sync_damage_buffer-01.png b/tests/reference/subsurface_sync_damage_buffer-01.png
new file mode 100644
index 00000000..d3565281
--- /dev/null
+++ b/tests/reference/subsurface_sync_damage_buffer-01.png
Binary files differ
diff --git a/tests/reference/subsurface_sync_damage_buffer-02.png b/tests/reference/subsurface_sync_damage_buffer-02.png
new file mode 100644
index 00000000..9ef82e06
--- /dev/null
+++ b/tests/reference/subsurface_sync_damage_buffer-02.png
Binary files differ
diff --git a/tests/subsurface-shot-test.c b/tests/subsurface-shot-test.c
index 3bdc82dc..f9b967ea 100644
--- a/tests/subsurface-shot-test.c
+++ b/tests/subsurface-shot-test.c
@@ -117,7 +117,7 @@ surface_commit_color(struct client *client, struct wl_surface *surface,
buf = create_shm_buffer_a8r8g8b8(client, width, height);
fill_image_with_color(buf->image, color);
wl_surface_attach(surface, buf->proxy, 0, 0);
- wl_surface_damage(surface, 0, 0, width, height);
+ wl_surface_damage_buffer(surface, 0, 0, width, height);
wl_surface_commit(surface);
return buf;
@@ -213,3 +213,70 @@ TEST(subsurface_z_order)
wl_subcompositor_destroy(subco);
client_destroy(client);
}
+
+TEST(subsurface_sync_damage_buffer)
+{
+ struct client *client;
+ struct wl_subcompositor *subco;
+ struct buffer *bufs[2] = { 0 };
+ struct wl_surface *surf[2] = { 0 };
+ struct wl_subsurface *sub[2] = { 0 };
+ struct rectangle clip = { 40, 40, 280, 200 };
+ int fail = 0;
+ unsigned i;
+ pixman_color_t red;
+ pixman_color_t blue;
+ pixman_color_t green;
+
+ color_rgb888(&red, 255, 0, 0);
+ color_rgb888(&blue, 0, 0, 255);
+ color_rgb888(&green, 0, 255, 0);
+
+ client = create_client_and_test_surface(100, 50, 100, 100);
+ assert(client);
+ subco = get_subcompositor(client);
+
+ /* move the pointer clearly away from our screenshooting area */
+ weston_test_move_pointer(client->test->weston_test, 0, 1, 0, 2, 30);
+
+ /* make the parent surface red */
+ surf[0] = client->surface->wl_surface;
+ client->surface->wl_surface = NULL; /* we stole it and destroy it */
+ bufs[0] = surface_commit_color(client, surf[0], &red, 100, 100);
+ /* sub[0] is not used */
+
+ fail += check_screen(client, "subsurface_sync_damage_buffer", 0, &clip, 0);
+
+ /* create a blue sub-surface above red */
+ surf[1] = wl_compositor_create_surface(client->wl_compositor);
+ sub[1] = wl_subcompositor_get_subsurface(subco, surf[1], surf[0]);
+ bufs[1] = surface_commit_color(client, surf[1], &blue, 100, 100);
+
+ wl_subsurface_set_position(sub[1], 20, 20);
+ wl_surface_commit(surf[0]);
+
+ fail += check_screen(client, "subsurface_sync_damage_buffer", 1, &clip, 1);
+
+ buffer_destroy(bufs[1]);
+ bufs[1] = surface_commit_color(client, surf[1], &green, 100, 100);
+ wl_surface_commit(surf[0]);
+
+ fail += check_screen(client, "subsurface_sync_damage_buffer", 2, &clip, 2);
+
+ assert(fail == 0);
+
+ for (i = 0; i < ARRAY_LENGTH(sub); i++)
+ if (sub[i])
+ wl_subsurface_destroy(sub[i]);
+
+ for (i = 0; i < ARRAY_LENGTH(surf); i++)
+ if (surf[i])
+ wl_surface_destroy(surf[i]);
+
+ for (i = 0; i < ARRAY_LENGTH(bufs); i++)
+ if (bufs[i])
+ buffer_destroy(bufs[i]);
+
+ wl_subcompositor_destroy(subco);
+ client_destroy(client);
+}