mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2025-12-20 02:20:13 +01:00
tests: Add helper to create solid-filled buffer
At the moment this is only replacing two clear calls with one. However, when client_buffer starts using properly-bracketed CPU access, this will become much more tedious. Introduce a helper now to make it easier. Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
parent
2259ac4e93
commit
4ebb06a94f
14 changed files with 63 additions and 38 deletions
|
|
@ -327,8 +327,7 @@ TEST(alpha_blend)
|
|||
subco = bind_to_singleton_global(client, &wl_subcompositor_interface, 1);
|
||||
|
||||
/* background window content */
|
||||
bg = create_shm_buffer_a8r8g8b8(client, width, height);
|
||||
fill_image_with_color(bg->image, &background_color);
|
||||
bg = create_shm_buffer_solid(client, width, height, &background_color);
|
||||
|
||||
/* background window, main surface */
|
||||
client->surface = create_test_surface(client);
|
||||
|
|
|
|||
|
|
@ -699,8 +699,7 @@ TEST(output_icc_alpha_blend)
|
|||
subco = bind_to_singleton_global(client, &wl_subcompositor_interface, 1);
|
||||
|
||||
/* background window content */
|
||||
bg = create_shm_buffer_a8r8g8b8(client, width, height);
|
||||
fill_image_with_color(bg->image, &background_color);
|
||||
bg = create_shm_buffer_solid(client, width, height, &background_color);
|
||||
|
||||
/* background window, main surface */
|
||||
client->surface = create_test_surface(client);
|
||||
|
|
|
|||
|
|
@ -57,9 +57,7 @@ TEST(drm_smoke) {
|
|||
test_assert_ptr_not_null(client);
|
||||
|
||||
surface = client->surface->wl_surface;
|
||||
buffer = create_shm_buffer_a8r8g8b8(client, 200, 200);
|
||||
|
||||
fill_image_with_color(buffer->image, &red);
|
||||
buffer = create_shm_buffer_solid(client, 200, 200, &red);
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
wl_surface_attach(surface, buffer->proxy, 0, 0);
|
||||
|
|
|
|||
|
|
@ -136,22 +136,25 @@ TEST(buffer_release)
|
|||
struct buffer *buf1;
|
||||
struct buffer *buf2;
|
||||
struct buffer *buf3;
|
||||
pixman_color_t black;
|
||||
int buf1_released = 0;
|
||||
int buf2_released = 0;
|
||||
int buf3_released = 0;
|
||||
int frame;
|
||||
|
||||
color_rgb888(&black, 0, 0, 0);
|
||||
|
||||
client = create_client_and_test_surface(100, 100, 100, 100);
|
||||
test_assert_ptr_not_null(client);
|
||||
surface = client->surface->wl_surface;
|
||||
|
||||
buf1 = create_shm_buffer_a8r8g8b8(client, 100, 100);
|
||||
buf1 = create_shm_buffer_solid(client, 100, 100, &black);
|
||||
wl_buffer_add_listener(buf1->proxy, &buffer_listener, &buf1_released);
|
||||
|
||||
buf2 = create_shm_buffer_a8r8g8b8(client, 100, 100);
|
||||
buf2 = create_shm_buffer_solid(client, 100, 100, &black);
|
||||
wl_buffer_add_listener(buf2->proxy, &buffer_listener, &buf2_released);
|
||||
|
||||
buf3 = create_shm_buffer_a8r8g8b8(client, 100, 100);
|
||||
buf3 = create_shm_buffer_solid(client, 100, 100, &black);
|
||||
wl_buffer_add_listener(buf3->proxy, &buffer_listener, &buf3_released);
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -463,6 +463,7 @@ TEST(ivi_layout_surface_configure_notification)
|
|||
struct ivi_application *iviapp;
|
||||
struct ivi_window *wind;
|
||||
struct buffer *buffer;
|
||||
pixman_color_t black;
|
||||
|
||||
client = create_client();
|
||||
runner = client_create_runner(client);
|
||||
|
|
@ -472,7 +473,8 @@ TEST(ivi_layout_surface_configure_notification)
|
|||
|
||||
wind = client_create_ivi_window(client, iviapp, IVI_TEST_SURFACE_ID(0));
|
||||
|
||||
buffer = create_shm_buffer_a8r8g8b8(client, 200, 300);
|
||||
color_rgb888(&black, 0, 0, 0);
|
||||
buffer = create_shm_buffer_solid(client, 200, 300, &black);
|
||||
|
||||
wl_surface_attach(wind->wl_surface, buffer->proxy, 0, 0);
|
||||
wl_surface_damage(wind->wl_surface, 0, 0, 20, 30);
|
||||
|
|
|
|||
|
|
@ -273,10 +273,13 @@ TEST(get_release_after_commit_succeeds)
|
|||
struct zwp_linux_surface_synchronization_v1 *surface_sync =
|
||||
zwp_linux_explicit_synchronization_v1_get_synchronization(
|
||||
sync, surface);
|
||||
struct buffer *buf1 = create_shm_buffer_a8r8g8b8(client, 100, 100);
|
||||
struct buffer *buf1;
|
||||
pixman_color_t black;
|
||||
struct zwp_linux_buffer_release_v1 *buffer_release1;
|
||||
struct zwp_linux_buffer_release_v1 *buffer_release2;
|
||||
|
||||
color_rgb888(&black, 0, 0, 0);
|
||||
buf1 = create_shm_buffer_solid(client, 100, 100, &black);
|
||||
buffer_release1 =
|
||||
zwp_linux_surface_synchronization_v1_get_release(surface_sync);
|
||||
client_roundtrip(client);
|
||||
|
|
@ -335,8 +338,9 @@ TEST(get_release_events_are_emitted_for_different_buffers)
|
|||
struct zwp_linux_surface_synchronization_v1 *surface_sync =
|
||||
zwp_linux_explicit_synchronization_v1_get_synchronization(
|
||||
sync, client->surface->wl_surface);
|
||||
struct buffer *buf1 = create_shm_buffer_a8r8g8b8(client, 100, 100);
|
||||
struct buffer *buf2 = create_shm_buffer_a8r8g8b8(client, 100, 100);
|
||||
struct buffer *buf1;
|
||||
struct buffer *buf2;
|
||||
pixman_color_t black;
|
||||
struct wl_surface *surface = client->surface->wl_surface;
|
||||
struct zwp_linux_buffer_release_v1 *buffer_release1;
|
||||
struct zwp_linux_buffer_release_v1 *buffer_release2;
|
||||
|
|
@ -344,6 +348,10 @@ TEST(get_release_events_are_emitted_for_different_buffers)
|
|||
int buf_released2 = 0;
|
||||
int frame;
|
||||
|
||||
color_rgb888(&black, 0, 0, 0);
|
||||
buf1 = create_shm_buffer_solid(client, 100, 100, &black);
|
||||
buf2 = create_shm_buffer_solid(client, 100, 100, &black);
|
||||
|
||||
buffer_release1 =
|
||||
zwp_linux_surface_synchronization_v1_get_release(surface_sync);
|
||||
zwp_linux_buffer_release_v1_add_listener(buffer_release1,
|
||||
|
|
@ -399,7 +407,8 @@ TEST(get_release_events_are_emitted_for_same_buffer_on_surface)
|
|||
struct zwp_linux_surface_synchronization_v1 *surface_sync =
|
||||
zwp_linux_explicit_synchronization_v1_get_synchronization(
|
||||
sync, client->surface->wl_surface);
|
||||
struct buffer *buf = create_shm_buffer_a8r8g8b8(client, 100, 100);
|
||||
struct buffer *buf;
|
||||
pixman_color_t black;
|
||||
struct wl_surface *surface = client->surface->wl_surface;
|
||||
struct zwp_linux_buffer_release_v1 *buffer_release1;
|
||||
struct zwp_linux_buffer_release_v1 *buffer_release2;
|
||||
|
|
@ -407,6 +416,8 @@ TEST(get_release_events_are_emitted_for_same_buffer_on_surface)
|
|||
int buf_released2 = 0;
|
||||
int frame;
|
||||
|
||||
color_rgb888(&black, 0, 0, 0);
|
||||
buf = create_shm_buffer_solid(client, 100, 100, &black);
|
||||
buffer_release1 =
|
||||
zwp_linux_surface_synchronization_v1_get_release(surface_sync);
|
||||
zwp_linux_buffer_release_v1_add_listener(buffer_release1,
|
||||
|
|
@ -467,14 +478,19 @@ TEST(get_release_events_are_emitted_for_same_buffer_on_different_surfaces)
|
|||
struct zwp_linux_surface_synchronization_v1 *surface_sync2 =
|
||||
zwp_linux_explicit_synchronization_v1_get_synchronization(
|
||||
sync, surface2);
|
||||
struct buffer *buf1 = create_shm_buffer_a8r8g8b8(client, 100, 100);
|
||||
struct buffer *buf2 = create_shm_buffer_a8r8g8b8(client, 100, 100);
|
||||
struct buffer *buf1;
|
||||
struct buffer *buf2;
|
||||
pixman_color_t black;
|
||||
struct zwp_linux_buffer_release_v1 *buffer_release1;
|
||||
struct zwp_linux_buffer_release_v1 *buffer_release2;
|
||||
int buf_released1 = 0;
|
||||
int buf_released2 = 0;
|
||||
int frame;
|
||||
|
||||
color_rgb888(&black, 0, 0, 0);
|
||||
buf1 = create_shm_buffer_solid(client, 100, 100, &black);
|
||||
buf2 = create_shm_buffer_solid(client, 100, 100, &black);
|
||||
|
||||
weston_test_move_surface(client->test->weston_test, surface2, 0, 0);
|
||||
|
||||
/* Attach buf1 to both surface1 and surface2. */
|
||||
|
|
|
|||
|
|
@ -210,10 +210,8 @@ TEST(output_damage)
|
|||
client->surface->width = width;
|
||||
client->surface->height = height;
|
||||
|
||||
for (i = 0; i < COUNT_BUFS; i++) {
|
||||
buf[i] = create_shm_buffer_a8r8g8b8(client, width, height);
|
||||
fill_image_with_color(buf[i]->image, &colors[i]);
|
||||
}
|
||||
for (i = 0; i < COUNT_BUFS; i++)
|
||||
buf[i] = create_shm_buffer_solid(client, width, height, &colors[i]);
|
||||
|
||||
client->surface->buffer = buf[0];
|
||||
move_client_frame_sync(client, 19, 19);
|
||||
|
|
|
|||
|
|
@ -57,8 +57,7 @@ surface_commit_color(struct client *client, struct wl_surface *surface,
|
|||
{
|
||||
struct buffer *buf;
|
||||
|
||||
buf = create_shm_buffer_a8r8g8b8(client, width, height);
|
||||
fill_image_with_color(buf->image, color);
|
||||
buf = create_shm_buffer_solid(client, width, height, color);
|
||||
wl_surface_attach(surface, buf->proxy, 0, 0);
|
||||
wl_surface_damage_buffer(surface, 0, 0, width, height);
|
||||
wl_surface_commit(surface);
|
||||
|
|
|
|||
|
|
@ -92,8 +92,7 @@ surface_commit_color(struct client *client, struct surface *surface,
|
|||
{
|
||||
struct buffer *buf;
|
||||
|
||||
buf = create_shm_buffer_a8r8g8b8(client, width, height);
|
||||
fill_image_with_color(buf->image, color);
|
||||
buf = create_shm_buffer_solid(client, width, height, color);
|
||||
wl_surface_attach(surface->wl_surface, buf->proxy, 0, 0);
|
||||
wl_surface_damage(surface->wl_surface, 0, 0, width, height);
|
||||
wl_surface_commit(surface->wl_surface);
|
||||
|
|
@ -145,8 +144,7 @@ TEST(pointer_cursor_retains_committed_buffer_after_reenter)
|
|||
|
||||
/* Set up the main surface. */
|
||||
client->surface = main_surface;
|
||||
client->surface->buffer = create_shm_buffer_a8r8g8b8(client, 100, 100);
|
||||
fill_image_with_color(client->surface->buffer->image, &red);
|
||||
client->surface->buffer = create_shm_buffer_solid(client, 100, 100, &red);
|
||||
move_client_frame_sync(client, 50, 50);
|
||||
|
||||
/* Move the pointer into the main surface. */
|
||||
|
|
|
|||
|
|
@ -120,8 +120,7 @@ surface_commit_color(struct client *client, struct wl_surface *surface,
|
|||
{
|
||||
struct buffer *buf;
|
||||
|
||||
buf = create_shm_buffer_a8r8g8b8(client, width, height);
|
||||
fill_image_with_color(buf->image, color);
|
||||
buf = create_shm_buffer_solid(client, width, height, color);
|
||||
wl_surface_attach(surface, buf->proxy, 0, 0);
|
||||
wl_surface_damage_buffer(surface, 0, 0, width, height);
|
||||
wl_surface_commit(surface);
|
||||
|
|
|
|||
|
|
@ -84,8 +84,7 @@ TEST(viewport_upscale_solid)
|
|||
client->surface = create_test_surface(client);
|
||||
viewport = client_create_viewport(client);
|
||||
|
||||
client->surface->buffer = create_shm_buffer_a8r8g8b8(client, 2, 2);
|
||||
fill_image_with_color(client->surface->buffer->image, &color);
|
||||
client->surface->buffer = create_shm_buffer_solid(client, 2, 2, &color);
|
||||
|
||||
/* Needs output scale != buffer scale to hit bilinear filter. */
|
||||
wl_surface_set_buffer_scale(client->surface->wl_surface, 2);
|
||||
|
|
|
|||
|
|
@ -1188,8 +1188,7 @@ create_client_and_test_surface(int x, int y, int width, int height)
|
|||
|
||||
surface->width = width;
|
||||
surface->height = height;
|
||||
surface->buffer = create_shm_buffer_a8r8g8b8(client, width, height);
|
||||
fill_image_with_color(surface->buffer->image, &color);
|
||||
surface->buffer = create_shm_buffer_solid(client, width, height, &color);
|
||||
|
||||
move_client_frame_sync(client, x, y);
|
||||
|
||||
|
|
@ -2351,6 +2350,20 @@ fill_image_with_color(pixman_image_t *image, const pixman_color_t *color)
|
|||
pixman_image_unref(solid);
|
||||
}
|
||||
|
||||
struct buffer *
|
||||
create_shm_buffer_solid(struct client *client, int width, int height,
|
||||
const pixman_color_t *color)
|
||||
{
|
||||
struct buffer *buffer;
|
||||
|
||||
buffer = create_shm_buffer_a8r8g8b8(client, width, height);
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
fill_image_with_color(buffer->image, color);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert 8-bit RGB to opaque Pixman color
|
||||
*
|
||||
|
|
|
|||
|
|
@ -244,6 +244,10 @@ create_shm_buffer(struct client *client, int width, int height,
|
|||
struct buffer *
|
||||
create_shm_buffer_a8r8g8b8(struct client *client, int width, int height);
|
||||
|
||||
struct buffer *
|
||||
create_shm_buffer_solid(struct client *client, int width, int height,
|
||||
const pixman_color_t *solid);
|
||||
|
||||
bool
|
||||
support_drm_format(struct client *client, uint32_t format, uint64_t modifier);
|
||||
|
||||
|
|
|
|||
|
|
@ -190,14 +190,12 @@ xdg_surface_commit_solid(struct xdg_surface_data *xdg_surface,
|
|||
width = xdg_surface->configure.width;
|
||||
height = xdg_surface->configure.height;
|
||||
|
||||
buf = create_shm_buffer_a8r8g8b8(xdg_surface->surface->client,
|
||||
width, height);
|
||||
color_rgb888(&color, r, g, b);
|
||||
buf = create_shm_buffer_solid(xdg_surface->surface->client,
|
||||
width, height, &color);
|
||||
test_assert_ptr_not_null(buf);
|
||||
xdg_surface->surface->buffer = buf;
|
||||
|
||||
color_rgb888(&color, r, g, b);
|
||||
fill_image_with_color(buf->image, &color);
|
||||
|
||||
wl_surface_attach(xdg_surface->surface->wl_surface, buf->proxy, 0, 0);
|
||||
wl_surface_damage_buffer(xdg_surface->surface->wl_surface,
|
||||
0, 0, width, height);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue