mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	scene: Block damage on single-pixel buffer textures
We cache whether buffers are single-pixel buffers (and if so what color
they are) to allow rendering optimizations.  But this breaks if the
client changes out the single-pixel buffer for one with a different
color, because this updates the texture in-place instead of actually
changing the buffer.
We can fix this by blocking in-place texture updates for single pixel
buffers.
Original bug: https://codeberg.org/ifreund/waylock/issues/121
See also: !5092
(cherry picked from commit 58c3680d96)
			
			
This commit is contained in:
		
							parent
							
								
									68dea55970
								
							
						
					
					
						commit
						5aa8c192a5
					
				
					 1 changed files with 21 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -96,8 +96,11 @@ static void scene_buffer_unmark_client_buffer(struct wlr_scene_buffer *scene_buf
 | 
			
		|||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	assert(buffer->n_ignore_locks > 0);
 | 
			
		||||
	// If the buffer was a single-pixel buffer where we cached its color
 | 
			
		||||
	// then it won't have been marked as damage-allowed.
 | 
			
		||||
	if (buffer->n_ignore_locks > 0) {
 | 
			
		||||
		buffer->n_ignore_locks--;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int min(int a, int b) {
 | 
			
		||||
| 
						 | 
				
			
			@ -165,7 +168,22 @@ static void surface_reconfigure(struct wlr_scene_surface *scene_surface) {
 | 
			
		|||
	scene_buffer_unmark_client_buffer(scene_buffer);
 | 
			
		||||
 | 
			
		||||
	if (surface->buffer) {
 | 
			
		||||
		// If we've cached the buffer's single-pixel buffer color
 | 
			
		||||
		// then any in-place updates to the texture wouldn't be
 | 
			
		||||
		// reflected in rendering. So only allow in-place texture
 | 
			
		||||
		// updates if it's not a single pixel buffer.  Note that we
 | 
			
		||||
		// can't use the cached scene_buffer->is_single_pixel_buffer
 | 
			
		||||
		// because that's only set later on.
 | 
			
		||||
		bool is_single_pixel_buffer = false;
 | 
			
		||||
		struct wlr_client_buffer *client_buffer = wlr_client_buffer_get(&surface->buffer->base);
 | 
			
		||||
		if (client_buffer != NULL && client_buffer->source != NULL) {
 | 
			
		||||
			struct wlr_single_pixel_buffer_v1 *spb =
 | 
			
		||||
				wlr_single_pixel_buffer_v1_try_from_buffer(client_buffer->source);
 | 
			
		||||
			is_single_pixel_buffer = spb != NULL;
 | 
			
		||||
		}
 | 
			
		||||
		if (!is_single_pixel_buffer) {
 | 
			
		||||
			client_buffer_mark_next_can_damage(surface->buffer);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		struct wlr_linux_drm_syncobj_surface_v1_state *syncobj_surface_state =
 | 
			
		||||
			wlr_linux_drm_syncobj_v1_get_surface_state(surface);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue