File: client-buffer-util.h

package info (click to toggle)
weston 14.0.91-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 11,292 kB
  • sloc: ansic: 166,537; xml: 1,274; cpp: 480; python: 106; sh: 39; makefile: 33
file content (82 lines) | stat: -rw-r--r-- 2,418 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
 * Copyright © 2025 Collabora, Ltd.
 *
 * 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.
 */

#pragma once

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>

struct pixel_format_info;
struct wl_buffer;
struct wl_shm;
struct wl_display;
struct zwp_linux_dmabuf_v1;

#define MAX_DMABUF_PLANES 4

enum client_buffer_type {
	CLIENT_BUFFER_TYPE_SHM = 1,
	CLIENT_BUFFER_TYPE_DMABUF,
};

struct client_buffer {
	const struct pixel_format_info *fmt;
	enum client_buffer_type type;
	struct wl_buffer *wl_buffer;
	void *data;
	size_t bytes;
	int dmabuf_fd;
	int width;
	int height;
	size_t bytes_per_line[MAX_DMABUF_PLANES];
	size_t strides[MAX_DMABUF_PLANES];
	size_t offsets[MAX_DMABUF_PLANES];
};

bool
client_buffer_util_is_dmabuf_supported(void);

void
client_buffer_util_destroy_buffer(struct client_buffer *buf);

struct client_buffer *
client_buffer_util_create_shm_buffer(struct wl_shm *shm,
				     const struct pixel_format_info *fmt,
				     int width,
				     int height);

struct client_buffer *
client_buffer_util_create_dmabuf_buffer(struct wl_display *display,
					struct zwp_linux_dmabuf_v1 *dmabuf,
					const struct pixel_format_info *fmt,
					int width,
					int height);

void
client_buffer_util_maybe_sync_dmabuf_start(struct client_buffer *buf);

void
client_buffer_util_maybe_sync_dmabuf_end(struct client_buffer *buf);