Allow running tests with an always garbaged subcompositor

* 12to11-test.xml (test_surface) <set_always_garbage>: 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.
This commit is contained in:
hujianwei 2022-11-17 04:56:55 +00:00
parent d2abef20c4
commit ac7b6b5915
5 changed files with 42 additions and 2 deletions

View file

@ -154,6 +154,13 @@
</description> </description>
</request> </request>
<request name="set_always_garbage">
<description summary="set_always_garbage">
Force the subcompositor to be garbaged, and all contents
redrawn from scratch upon any damage.
</description>
</request>
<event name="mapped"> <event name="mapped">
<description summary="role initialized"> <description summary="role initialized">
The map event is sent once the window is mapped and its The map event is sent once the window is mapped and its

View file

@ -820,6 +820,7 @@ extern SubcompositorDestroyCallback *SubcompositorOnDestroy (Subcompositor *,
void (*) (void *), void (*) (void *),
void *); void *);
extern void SubcompositorRemoveDestroyCallback (SubcompositorDestroyCallback *); extern void SubcompositorRemoveDestroyCallback (SubcompositorDestroyCallback *);
extern void SubcompositorSetAlwaysGarbaged (Subcompositor *);
extern void ViewSetSubcompositor (View *, Subcompositor *); extern void ViewSetSubcompositor (View *, Subcompositor *);

View file

@ -133,6 +133,8 @@ enum
SubcompositorIsPartiallyMapped = (1 << 4), SubcompositorIsPartiallyMapped = (1 << 4),
/* This means that the subcompositor has a target attached. */ /* This means that the subcompositor has a target attached. */
SubcompositorIsTargetAttached = (1 << 5), SubcompositorIsTargetAttached = (1 << 5),
/* This means the subcompositor is always garbaged. */
SubcompositorIsAlwaysGarbaged = (1 << 6),
}; };
#define IsGarbaged(subcompositor) \ #define IsGarbaged(subcompositor) \
@ -160,6 +162,11 @@ enum
#define IsTargetAttached(subcompositor) \ #define IsTargetAttached(subcompositor) \
((subcompositor)->state & SubcompositorIsTargetAttached) ((subcompositor)->state & SubcompositorIsTargetAttached)
#define SetAlwaysGarbaged(subcompositor) \
((subcompositor)->state |= SubcompositorIsAlwaysGarbaged)
#define IsAlwaysGarbaged(subcompositor) \
((subcompositor)->state & SubcompositorIsAlwaysGarbaged)
enum enum
{ {
/* This means that the view and all its inferiors should be /* This means that the view and all its inferiors should be
@ -3042,8 +3049,11 @@ SubcompositorUpdate (Subcompositor *subcompositor)
EndFrame (subcompositor); EndFrame (subcompositor);
/* Clear the garbaged flag. */ /* Clear the garbaged flag, unless for debugging purposes the
subcompositor->state &= ~SubcompositorIsGarbaged; subcompositor is always garbaged. */
if (!IsAlwaysGarbaged (subcompositor))
subcompositor->state &= ~SubcompositorIsGarbaged;
return; return;
} }
@ -3282,3 +3292,10 @@ SubcompositorRemoveDestroyCallback (SubcompositorDestroyCallback *callback)
XLFree (callback); XLFree (callback);
} }
void
SubcompositorSetAlwaysGarbaged (Subcompositor *subcompositor)
{
SetGarbaged (subcompositor);
SetAlwaysGarbaged (subcompositor);
}

12
test.c
View file

@ -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 = static const struct test_surface_interface test_surface_impl =
{ {
.destroy = Destroy, .destroy = Destroy,
.set_always_garbage = SetAlwaysGarbage,
}; };
static void static void

View file

@ -421,6 +421,9 @@ make_test_surface (struct test_display *display,
return false; return false;
} }
if (getenv ("TEST_ALWAYS_GARBAGE"))
test_surface_set_always_garbage (test_surface);
*surface_return = surface; *surface_return = surface;
*test_surface_return = test_surface; *test_surface_return = test_surface;
return true; return true;