wayvnc/include/buffer.h

88 lines
2.5 KiB
C
Raw Permalink Normal View History

2020-07-06 17:14:10 +00:00
/*
* Copyright (c) 2020 Andri Yngvason
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
2020-06-20 14:33:40 +00:00
#pragma once
#include "sys/queue.h"
#include "config.h"
2020-06-20 14:33:40 +00:00
#include <unistd.h>
#include <stdbool.h>
2020-06-20 21:43:35 +00:00
#include <stdint.h>
2020-06-26 18:05:31 +00:00
#include <pixman.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,
#ifdef ENABLE_SCREENCOPY_DMABUF
2020-06-23 18:30:08 +00:00
WV_BUFFER_DMABUF,
#endif
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
2020-06-26 18:05:31 +00:00
struct pixman_region16 damage;
2020-06-23 18:30:08 +00:00
/* The following is only applicable to DMABUF */
struct gbm_bo* bo;
void* bo_map_handle;
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;
};
enum wv_buffer_type wv_buffer_get_available_types(void);
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);
2020-06-26 18:05:31 +00:00
void wv_buffer_damage_rect(struct wv_buffer* self, int x, int y, int width,
int height);
void wv_buffer_damage_whole(struct wv_buffer* self);
void wv_buffer_damage_clear(struct wv_buffer* self);
2020-06-23 17:20:43 +00:00
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);