xref: /aosp_15_r20/external/swiftshader/src/WSI/libWaylandClient.hpp (revision 03ce13f70fcc45d86ee91b7ee4cab1936a95046e)
1*03ce13f7SAndroid Build Coastguard Worker // Copyright 2022 The SwiftShader Authors. All Rights Reserved.
2*03ce13f7SAndroid Build Coastguard Worker //
3*03ce13f7SAndroid Build Coastguard Worker // Licensed under the Apache License, Version 2.0 (the "License");
4*03ce13f7SAndroid Build Coastguard Worker // you may not use this file except in compliance with the License.
5*03ce13f7SAndroid Build Coastguard Worker // You may obtain a copy of the License at
6*03ce13f7SAndroid Build Coastguard Worker //
7*03ce13f7SAndroid Build Coastguard Worker //    http://www.apache.org/licenses/LICENSE-2.0
8*03ce13f7SAndroid Build Coastguard Worker //
9*03ce13f7SAndroid Build Coastguard Worker // Unless required by applicable law or agreed to in writing, software
10*03ce13f7SAndroid Build Coastguard Worker // distributed under the License is distributed on an "AS IS" BASIS,
11*03ce13f7SAndroid Build Coastguard Worker // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*03ce13f7SAndroid Build Coastguard Worker // See the License for the specific language governing permissions and
13*03ce13f7SAndroid Build Coastguard Worker // limitations under the License.
14*03ce13f7SAndroid Build Coastguard Worker 
15*03ce13f7SAndroid Build Coastguard Worker #ifndef libWaylandClient_hpp
16*03ce13f7SAndroid Build Coastguard Worker #define libWaylandClient_hpp
17*03ce13f7SAndroid Build Coastguard Worker 
18*03ce13f7SAndroid Build Coastguard Worker #include <wayland-client.h>
19*03ce13f7SAndroid Build Coastguard Worker 
20*03ce13f7SAndroid Build Coastguard Worker struct LibWaylandClientExports
21*03ce13f7SAndroid Build Coastguard Worker {
LibWaylandClientExportsLibWaylandClientExports22*03ce13f7SAndroid Build Coastguard Worker 	LibWaylandClientExports() {}
23*03ce13f7SAndroid Build Coastguard Worker 	LibWaylandClientExports(void *libwl);
24*03ce13f7SAndroid Build Coastguard Worker 
25*03ce13f7SAndroid Build Coastguard Worker 	int (*wl_display_dispatch)(wl_display *d) = nullptr;
26*03ce13f7SAndroid Build Coastguard Worker 	wl_registry *(*wl_display_get_registry)(wl_display *d) = nullptr;
27*03ce13f7SAndroid Build Coastguard Worker 	int (*wl_display_roundtrip)(wl_display *d) = nullptr;
28*03ce13f7SAndroid Build Coastguard Worker 	wl_callback *(*wl_display_sync)(wl_display *d) = nullptr;
29*03ce13f7SAndroid Build Coastguard Worker 
30*03ce13f7SAndroid Build Coastguard Worker 	int (*wl_registry_add_listener)(wl_registry *r,
31*03ce13f7SAndroid Build Coastguard Worker 	                                const wl_registry_listener *l, void *data) = nullptr;
32*03ce13f7SAndroid Build Coastguard Worker 	void *(*wl_registry_bind)(wl_registry *r, uint32_t name, const wl_interface *i, uint32_t version) = nullptr;
33*03ce13f7SAndroid Build Coastguard Worker 
34*03ce13f7SAndroid Build Coastguard Worker 	void (*wl_buffer_destroy)(wl_buffer *b) = nullptr;
35*03ce13f7SAndroid Build Coastguard Worker 	wl_shm_pool *(*wl_shm_create_pool)(wl_shm *shm, int32_t fd, int32_t size) = nullptr;
36*03ce13f7SAndroid Build Coastguard Worker 	wl_buffer *(*wl_shm_pool_create_buffer)(wl_shm_pool *p, int32_t offset, int32_t width, int32_t height, int32_t stride, uint32_t format) = nullptr;
37*03ce13f7SAndroid Build Coastguard Worker 	void (*wl_shm_pool_destroy)(wl_shm_pool *p) = nullptr;
38*03ce13f7SAndroid Build Coastguard Worker 
39*03ce13f7SAndroid Build Coastguard Worker 	void (*wl_surface_attach)(wl_surface *s, wl_buffer *b, int32_t x, int32_t y) = nullptr;
40*03ce13f7SAndroid Build Coastguard Worker 	void (*wl_surface_damage)(wl_surface *s, int32_t x, int32_t y, int32_t width, int32_t height) = nullptr;
41*03ce13f7SAndroid Build Coastguard Worker 	void (*wl_surface_commit)(wl_surface *s) = nullptr;
42*03ce13f7SAndroid Build Coastguard Worker 
43*03ce13f7SAndroid Build Coastguard Worker 	const wl_interface *wl_shm_interface = nullptr;
44*03ce13f7SAndroid Build Coastguard Worker };
45*03ce13f7SAndroid Build Coastguard Worker 
46*03ce13f7SAndroid Build Coastguard Worker class LibWaylandClient
47*03ce13f7SAndroid Build Coastguard Worker {
48*03ce13f7SAndroid Build Coastguard Worker public:
isPresent()49*03ce13f7SAndroid Build Coastguard Worker 	bool isPresent()
50*03ce13f7SAndroid Build Coastguard Worker 	{
51*03ce13f7SAndroid Build Coastguard Worker 		return loadExports() != nullptr;
52*03ce13f7SAndroid Build Coastguard Worker 	}
53*03ce13f7SAndroid Build Coastguard Worker 
54*03ce13f7SAndroid Build Coastguard Worker 	LibWaylandClientExports *operator->();
55*03ce13f7SAndroid Build Coastguard Worker 
56*03ce13f7SAndroid Build Coastguard Worker private:
57*03ce13f7SAndroid Build Coastguard Worker 	LibWaylandClientExports *loadExports();
58*03ce13f7SAndroid Build Coastguard Worker };
59*03ce13f7SAndroid Build Coastguard Worker 
60*03ce13f7SAndroid Build Coastguard Worker extern LibWaylandClient libWaylandClient;
61*03ce13f7SAndroid Build Coastguard Worker 
62*03ce13f7SAndroid Build Coastguard Worker #endif  // libWaylandClient_hpp
63