I will be needing it in a new test, so let's share it. For convenience, this also adds client back-pointer in struct surface so that I don't need to pass client explicitly. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
@ -80,19 +80,6 @@ fixture_setup(struct weston_test_harness *harness, const struct setup_args *arg)
}
DECLARE_FIXTURE_SETUP_WITH_ARG(fixture_setup, my_setup_args, meta);
static void
set_opaque_rect(struct client *client,
struct surface *surface,
const struct rectangle *rect)
{
struct wl_region *region;
region = wl_compositor_create_region(client->wl_compositor);
wl_region_add(region, rect->x, rect->y, rect->width, rect->height);
wl_surface_set_opaque_region(surface->wl_surface, region);
wl_region_destroy(region);
static uint32_t
premult_color(uint32_t a, uint32_t r, uint32_t g, uint32_t b)
@ -400,7 +387,7 @@ TEST(alpha_blend)
client->surface->width = width;
client->surface->height = height;
client->surface->buffer = bg; /* pass ownership */
set_opaque_rect(client, client->surface,
surface_set_opaque_rect(client->surface,
&(struct rectangle){ 0, 0, width, height });
/* foreground blended content */
@ -976,6 +976,7 @@ create_test_surface(struct client *client)
surface = xzalloc(sizeof *surface);
surface->client = client;
surface->wl_surface =
wl_compositor_create_surface(client->wl_compositor);
assert(surface->wl_surface);
@ -998,6 +999,17 @@ surface_destroy(struct surface *surface)
free(surface);
void
surface_set_opaque_rect(struct surface *surface, const struct rectangle *rect)
region = wl_compositor_create_region(surface->client->wl_compositor);
struct client *
create_client_and_test_surface(int x, int y, int width, int height)
@ -172,6 +172,8 @@ struct buffer {
};
struct surface {
struct client *client; /* not owned */
struct wl_surface *wl_surface;
struct output *output; /* not owned */
int x;
@ -205,6 +207,9 @@ create_test_surface(struct client *client);
surface_destroy(struct surface *surface);
surface_set_opaque_rect(struct surface *surface, const struct rectangle *rect);
create_client_and_test_surface(int x, int y, int width, int height);