mirror of
https://gitlab.freedesktop.org/wayland/weston
synced 2024-10-07 00:30:03 +00:00
tests: internal-screenshot-test to use create_shm_buffer_a8r8g8b8()
This removes the uses of create_shm_buffer() from this test. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
parent
7789acd186
commit
95e2872e9c
|
@ -32,25 +32,37 @@
|
||||||
char *server_parameters="--use-pixman --width=320 --height=240";
|
char *server_parameters="--use-pixman --width=320 --height=240";
|
||||||
|
|
||||||
static void
|
static void
|
||||||
draw_stuff(void *pixels, int w, int h)
|
draw_stuff(pixman_image_t *image)
|
||||||
{
|
{
|
||||||
|
int w, h;
|
||||||
|
int stride; /* bytes */
|
||||||
int x, y;
|
int x, y;
|
||||||
uint8_t r, g, b;
|
uint8_t r, g, b;
|
||||||
|
uint32_t *pixels;
|
||||||
uint32_t *pixel;
|
uint32_t *pixel;
|
||||||
|
pixman_format_code_t fmt;
|
||||||
|
|
||||||
|
fmt = pixman_image_get_format(image);
|
||||||
|
w = pixman_image_get_width(image);
|
||||||
|
h = pixman_image_get_height(image);
|
||||||
|
stride = pixman_image_get_stride(image);
|
||||||
|
pixels = pixman_image_get_data(image);
|
||||||
|
|
||||||
|
assert(PIXMAN_FORMAT_BPP(fmt) == 32);
|
||||||
|
|
||||||
for (x = 0; x < w; x++)
|
for (x = 0; x < w; x++)
|
||||||
for (y = 0; y < h; y++) {
|
for (y = 0; y < h; y++) {
|
||||||
b = x;
|
b = x;
|
||||||
g = x + y;
|
g = x + y;
|
||||||
r = y;
|
r = y;
|
||||||
pixel = (uint32_t *)pixels + y * w + x;
|
pixel = pixels + (y * stride / 4) + x;
|
||||||
*pixel = (255 << 24) | (r << 16) | (g << 8) | b;
|
*pixel = (255 << 24) | (r << 16) | (g << 8) | b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(internal_screenshot)
|
TEST(internal_screenshot)
|
||||||
{
|
{
|
||||||
struct wl_buffer *buf;
|
struct buffer *buf;
|
||||||
struct client *client;
|
struct client *client;
|
||||||
struct wl_surface *surface;
|
struct wl_surface *surface;
|
||||||
struct surface *screenshot = NULL;
|
struct surface *screenshot = NULL;
|
||||||
|
@ -60,7 +72,6 @@ TEST(internal_screenshot)
|
||||||
const char *fname;
|
const char *fname;
|
||||||
bool match = false;
|
bool match = false;
|
||||||
bool dump_all_images = true;
|
bool dump_all_images = true;
|
||||||
void *pixels;
|
|
||||||
|
|
||||||
/* Create the client */
|
/* Create the client */
|
||||||
printf("Creating client for test\n");
|
printf("Creating client for test\n");
|
||||||
|
@ -86,9 +97,9 @@ TEST(internal_screenshot)
|
||||||
/* Move the pointer away from the screenshot area. */
|
/* Move the pointer away from the screenshot area. */
|
||||||
weston_test_move_pointer(client->test->weston_test, 0, 0);
|
weston_test_move_pointer(client->test->weston_test, 0, 0);
|
||||||
|
|
||||||
buf = create_shm_buffer(client, 100, 100, &pixels);
|
buf = create_shm_buffer_a8r8g8b8(client, 100, 100);
|
||||||
draw_stuff(pixels, 100, 100);
|
draw_stuff(buf->image);
|
||||||
wl_surface_attach(surface, buf, 0, 0);
|
wl_surface_attach(surface, buf->proxy, 0, 0);
|
||||||
wl_surface_damage(surface, 0, 0, 100, 100);
|
wl_surface_damage(surface, 0, 0, 100, 100);
|
||||||
wl_surface_commit(surface);
|
wl_surface_commit(surface);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue