From dc3b3493259ee55df2429af30d1ddf9e5e9a45d2 Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Tue, 25 Jan 2022 17:56:46 +0100 Subject: [PATCH] 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 --- .../subsurface_sync_damage_buffer-00.png | Bin 0 -> 825 bytes .../subsurface_sync_damage_buffer-01.png | Bin 0 -> 858 bytes .../subsurface_sync_damage_buffer-02.png | Bin 0 -> 857 bytes tests/subsurface-shot-test.c | 69 +++++++++++++++++- 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 tests/reference/subsurface_sync_damage_buffer-00.png create mode 100644 tests/reference/subsurface_sync_damage_buffer-01.png create mode 100644 tests/reference/subsurface_sync_damage_buffer-02.png 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 0000000000000000000000000000000000000000..f127154cb68edf8e0148ac0de00ea5ca360b371b GIT binary patch literal 825 zcmeAS@N?(olHy`uVBq!ia0y~yU~~YoKX5Ps$$$P@Hb9Ck$=lt9;Xep2*t>i(0|V1L zPZ!6KiaBquI`T3(inusVQ%IX=T;|45HlbP8=FQXRsjEf4JYCvf{FeQ~mpO6_G3p5% z!Uipz5{FoL5}Dcz7@cP{DEb@_P@})_w^?!lpMKXZQ%~7*ecrqRZn;6=rU3{BqO9ET rIHtOaxnLsufW{b6PNij%+Fi(0|PU^ zr;B4q#hkZyHu4^F5Mg!f(Kt5cahZ>wwO)IX!Xn1x!l)T1{i{yCN;f}yx{7Jmxy9@Z zzd0oivG61^wHYuv&uCEeIUt~xz#(kVG62G{Zu}aRIo~e|8?8HSRdp!7pph)+d{)0U z-Dmmp7o7LEzOA>?-~PDlkA?W4@g&W{b$5?kKvC?qzx_ZDADGQeR+Qc_ssD6d*kB5I hx(7J9rfODhL8pZOKY^Kr!PC{xWt~$(69BBr`2GL@ literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..9ef82e06c45ebdd1e1ad0689517c71ef17752649 GIT binary patch literal 857 zcmeAS@N?(olHy`uVBq!ia0y~yU~~YoKX5Ps$$$P@Hb9Ck$=lt9;Xep2*t>i(0|PUk zr;B4q#hkZyHu4^F5Mg!f(Kt3G`BWieUVD)SyHZig1b^+cPm|*|{krMimage, 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); +}