xref: /aosp_15_r20/external/swiftshader/src/WSI/libXCB.hpp (revision 03ce13f70fcc45d86ee91b7ee4cab1936a95046e)
1*03ce13f7SAndroid Build Coastguard Worker // Copyright 2021 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 libXCB_hpp
16*03ce13f7SAndroid Build Coastguard Worker #define libXCB_hpp
17*03ce13f7SAndroid Build Coastguard Worker 
18*03ce13f7SAndroid Build Coastguard Worker #include <xcb/shm.h>
19*03ce13f7SAndroid Build Coastguard Worker #include <xcb/xcb.h>
20*03ce13f7SAndroid Build Coastguard Worker 
21*03ce13f7SAndroid Build Coastguard Worker struct LibXcbExports
22*03ce13f7SAndroid Build Coastguard Worker {
LibXcbExportsLibXcbExports23*03ce13f7SAndroid Build Coastguard Worker 	LibXcbExports() {}
24*03ce13f7SAndroid Build Coastguard Worker 	LibXcbExports(void *libxcb, void *libshm);
25*03ce13f7SAndroid Build Coastguard Worker 
26*03ce13f7SAndroid Build Coastguard Worker 	xcb_void_cookie_t (*xcb_create_gc)(xcb_connection_t *c, xcb_gcontext_t cid, xcb_drawable_t drawable, uint32_t value_mask, const void *value_list) = nullptr;
27*03ce13f7SAndroid Build Coastguard Worker 	int (*xcb_flush)(xcb_connection_t *c) = nullptr;
28*03ce13f7SAndroid Build Coastguard Worker 	xcb_void_cookie_t (*xcb_free_gc)(xcb_connection_t *c, xcb_gcontext_t gc) = nullptr;
29*03ce13f7SAndroid Build Coastguard Worker 	uint32_t (*xcb_generate_id)(xcb_connection_t *c) = nullptr;
30*03ce13f7SAndroid Build Coastguard Worker 	xcb_get_geometry_cookie_t (*xcb_get_geometry)(xcb_connection_t *c, xcb_drawable_t drawable) = nullptr;
31*03ce13f7SAndroid Build Coastguard Worker 	xcb_get_geometry_reply_t *(*xcb_get_geometry_reply)(xcb_connection_t *c, xcb_get_geometry_cookie_t cookie, xcb_generic_error_t **e) = nullptr;
32*03ce13f7SAndroid Build Coastguard Worker 	xcb_void_cookie_t (*xcb_put_image)(xcb_connection_t *c, uint8_t format, xcb_drawable_t drawable, xcb_gcontext_t gc, uint16_t width, uint16_t height, int16_t dst_x, int16_t dst_y, uint8_t left_pad, uint8_t depth, uint32_t data_len, const uint8_t *data) = nullptr;
33*03ce13f7SAndroid Build Coastguard Worker 	xcb_void_cookie_t (*xcb_copy_area)(xcb_connection_t *conn, xcb_drawable_t src_drawable, xcb_drawable_t dst_drawable, xcb_gcontext_t gc, int16_t src_x, int16_t src_y, int16_t dst_x, int16_t dst_y, uint16_t width, uint16_t height);
34*03ce13f7SAndroid Build Coastguard Worker 	xcb_void_cookie_t (*xcb_free_pixmap)(xcb_connection_t *conn, xcb_pixmap_t pixmap);
35*03ce13f7SAndroid Build Coastguard Worker 	xcb_query_extension_reply_t *(*xcb_get_extension_data)(xcb_connection_t *c, xcb_extension_t *extension) = nullptr;
36*03ce13f7SAndroid Build Coastguard Worker 	int	(*xcb_connection_has_error)(xcb_connection_t *c);
37*03ce13f7SAndroid Build Coastguard Worker 	uint32_t (*xcb_get_maximum_request_length)(xcb_connection_t *c);
38*03ce13f7SAndroid Build Coastguard Worker 
39*03ce13f7SAndroid Build Coastguard Worker 	xcb_shm_query_version_cookie_t (*xcb_shm_query_version)(xcb_connection_t *c);
40*03ce13f7SAndroid Build Coastguard Worker 	xcb_shm_query_version_reply_t *(*xcb_shm_query_version_reply)(xcb_connection_t *c, xcb_shm_query_version_cookie_t cookie, xcb_generic_error_t **e);
41*03ce13f7SAndroid Build Coastguard Worker 	xcb_void_cookie_t (*xcb_shm_attach)(xcb_connection_t *c, xcb_shm_seg_t shmseg, uint32_t shmid, uint8_t read_only);
42*03ce13f7SAndroid Build Coastguard Worker 	xcb_void_cookie_t (*xcb_shm_detach)(xcb_connection_t *c, xcb_shm_seg_t shmseg);
43*03ce13f7SAndroid Build Coastguard Worker 	xcb_void_cookie_t (*xcb_shm_create_pixmap)(xcb_connection_t *c, xcb_pixmap_t pid, xcb_drawable_t drawable, uint16_t width, uint16_t height, uint8_t depth, xcb_shm_seg_t shmseg, uint32_t offset);
44*03ce13f7SAndroid Build Coastguard Worker 	xcb_extension_t *xcb_shm_id;
45*03ce13f7SAndroid Build Coastguard Worker };
46*03ce13f7SAndroid Build Coastguard Worker 
47*03ce13f7SAndroid Build Coastguard Worker class LibXCB
48*03ce13f7SAndroid Build Coastguard Worker {
49*03ce13f7SAndroid Build Coastguard Worker public:
isPresent()50*03ce13f7SAndroid Build Coastguard Worker 	bool isPresent()
51*03ce13f7SAndroid Build Coastguard Worker 	{
52*03ce13f7SAndroid Build Coastguard Worker 		return loadExports() != nullptr;
53*03ce13f7SAndroid Build Coastguard Worker 	}
54*03ce13f7SAndroid Build Coastguard Worker 
55*03ce13f7SAndroid Build Coastguard Worker 	LibXcbExports *operator->();
56*03ce13f7SAndroid Build Coastguard Worker 
57*03ce13f7SAndroid Build Coastguard Worker private:
58*03ce13f7SAndroid Build Coastguard Worker 	LibXcbExports *loadExports();
59*03ce13f7SAndroid Build Coastguard Worker };
60*03ce13f7SAndroid Build Coastguard Worker 
61*03ce13f7SAndroid Build Coastguard Worker extern LibXCB libXCB;
62*03ce13f7SAndroid Build Coastguard Worker 
63*03ce13f7SAndroid Build Coastguard Worker #endif  // libXCB_hpp
64