tests: move set_opaque_rect() to client helpers
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>
This commit is contained in:
committed by
Marius Vlad
parent
b878357dfd
commit
4d2ea5dd0b
@@ -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);
|
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
|
static uint32_t
|
||||||
premult_color(uint32_t a, uint32_t r, uint32_t g, uint32_t b)
|
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->width = width;
|
||||||
client->surface->height = height;
|
client->surface->height = height;
|
||||||
client->surface->buffer = bg; /* pass ownership */
|
client->surface->buffer = bg; /* pass ownership */
|
||||||
set_opaque_rect(client, client->surface,
|
surface_set_opaque_rect(client->surface,
|
||||||
&(struct rectangle){ 0, 0, width, height });
|
&(struct rectangle){ 0, 0, width, height });
|
||||||
|
|
||||||
/* foreground blended content */
|
/* foreground blended content */
|
||||||
|
|||||||
@@ -976,6 +976,7 @@ create_test_surface(struct client *client)
|
|||||||
|
|
||||||
surface = xzalloc(sizeof *surface);
|
surface = xzalloc(sizeof *surface);
|
||||||
|
|
||||||
|
surface->client = client;
|
||||||
surface->wl_surface =
|
surface->wl_surface =
|
||||||
wl_compositor_create_surface(client->wl_compositor);
|
wl_compositor_create_surface(client->wl_compositor);
|
||||||
assert(surface->wl_surface);
|
assert(surface->wl_surface);
|
||||||
@@ -998,6 +999,17 @@ surface_destroy(struct surface *surface)
|
|||||||
free(surface);
|
free(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
surface_set_opaque_rect(struct surface *surface, const struct rectangle *rect)
|
||||||
|
{
|
||||||
|
struct wl_region *region;
|
||||||
|
|
||||||
|
region = wl_compositor_create_region(surface->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);
|
||||||
|
}
|
||||||
|
|
||||||
struct client *
|
struct client *
|
||||||
create_client_and_test_surface(int x, int y, int width, int height)
|
create_client_and_test_surface(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -172,6 +172,8 @@ struct buffer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct surface {
|
struct surface {
|
||||||
|
struct client *client; /* not owned */
|
||||||
|
|
||||||
struct wl_surface *wl_surface;
|
struct wl_surface *wl_surface;
|
||||||
struct output *output; /* not owned */
|
struct output *output; /* not owned */
|
||||||
int x;
|
int x;
|
||||||
@@ -205,6 +207,9 @@ create_test_surface(struct client *client);
|
|||||||
void
|
void
|
||||||
surface_destroy(struct surface *surface);
|
surface_destroy(struct surface *surface);
|
||||||
|
|
||||||
|
void
|
||||||
|
surface_set_opaque_rect(struct surface *surface, const struct rectangle *rect);
|
||||||
|
|
||||||
struct client *
|
struct client *
|
||||||
create_client_and_test_surface(int x, int y, int width, int height);
|
create_client_and_test_surface(int x, int y, int width, int height);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user