mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-10-29 05:40:12 -04:00 
			
		
		
		
	shm: add support for wl_shm version 2
References: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/335
This commit is contained in:
		
							parent
							
								
									9646742502
								
							
						
					
					
						commit
						22dab77d28
					
				
					 1 changed files with 10 additions and 2 deletions
				
			
		|  | @ -22,7 +22,7 @@ | ||||||
| #error "Lock-free C11 atomic pointers are required" | #error "Lock-free C11 atomic pointers are required" | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #define SHM_VERSION 1 | #define SHM_VERSION 2 | ||||||
| 
 | 
 | ||||||
| struct wlr_shm_pool { | struct wlr_shm_pool { | ||||||
| 	struct wl_resource *resource; // may be NULL
 | 	struct wl_resource *resource; // may be NULL
 | ||||||
|  | @ -460,8 +460,14 @@ error_fd: | ||||||
| 	close(fd); | 	close(fd); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | static void shm_handle_release(struct wl_client *client, | ||||||
|  | 		struct wl_resource *resource) { | ||||||
|  | 	wl_resource_destroy(resource); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| static const struct wl_shm_interface shm_impl = { | static const struct wl_shm_interface shm_impl = { | ||||||
| 	.create_pool = shm_handle_create_pool, | 	.create_pool = shm_handle_create_pool, | ||||||
|  | 	.release = shm_handle_release, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| static void shm_bind(struct wl_client *client, void *data, uint32_t version, | static void shm_bind(struct wl_client *client, void *data, uint32_t version, | ||||||
|  | @ -491,6 +497,8 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { | ||||||
| 
 | 
 | ||||||
| struct wlr_shm *wlr_shm_create(struct wl_display *display, uint32_t version, | struct wlr_shm *wlr_shm_create(struct wl_display *display, uint32_t version, | ||||||
| 		const uint32_t *formats, size_t formats_len) { | 		const uint32_t *formats, size_t formats_len) { | ||||||
|  | 	assert(version <= SHM_VERSION); | ||||||
|  | 
 | ||||||
| 	// ARGB8888 and XRGB8888 must be supported per the wl_shm spec
 | 	// ARGB8888 and XRGB8888 must be supported per the wl_shm spec
 | ||||||
| 	bool has_argb8888 = false, has_xrgb8888 = false; | 	bool has_argb8888 = false, has_xrgb8888 = false; | ||||||
| 	for (size_t i = 0; i < formats_len; i++) { | 	for (size_t i = 0; i < formats_len; i++) { | ||||||
|  | @ -522,7 +530,7 @@ struct wlr_shm *wlr_shm_create(struct wl_display *display, uint32_t version, | ||||||
| 		shm->formats[i] = convert_drm_format_to_wl_shm(formats[i]); | 		shm->formats[i] = convert_drm_format_to_wl_shm(formats[i]); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	shm->global = wl_global_create(display, &wl_shm_interface, SHM_VERSION, | 	shm->global = wl_global_create(display, &wl_shm_interface, version, | ||||||
| 		shm, shm_bind); | 		shm, shm_bind); | ||||||
| 	if (shm->global == NULL) { | 	if (shm->global == NULL) { | ||||||
| 		wlr_log(WLR_ERROR, "wl_global_create failed"); | 		wlr_log(WLR_ERROR, "wl_global_create failed"); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Simon Ser
						Simon Ser