fix(vg_lite): fix grad item not fully initialized (#8486)

Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com>
Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
This commit is contained in:
VIFEX
2025-06-26 16:50:49 +08:00
committed by GitHub
parent 3a4cf38ef3
commit 9d358afe67
+14 -12
View File
@@ -423,25 +423,27 @@ static grad_item_t * grad_item_pool_alloc(lv_vg_lite_grad_ctx_t * ctx, grad_type
grad_item_t * item = lv_ll_get_head(&ctx->item_pool);
/* Always get free nodes from the head */
/* Try to obtain a free node from the head */
if(item && item->type == GRAD_TYPE_FREE) {
item->type = type;
lv_ll_move_before(&ctx->item_pool, item, NULL);
LV_LOG_TRACE("reuse item: %p, type: %d", (void *)item, type);
return item;
}
item = lv_ll_ins_tail(&ctx->item_pool);
LV_ASSERT_MALLOC(item);
if(!item) {
LV_LOG_ERROR("alloc grad item failed");
return NULL;
}
else {
/* Allocate a new node if the pool is empty or all nodes are in use */
item = lv_ll_ins_tail(&ctx->item_pool);
LV_ASSERT_MALLOC(item);
if(!item) {
LV_LOG_ERROR("alloc grad item failed");
return NULL;
}
LV_LOG_TRACE("alloc new item: %p, type: %d, pool size: %" LV_PRIu32,
(void *)item, type, lv_ll_get_len(&ctx->item_pool));
}
lv_memzero(item, sizeof(grad_item_t));
item->ctx = ctx;
item->type = type;
LV_LOG_TRACE("alloc new item: %p, type: %d, pool size: %" LV_PRIu32,
(void *)item, type, lv_ll_get_len(&ctx->item_pool));
return item;
}