buffer: make wlr_client_buffer_apply_damage return a bool
We always return the same wlr_client_buffer as the one passed in, so no need to return anything.
This commit is contained in:
		
							parent
							
								
									cbe099dcc7
								
							
						
					
					
						commit
						bb82b6dada
					
				|  | @ -178,15 +178,12 @@ struct wlr_client_buffer *wlr_client_buffer_get(struct wlr_buffer *buffer); | |||
|  */ | ||||
| bool wlr_resource_is_buffer(struct wl_resource *resource); | ||||
| /**
 | ||||
|  * Try to update the buffer's content. On success, returns the updated buffer | ||||
|  * and destroys the provided `buffer`. On error, `buffer` is intact and NULL is | ||||
|  * returned. | ||||
|  * Try to update the buffer's content. | ||||
|  * | ||||
|  * Fails if there's more than one reference to the buffer or if the texture | ||||
|  * isn't mutable. | ||||
|  */ | ||||
| struct wlr_client_buffer *wlr_client_buffer_apply_damage( | ||||
| 	struct wlr_client_buffer *buffer, struct wlr_buffer *next, | ||||
| 	pixman_region32_t *damage); | ||||
| bool wlr_client_buffer_apply_damage(struct wlr_client_buffer *client_buffer, | ||||
| 	struct wlr_buffer *next, pixman_region32_t *damage); | ||||
| 
 | ||||
| #endif | ||||
|  |  | |||
|  | @ -271,36 +271,35 @@ struct wlr_client_buffer *wlr_client_buffer_create(struct wlr_buffer *buffer, | |||
| 	return client_buffer; | ||||
| } | ||||
| 
 | ||||
| struct wlr_client_buffer *wlr_client_buffer_apply_damage( | ||||
| 		struct wlr_client_buffer *client_buffer, struct wlr_buffer *next, | ||||
| 		pixman_region32_t *damage) { | ||||
| bool wlr_client_buffer_apply_damage(struct wlr_client_buffer *client_buffer, | ||||
| 		struct wlr_buffer *next, pixman_region32_t *damage) { | ||||
| 	if (client_buffer->base.n_locks > 1) { | ||||
| 		// Someone else still has a reference to the buffer
 | ||||
| 		return NULL; | ||||
| 		return false; | ||||
| 	} | ||||
| 
 | ||||
| 	if ((uint32_t)next->width != client_buffer->texture->width || | ||||
| 			(uint32_t)next->height != client_buffer->texture->height) { | ||||
| 		return NULL; | ||||
| 		return false; | ||||
| 	} | ||||
| 
 | ||||
| 	if (client_buffer->shm_source_format == DRM_FORMAT_INVALID) { | ||||
| 		// Uploading only damaged regions only works for wl_shm buffers and
 | ||||
| 		// mutable textures (created from wl_shm buffer)
 | ||||
| 		return NULL; | ||||
| 		return false; | ||||
| 	} | ||||
| 
 | ||||
| 	void *data; | ||||
| 	uint32_t format; | ||||
| 	size_t stride; | ||||
| 	if (!buffer_begin_data_ptr_access(next, &data, &format, &stride)) { | ||||
| 		return NULL; | ||||
| 		return false; | ||||
| 	} | ||||
| 
 | ||||
| 	if (format != client_buffer->shm_source_format) { | ||||
| 		// Uploading to textures can't change the format
 | ||||
| 		buffer_end_data_ptr_access(next); | ||||
| 		return NULL; | ||||
| 		return false; | ||||
| 	} | ||||
| 
 | ||||
| 	int n; | ||||
|  | @ -311,13 +310,13 @@ struct wlr_client_buffer *wlr_client_buffer_apply_damage( | |||
| 				r->x2 - r->x1, r->y2 - r->y1, r->x1, r->y1, | ||||
| 				r->x1, r->y1, data)) { | ||||
| 			buffer_end_data_ptr_access(next); | ||||
| 			return NULL; | ||||
| 			return false; | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	buffer_end_data_ptr_access(next); | ||||
| 
 | ||||
| 	return client_buffer; | ||||
| 	return true; | ||||
| } | ||||
| 
 | ||||
| static const struct wlr_buffer_impl shm_client_buffer_impl; | ||||
|  |  | |||
|  | @ -364,13 +364,10 @@ static void surface_apply_damage(struct wlr_surface *surface) { | |||
| 	} | ||||
| 
 | ||||
| 	if (surface->buffer != NULL) { | ||||
| 		struct wlr_client_buffer *updated_buffer = | ||||
| 			wlr_client_buffer_apply_damage(surface->buffer, | ||||
| 			surface->current.buffer, &surface->buffer_damage); | ||||
| 		if (updated_buffer != NULL) { | ||||
| 		if (wlr_client_buffer_apply_damage(surface->buffer, | ||||
| 				surface->current.buffer, &surface->buffer_damage)) { | ||||
| 			wlr_buffer_unlock(surface->current.buffer); | ||||
| 			surface->current.buffer = NULL; | ||||
| 			surface->buffer = updated_buffer; | ||||
| 			return; | ||||
| 		} | ||||
| 	} | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue