|
|
|
/*
|
|
|
|
* Copyright © 2012 Intel Corporation
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the
|
|
|
|
* next paragraph) shall be included in all copies or substantial
|
|
|
|
* portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _WESTON_TEST_CLIENT_HELPER_H_
|
|
|
|
#define _WESTON_TEST_CLIENT_HELPER_H_
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
tests: introduce struct buffer for client-helper
We are growing more tests that need to handle buffers, both just images
and wl_buffers. Particularly the screenshooting facility needs these.
Currently everything is in struct surface, which contains more than we
need. It is a bit messy.
Create a new struct buffer to encapsulate the image representation, the
wl_buffer, and enough information to tear it all down (munmap) so we
don't have to leak everything. Some tests might start doing things in
loops, and leaking would accumulate.
Instead of inventing our own image representation, use pixman_image_t.
It is a well-tested library worth using, and we already rely on it in
other places.
This makes the tests depend on Pixman, which requires the fix for
building buffer-count, which would otherwise not find pixman.h.
The new create_shm_buffer_a8r8g8b8() creates an image with an explicit
format, and pixman_image_t keeps track of it. And stride and size and
data. This implementation is still a little hacky due to calling
create_shm_buffer().
A very new thing is buffer_destroy(). Previously we didn't really free
any buffers. It is not a problem when the process will exit soon anyway,
but it may become a problem if tests start iterating things.
Manual memset() on a image is converted to a pixman action, just to show
how to do it properly with pixman.
Stride and pixel format assumptions still linger all around, but those
are for another patch.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
9 years ago
|
|
|
#include <pixman.h>
|
|
|
|
|
|
|
|
#include <wayland-client-protocol.h>
|
|
|
|
#include "weston-test-runner.h"
|
|
|
|
#include "weston-test-client-protocol.h"
|
|
|
|
|
|
|
|
struct client {
|
|
|
|
struct wl_display *wl_display;
|
|
|
|
struct wl_registry *wl_registry;
|
|
|
|
struct wl_compositor *wl_compositor;
|
|
|
|
struct wl_shm *wl_shm;
|
|
|
|
struct test *test;
|
|
|
|
/* the seat that is actually used for input events */
|
|
|
|
struct input *input;
|
|
|
|
/* server can have more wl_seats. We need keep them all until we
|
|
|
|
* find the one that we need. After that, the others
|
|
|
|
* will be destroyed, so this list will have the length of 1.
|
|
|
|
* If some day in the future we will need the other seats,
|
|
|
|
* we can just keep them here. */
|
|
|
|
struct wl_list inputs;
|
|
|
|
struct output *output;
|
|
|
|
struct surface *surface;
|
|
|
|
int has_argb;
|
|
|
|
struct wl_list global_list;
|
|
|
|
bool has_wl_drm;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct global {
|
|
|
|
uint32_t name;
|
|
|
|
char *interface;
|
|
|
|
uint32_t version;
|
|
|
|
struct wl_list link;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct test {
|
|
|
|
struct weston_test *weston_test;
|
|
|
|
int pointer_x;
|
|
|
|
int pointer_y;
|
|
|
|
uint32_t n_egl_buffers;
|
|
|
|
int buffer_copy_done;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct input {
|
|
|
|
struct wl_seat *wl_seat;
|
|
|
|
struct pointer *pointer;
|
|
|
|
struct keyboard *keyboard;
|
|
|
|
struct touch *touch;
|
|
|
|
char *seat_name;
|
|
|
|
enum wl_seat_capability caps;
|
|
|
|
struct wl_list link;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct pointer {
|
|
|
|
struct wl_pointer *wl_pointer;
|
|
|
|
struct surface *focus;
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
uint32_t button;
|
|
|
|
uint32_t state;
|
|
|
|
uint32_t motion_time_msec;
|
|
|
|
uint32_t button_time_msec;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct keyboard {
|
|
|
|
struct wl_keyboard *wl_keyboard;
|
|
|
|
struct surface *focus;
|
|
|
|
uint32_t key;
|
|
|
|
uint32_t state;
|
|
|
|
uint32_t mods_depressed;
|
|
|
|
uint32_t mods_latched;
|
|
|
|
uint32_t mods_locked;
|
|
|
|
uint32_t group;
|
|
|
|
struct {
|
|
|
|
int rate;
|
|
|
|
int delay;
|
|
|
|
} repeat_info;
|
|
|
|
uint32_t key_time_msec;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct touch {
|
|
|
|
struct wl_touch *wl_touch;
|
|
|
|
int down_x;
|
|
|
|
int down_y;
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int id;
|
|
|
|
int up_id; /* id of last wl_touch.up event */
|
|
|
|
int frame_no;
|
|
|
|
int cancel_no;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct output {
|
|
|
|
struct wl_output *wl_output;
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
int scale;
|
|
|
|
int initialized;
|
|
|
|
};
|
|
|
|
|
tests: introduce struct buffer for client-helper
We are growing more tests that need to handle buffers, both just images
and wl_buffers. Particularly the screenshooting facility needs these.
Currently everything is in struct surface, which contains more than we
need. It is a bit messy.
Create a new struct buffer to encapsulate the image representation, the
wl_buffer, and enough information to tear it all down (munmap) so we
don't have to leak everything. Some tests might start doing things in
loops, and leaking would accumulate.
Instead of inventing our own image representation, use pixman_image_t.
It is a well-tested library worth using, and we already rely on it in
other places.
This makes the tests depend on Pixman, which requires the fix for
building buffer-count, which would otherwise not find pixman.h.
The new create_shm_buffer_a8r8g8b8() creates an image with an explicit
format, and pixman_image_t keeps track of it. And stride and size and
data. This implementation is still a little hacky due to calling
create_shm_buffer().
A very new thing is buffer_destroy(). Previously we didn't really free
any buffers. It is not a problem when the process will exit soon anyway,
but it may become a problem if tests start iterating things.
Manual memset() on a image is converted to a pixman action, just to show
how to do it properly with pixman.
Stride and pixel format assumptions still linger all around, but those
are for another patch.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
9 years ago
|
|
|
struct buffer {
|
|
|
|
struct wl_buffer *proxy;
|
|
|
|
size_t len;
|
|
|
|
pixman_image_t *image;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct surface {
|
|
|
|
struct wl_surface *wl_surface;
|
|
|
|
struct output *output;
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int width;
|
|
|
|
int height;
|
tests: introduce struct buffer for client-helper
We are growing more tests that need to handle buffers, both just images
and wl_buffers. Particularly the screenshooting facility needs these.
Currently everything is in struct surface, which contains more than we
need. It is a bit messy.
Create a new struct buffer to encapsulate the image representation, the
wl_buffer, and enough information to tear it all down (munmap) so we
don't have to leak everything. Some tests might start doing things in
loops, and leaking would accumulate.
Instead of inventing our own image representation, use pixman_image_t.
It is a well-tested library worth using, and we already rely on it in
other places.
This makes the tests depend on Pixman, which requires the fix for
building buffer-count, which would otherwise not find pixman.h.
The new create_shm_buffer_a8r8g8b8() creates an image with an explicit
format, and pixman_image_t keeps track of it. And stride and size and
data. This implementation is still a little hacky due to calling
create_shm_buffer().
A very new thing is buffer_destroy(). Previously we didn't really free
any buffers. It is not a problem when the process will exit soon anyway,
but it may become a problem if tests start iterating things.
Manual memset() on a image is converted to a pixman action, just to show
how to do it properly with pixman.
Stride and pixel format assumptions still linger all around, but those
are for another patch.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
9 years ago
|
|
|
struct buffer *buffer;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct rectangle {
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct client *
|
|
|
|
create_client(void);
|
|
|
|
|
|
|
|
struct surface *
|
|
|
|
create_test_surface(struct client *client);
|
|
|
|
|
|
|
|
struct client *
|
|
|
|
create_client_and_test_surface(int x, int y, int width, int height);
|
|
|
|
|
tests: introduce struct buffer for client-helper
We are growing more tests that need to handle buffers, both just images
and wl_buffers. Particularly the screenshooting facility needs these.
Currently everything is in struct surface, which contains more than we
need. It is a bit messy.
Create a new struct buffer to encapsulate the image representation, the
wl_buffer, and enough information to tear it all down (munmap) so we
don't have to leak everything. Some tests might start doing things in
loops, and leaking would accumulate.
Instead of inventing our own image representation, use pixman_image_t.
It is a well-tested library worth using, and we already rely on it in
other places.
This makes the tests depend on Pixman, which requires the fix for
building buffer-count, which would otherwise not find pixman.h.
The new create_shm_buffer_a8r8g8b8() creates an image with an explicit
format, and pixman_image_t keeps track of it. And stride and size and
data. This implementation is still a little hacky due to calling
create_shm_buffer().
A very new thing is buffer_destroy(). Previously we didn't really free
any buffers. It is not a problem when the process will exit soon anyway,
but it may become a problem if tests start iterating things.
Manual memset() on a image is converted to a pixman action, just to show
how to do it properly with pixman.
Stride and pixel format assumptions still linger all around, but those
are for another patch.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
9 years ago
|
|
|
struct buffer *
|
|
|
|
create_shm_buffer_a8r8g8b8(struct client *client, int width, int height);
|
|
|
|
|
|
|
|
void
|
|
|
|
buffer_destroy(struct buffer *buf);
|
|
|
|
|
|
|
|
int
|
|
|
|
surface_contains(struct surface *surface, int x, int y);
|
|
|
|
|
|
|
|
void
|
|
|
|
move_client(struct client *client, int x, int y);
|
|
|
|
|
|
|
|
#define client_roundtrip(c) do { \
|
|
|
|
assert(wl_display_roundtrip((c)->wl_display) >= 0); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
struct wl_callback *
|
|
|
|
frame_callback_set(struct wl_surface *surface, int *done);
|
|
|
|
|
|
|
|
int
|
|
|
|
frame_callback_wait_nofail(struct client *client, int *done);
|
|
|
|
|
|
|
|
#define frame_callback_wait(c, d) assert(frame_callback_wait_nofail((c), (d)))
|
|
|
|
|
|
|
|
void
|
|
|
|
skip(const char *fmt, ...);
|
|
|
|
|
|
|
|
void
|
|
|
|
expect_protocol_error(struct client *client,
|
|
|
|
const struct wl_interface *intf, uint32_t code);
|
|
|
|
|
|
|
|
char *
|
|
|
|
screenshot_output_filename(const char *basename, uint32_t seq);
|
|
|
|
|
|
|
|
char *
|
|
|
|
screenshot_reference_filename(const char *basename, uint32_t seq);
|
|
|
|
|
|
|
|
bool
|
|
|
|
check_images_match(pixman_image_t *img_a, pixman_image_t *img_b,
|
|
|
|
const struct rectangle *clip);
|
|
|
|
|
|
|
|
pixman_image_t *
|
|
|
|
visualize_image_difference(pixman_image_t *img_a, pixman_image_t *img_b,
|
|
|
|
const struct rectangle *clip_rect);
|
|
|
|
|
|
|
|
bool
|
|
|
|
write_image_as_png(pixman_image_t *image, const char *fname);
|
|
|
|
|
|
|
|
pixman_image_t *
|
|
|
|
load_image_from_png(const char *fname);
|
|
|
|
|
|
|
|
struct buffer *
|
|
|
|
capture_screenshot_of_output(struct client *client);
|
|
|
|
|
|
|
|
#endif
|