wayvnc/include/buffer.h

63 lines
1.4 KiB
C
Raw Normal View History

2020-06-20 14:33:40 +00:00
#pragma once
#include "sys/queue.h"
#include <unistd.h>
#include <stdbool.h>
2020-06-20 21:43:35 +00:00
#include <stdint.h>
2020-06-20 14:33:40 +00:00
struct wl_buffer;
2020-06-23 18:30:08 +00:00
struct gbm_bo;
2020-06-20 14:33:40 +00:00
2020-06-23 17:20:43 +00:00
enum wv_buffer_type {
WV_BUFFER_UNSPEC = 0,
WV_BUFFER_SHM,
2020-06-23 18:30:08 +00:00
WV_BUFFER_DMABUF,
2020-06-23 17:20:43 +00:00
};
2020-06-20 14:33:40 +00:00
struct wv_buffer {
2020-06-23 17:20:43 +00:00
enum wv_buffer_type type;
2020-06-20 14:33:40 +00:00
TAILQ_ENTRY(wv_buffer) link;
2020-06-23 18:30:08 +00:00
2020-06-20 14:33:40 +00:00
struct wl_buffer* wl_buffer;
2020-06-23 18:30:08 +00:00
2020-06-20 14:33:40 +00:00
void* pixels;
size_t size;
int width, height, stride;
uint32_t format;
bool y_inverted;
2020-06-23 18:30:08 +00:00
/* The following is only applicable to DMABUF */
struct gbm_bo* bo;
void* bo_map_handle;
bool is_ready;
void (*on_ready)(struct wv_buffer*);
void* userdata;
2020-06-20 14:33:40 +00:00
};
TAILQ_HEAD(wv_buffer_queue, wv_buffer);
struct wv_buffer_pool {
struct wv_buffer_queue queue;
2020-06-23 17:20:43 +00:00
enum wv_buffer_type type;
2020-06-20 14:33:40 +00:00
int width, height, stride;
uint32_t format;
};
2020-06-23 17:20:43 +00:00
struct wv_buffer* wv_buffer_create(enum wv_buffer_type, int width, int height,
int stride, uint32_t fourcc);
2020-06-20 14:33:40 +00:00
void wv_buffer_destroy(struct wv_buffer* self);
2020-06-23 17:20:43 +00:00
int wv_buffer_map(struct wv_buffer* self);
void wv_buffer_unmap(struct wv_buffer* self);
struct wv_buffer_pool* wv_buffer_pool_create(enum wv_buffer_type, int width,
int height, int stride, uint32_t format);
2020-06-20 14:33:40 +00:00
void wv_buffer_pool_destroy(struct wv_buffer_pool* pool);
2020-06-23 17:20:43 +00:00
void wv_buffer_pool_resize(struct wv_buffer_pool* pool, enum wv_buffer_type,
2020-06-20 14:33:40 +00:00
int width, int height, int stride, uint32_t format);
struct wv_buffer* wv_buffer_pool_acquire(struct wv_buffer_pool* pool);
void wv_buffer_pool_release(struct wv_buffer_pool* pool,
struct wv_buffer* buffer);