fix crash on buffer culling

This commit is contained in:
Leon Henrik Plickat 2023-08-14 01:58:20 +02:00
commit cb1e04cc76

View file

@ -413,12 +413,14 @@ static struct Buffer *buffer_pool_new_buffer (uint32_t width, uint32_t height)
return buffer; return buffer;
} }
static void buffer_pool_cull_buffers (void) static void buffer_pool_cull_buffers (struct Buffer *skip)
{ {
int to_remove = wl_list_length(&buffer_pool) - (max_buffer_multiplicity * surface_amount); int to_remove = wl_list_length(&buffer_pool) - (max_buffer_multiplicity * surface_amount);
struct Buffer *buffer, *tmp; struct Buffer *buffer, *tmp;
wl_list_for_each_safe(buffer, tmp, &buffer_pool, link) wl_list_for_each_safe(buffer, tmp, &buffer_pool, link)
{ {
if ( buffer == skip )
continue;
if ( to_remove == 0 ) if ( to_remove == 0 )
break; break;
if (buffer->busy) if (buffer->busy)
@ -440,7 +442,7 @@ static struct Buffer *buffer_pool_next_buffer (uint32_t width, uint32_t height)
ret = buffer_pool_new_buffer(width, height); ret = buffer_pool_new_buffer(width, height);
if ( wl_list_length(&buffer_pool) > max_buffer_multiplicity * surface_amount ) if ( wl_list_length(&buffer_pool) > max_buffer_multiplicity * surface_amount )
buffer_pool_cull_buffers(); buffer_pool_cull_buffers(ret);
return ret; return ret;
} }
@ -454,6 +456,7 @@ static void buffer_pool_destroy_all_buffers (void)
buffer_destroy(buffer); buffer_destroy(buffer);
} }
} }
/*********** /***********
* * * *
* Atlas * * Atlas *
@ -557,7 +560,7 @@ static void animation_neko_do_run_left (void)
static bool animation_can_run_right (void) static bool animation_can_run_right (void)
{ {
return surface.neko_x < surface.width - neko_size; return surface.neko_x < surface.width - neko_size - neko_x_advance;
} }
static void animation_neko_do_run_right (void) static void animation_neko_do_run_right (void)
@ -743,8 +746,13 @@ static void surface_next_frame (void)
if ( buffer == NULL ) if ( buffer == NULL )
return; return;
pixman_image_fill_rectangles(PIXMAN_OP_CLEAR, buffer->pixman_image, &bg_colour, pixman_image_fill_rectangles(
1, &(pixman_rectangle16_t){ (int16_t)surface.prev_neko_x, (int16_t)0, (uint16_t)neko_size, (uint16_t)neko_size, }); PIXMAN_OP_CLEAR, buffer->pixman_image, &bg_colour,
1, &(pixman_rectangle16_t){
(int16_t)surface.prev_neko_x, (int16_t)0,
(uint16_t)neko_size, (uint16_t)neko_size,
}
);
atlas_composite_neko(buffer, current_neko, surface.neko_x, 0); atlas_composite_neko(buffer, current_neko, surface.neko_x, 0);
wl_surface_set_buffer_scale(surface.wl_surface, 1); wl_surface_set_buffer_scale(surface.wl_surface, 1);