Merge branch 'sunli1/wlroots-output_layers_v3' into 'master'

wlr_scene: Implement Output Layers

See merge request wlroots/wlroots!4348
This commit is contained in:
Leo Li 2023-10-30 06:13:22 +00:00
commit 51e76f9000
6 changed files with 581 additions and 66 deletions

View file

@ -38,3 +38,26 @@ bool array_realloc(struct wl_array *arr, size_t size) {
arr->alloc = alloc;
return true;
}
void *array_reversed_start(struct wl_array *arr) {
char *data = arr->data;
return data + arr->alloc - arr->size;
}
void *array_reversed_add(struct wl_array *arr, size_t size) {
if (arr->size + size > arr->alloc) {
size_t new_alloc = arr->alloc * 2;
char *new = malloc(new_alloc);
if (!new) {
return NULL;
}
memcpy(new + (new_alloc - arr->size), array_reversed_start(arr), arr->size);
free(arr->data);
arr->data = new;
arr->alloc = new_alloc;
}
arr->size += size;
return array_reversed_start(arr);
}