From ac7b6b59151862a18eb024c53b4bcbbc79225185 Mon Sep 17 00:00:00 2001 From: hujianwei Date: Thu, 17 Nov 2022 04:56:55 +0000 Subject: [PATCH] Allow running tests with an always garbaged subcompositor * 12to11-test.xml (test_surface) : New request. * compositor.h: Update prototypes. * subcompositor.c (SubcompositorUpdate): Don't clear garbaged flag if the subcompositor is always garbaged. (SubcompositorSetAlwaysGarbaged): New function. * test.c (SetAlwaysGarbage): New function. (test_surface_impl): Add function. * tests/test_harness.c (make_test_surface): Always garbage the subcompositor if TEST_ALWAYS_GARBAGE is set. --- 12to11-test.xml | 7 +++++++ compositor.h | 1 + subcompositor.c | 21 +++++++++++++++++++-- test.c | 12 ++++++++++++ tests/test_harness.c | 3 +++ 5 files changed, 42 insertions(+), 2 deletions(-) diff --git a/12to11-test.xml b/12to11-test.xml index 64180b7..7604a4c 100644 --- a/12to11-test.xml +++ b/12to11-test.xml @@ -154,6 +154,13 @@ + + + Force the subcompositor to be garbaged, and all contents + redrawn from scratch upon any damage. + + + The map event is sent once the window is mapped and its diff --git a/compositor.h b/compositor.h index 3894f27..a3fcef7 100644 --- a/compositor.h +++ b/compositor.h @@ -820,6 +820,7 @@ extern SubcompositorDestroyCallback *SubcompositorOnDestroy (Subcompositor *, void (*) (void *), void *); extern void SubcompositorRemoveDestroyCallback (SubcompositorDestroyCallback *); +extern void SubcompositorSetAlwaysGarbaged (Subcompositor *); extern void ViewSetSubcompositor (View *, Subcompositor *); diff --git a/subcompositor.c b/subcompositor.c index a228da9..cde4ab3 100644 --- a/subcompositor.c +++ b/subcompositor.c @@ -133,6 +133,8 @@ enum SubcompositorIsPartiallyMapped = (1 << 4), /* This means that the subcompositor has a target attached. */ SubcompositorIsTargetAttached = (1 << 5), + /* This means the subcompositor is always garbaged. */ + SubcompositorIsAlwaysGarbaged = (1 << 6), }; #define IsGarbaged(subcompositor) \ @@ -160,6 +162,11 @@ enum #define IsTargetAttached(subcompositor) \ ((subcompositor)->state & SubcompositorIsTargetAttached) +#define SetAlwaysGarbaged(subcompositor) \ + ((subcompositor)->state |= SubcompositorIsAlwaysGarbaged) +#define IsAlwaysGarbaged(subcompositor) \ + ((subcompositor)->state & SubcompositorIsAlwaysGarbaged) + enum { /* This means that the view and all its inferiors should be @@ -3042,8 +3049,11 @@ SubcompositorUpdate (Subcompositor *subcompositor) EndFrame (subcompositor); - /* Clear the garbaged flag. */ - subcompositor->state &= ~SubcompositorIsGarbaged; + /* Clear the garbaged flag, unless for debugging purposes the + subcompositor is always garbaged. */ + + if (!IsAlwaysGarbaged (subcompositor)) + subcompositor->state &= ~SubcompositorIsGarbaged; return; } @@ -3282,3 +3292,10 @@ SubcompositorRemoveDestroyCallback (SubcompositorDestroyCallback *callback) XLFree (callback); } + +void +SubcompositorSetAlwaysGarbaged (Subcompositor *subcompositor) +{ + SetGarbaged (subcompositor); + SetAlwaysGarbaged (subcompositor); +} diff --git a/test.c b/test.c index 6d67ead..48d47a4 100644 --- a/test.c +++ b/test.c @@ -363,9 +363,21 @@ Activate (Surface *surface, Role *role, int deviceid, } } +static void +SetAlwaysGarbage (struct wl_client *client, struct wl_resource *resource) +{ + TestSurface *test; + + test = wl_resource_get_user_data (resource); + + /* Make the subcompositor always garbaged. */ + SubcompositorSetAlwaysGarbaged (test->subcompositor); +} + static const struct test_surface_interface test_surface_impl = { .destroy = Destroy, + .set_always_garbage = SetAlwaysGarbage, }; static void diff --git a/tests/test_harness.c b/tests/test_harness.c index 3dcf35e..5e15cb1 100644 --- a/tests/test_harness.c +++ b/tests/test_harness.c @@ -421,6 +421,9 @@ make_test_surface (struct test_display *display, return false; } + if (getenv ("TEST_ALWAYS_GARBAGE")) + test_surface_set_always_garbage (test_surface); + *surface_return = surface; *test_surface_return = test_surface; return true;