main wayland.h
 1/* wld: wayland.h
 2 *
 3 * Copyright (c) 2013, 2014 Michael Forney
 4 *
 5 * Permission is hereby granted, free of charge, to any person obtaining a copy
 6 * of this software and associated documentation files (the "Software"), to deal
 7 * in the Software without restriction, including without limitation the rights
 8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
24#ifndef WLD_WAYLAND_H
25#define WLD_WAYLAND_H
26
27#include <stdbool.h>
28#include <stdint.h>
29
30struct wl_display;
31struct wl_surface;
32
33#define WLD_WAYLAND_ID (0x3 << 24)
34
35enum wld_wayland_interface_id {
36	/**
37	 * Give up on trying any new interfaces. This can be considered as a
38	 * sentinel for wld_wayland_create_context.
39	 */
40	WLD_NONE = -2,
41
42	/**
43	 * Try any available interface.
44	 */
45	WLD_ANY = -1,
46	WLD_DRM,
47	WLD_SHM
48};
49
50enum wld_wayland_object_type {
51	WLD_WAYLAND_OBJECT_BUFFER = WLD_WAYLAND_ID
52};
53
54/**
55 * Create a new WLD context which uses various available Wayland interfaces
56 * (such as wl_shm and wl_drm) to create wl_buffers backed by implementations
57 * specific to the interface.
58 *
59 * You can specify the particular interface you want to use by specifying them
60 * as arguments. Interfaces will be tried in the order they are given.
61 *
62 * The last argument must be either WLD_NONE or WLD_ANY.
63 *
64 * @see enum wld_wayland_interface_id
65 */
66struct wld_context *wld_wayland_create_context(struct wl_display *display, enum wld_wayland_interface_id id, ...);
67
68struct wld_surface *wld_wayland_create_surface(struct wld_context *context,
69                                               uint32_t width, uint32_t height,
70                                               uint32_t format, uint32_t flags,
71                                               struct wl_surface *surface);
72
73/**
74 * Check if the wayland implementation supports a particular pixel format.
75 *
76 * @see enum wld_format
77 */
78bool wld_wayland_has_format(struct wld_context *context, uint32_t format);
79
80#endif