diff options
author | William McKinnon <[email protected]> | 2023-07-11 00:44:26 -0400 |
---|---|---|
committer | William McKinnon <[email protected]> | 2023-07-11 00:44:26 -0400 |
commit | 9eaa07a4b141bc80a46cb7ab2dc94048f126fa8c (patch) | |
tree | c78cb64199476b94d9ee2f403f1e31ff4d3c5a69 /include | |
parent | 74e85d896e4e0964a93113cd9ef31bfb10747b28 (diff) |
added more scene dependencies, added tinywl
Diffstat (limited to 'include')
-rw-r--r-- | include/meson.build | 1 | ||||
-rw-r--r-- | include/types/wlr_buffer.h | 84 | ||||
-rw-r--r-- | include/types/wlr_scene.h | 8 | ||||
-rw-r--r-- | include/util/array.h | 18 | ||||
-rw-r--r-- | include/util/env.h | 11 | ||||
-rw-r--r-- | include/util/time.h | 27 |
6 files changed, 149 insertions, 0 deletions
diff --git a/include/meson.build b/include/meson.build new file mode 100644 index 0000000..4c388f0 --- /dev/null +++ b/include/meson.build @@ -0,0 +1 @@ +exclude_files = ['meson.build', 'config.h.in', 'version.h.in'] diff --git a/include/types/wlr_buffer.h b/include/types/wlr_buffer.h new file mode 100644 index 0000000..59d78e9 --- /dev/null +++ b/include/types/wlr_buffer.h @@ -0,0 +1,84 @@ +#ifndef TYPES_WLR_BUFFER +#define TYPES_WLR_BUFFER + +#include <wlr/types/wlr_buffer.h> + +struct wlr_shm_client_buffer { + struct wlr_buffer base; + + uint32_t format; + size_t stride; + + // The following fields are NULL if the client has destroyed the wl_buffer + struct wl_resource *resource; + struct wl_shm_buffer *shm_buffer; + + // This is used to keep the backing storage alive after the client has + // destroyed the wl_buffer + struct wl_shm_pool *saved_shm_pool; + void *saved_data; + + struct wl_listener resource_destroy; + struct wl_listener release; +}; + +struct wlr_shm_client_buffer *shm_client_buffer_get_or_create( + struct wl_resource *resource); + +/** + * A read-only buffer that holds a data pointer. + * + * This is suitable for passing raw pixel data to a function that accepts a + * wlr_buffer. + */ +struct wlr_readonly_data_buffer { + struct wlr_buffer base; + + const void *data; + uint32_t format; + size_t stride; + + void *saved_data; +}; + +/** + * Wraps a read-only data pointer into a wlr_buffer. The data pointer may be + * accessed until readonly_data_buffer_drop() is called. + */ +struct wlr_readonly_data_buffer *readonly_data_buffer_create(uint32_t format, + size_t stride, uint32_t width, uint32_t height, const void *data); +/** + * Drops ownership of the buffer (see wlr_buffer_drop() for more details) and + * perform a copy of the data pointer if a consumer still has the buffer locked. + */ +bool readonly_data_buffer_drop(struct wlr_readonly_data_buffer *buffer); + +struct wlr_dmabuf_buffer { + struct wlr_buffer base; + struct wlr_dmabuf_attributes dmabuf; + bool saved; +}; + +/** + * Wraps a DMA-BUF into a wlr_buffer. The DMA-BUF may be accessed until + * dmabuf_buffer_drop() is called. + */ +struct wlr_dmabuf_buffer *dmabuf_buffer_create( + struct wlr_dmabuf_attributes *dmabuf); +/** + * Drops ownership of the buffer (see wlr_buffer_drop() for more details) and + * takes a reference to the DMA-BUF (by dup'ing its file descriptors) if a + * consumer still has the buffer locked. + */ +bool dmabuf_buffer_drop(struct wlr_dmabuf_buffer *buffer); + +/** + * Check whether a buffer is fully opaque. + * + * When true is returned, the buffer is guaranteed to be fully opaque, but the + * reverse is not true: false may be returned in cases where the buffer is fully + * opaque. + */ +bool buffer_is_opaque(struct wlr_buffer *buffer); + +#endif diff --git a/include/types/wlr_scene.h b/include/types/wlr_scene.h new file mode 100644 index 0000000..64c11bc --- /dev/null +++ b/include/types/wlr_scene.h @@ -0,0 +1,8 @@ +#ifndef TYPES_WLR_SCENE_H +#define TYPES_WLR_SCENE_H + +#include <wlr/types/wlr_scene.h> + +struct wlr_scene *scene_node_get_root(struct wlr_scene_node *node); + +#endif diff --git a/include/util/array.h b/include/util/array.h new file mode 100644 index 0000000..a51bdb6 --- /dev/null +++ b/include/util/array.h @@ -0,0 +1,18 @@ +#ifndef UTIL_ARRAY_H +#define UTIL_ARRAY_H + +#include <stdlib.h> +#include <stdbool.h> +#include <wayland-util.h> + +/** + * Remove a chunk of memory of the specified size at the specified offset. + */ +void array_remove_at(struct wl_array *arr, size_t offset, size_t size); + +/** + * Grow or shrink the array to fit the specifized size. + */ +bool array_realloc(struct wl_array *arr, size_t size); + +#endif diff --git a/include/util/env.h b/include/util/env.h new file mode 100644 index 0000000..6720fa8 --- /dev/null +++ b/include/util/env.h @@ -0,0 +1,11 @@ +#ifndef UTIL_ENV_H +#define UTIL_ENV_H + +#include <stdbool.h> +#include <unistd.h> + +bool env_parse_bool(const char *option); + +ssize_t env_parse_switch(const char *option, const char **switches); + +#endif diff --git a/include/util/time.h b/include/util/time.h new file mode 100644 index 0000000..287698d --- /dev/null +++ b/include/util/time.h @@ -0,0 +1,27 @@ +#ifndef UTIL_TIME_H +#define UTIL_TIME_H + +#include <time.h> + +/** + * Get the current time, in milliseconds. + */ +uint32_t get_current_time_msec(void); + +/** + * Convert a timespec to milliseconds. + */ +int64_t timespec_to_msec(const struct timespec *a); + +/** + * Convert nanoseconds to a timespec. + */ +void timespec_from_nsec(struct timespec *r, int64_t nsec); + +/** + * Subtracts timespec `b` from timespec `a`, and stores the difference in `r`. + */ +void timespec_sub(struct timespec *r, const struct timespec *a, + const struct timespec *b); + +#endif |