This commit is contained in:
刘可亮
2025-07-22 11:15:46 +08:00
parent d164b333ed
commit 11c97ef399
2870 changed files with 951307 additions and 26675 deletions

View File

@@ -11,6 +11,13 @@
#include "../stdlib/lv_string.h"
#include "../core/lv_global.h"
#ifdef LV_MEM_HEAP_ADAPTIVE_SUPPORT
#include "aic_core.h"
#ifndef LV_USE_CMA_HEAP_LOW_LIMIT
#define LV_USE_CMA_HEAP_LOW_LIMIT (1024 * 48)
#endif // LV_USE_CMA_HEAP_LOW_LIMIT
#endif // LV_MEM_HEAP_ADAPTIVE_SUPPORT
/*********************
* DEFINES
*********************/
@@ -227,6 +234,13 @@ lv_draw_buf_t * lv_draw_buf_create(uint32_t w, uint32_t h, lv_color_format_t cf,
draw_buf->data = lv_draw_buf_align(buf, cf);
draw_buf->unaligned_data = buf;
draw_buf->data_size = size;
#ifdef LV_MEM_HEAP_ADAPTIVE_SUPPORT
if (size >= LV_USE_CMA_HEAP_LOW_LIMIT) {
draw_buf->header.flags |= LV_IMAGE_FLAGS_USER2;
}
#endif // LV_MEM_HEAP_ADAPTIVE_SUPPORT
return draw_buf;
}
@@ -277,7 +291,15 @@ void lv_draw_buf_destroy(lv_draw_buf_t * buf)
if(buf == NULL) return;
if(buf->header.flags & LV_IMAGE_FLAGS_ALLOCATED) {
#ifndef LV_MEM_HEAP_ADAPTIVE_SUPPORT
draw_buf_free(buf->unaligned_data);
#else
if (buf->header.flags & LV_IMAGE_FLAGS_USER2) {
aicos_free(MEM_CMA, (void*)buf->unaligned_data);
} else {
draw_buf_free(buf->unaligned_data);
}
#endif // LV_MEM_HEAP_ADAPTIVE_SUPPORT
lv_free(buf);
}
else {
@@ -462,7 +484,15 @@ static void * buf_malloc(size_t size_bytes, lv_color_format_t color_format)
/*Allocate larger memory to be sure it can be aligned as needed*/
size_bytes += LV_DRAW_BUF_ALIGN - 1;
#ifndef LV_MEM_HEAP_ADAPTIVE_SUPPORT
return lv_malloc(size_bytes);
#else
if (size_bytes >= LV_USE_CMA_HEAP_LOW_LIMIT) {
return (void *)aicos_malloc_try_cma(size_bytes);
} else {
return lv_malloc(size_bytes);
}
#endif // LV_MEM_HEAP_ADAPTIVE_SUPPORT
}
static void buf_free(void * buf)

View File

@@ -8,6 +8,8 @@
#include <string.h>
#include <stdbool.h>
#include <aic_core.h>
#define MIN(A, B) ((A) < (B) ? (A) : (B))
#define MAX(A, B) ((A) > (B) ? (A) : (B))
@@ -114,9 +116,13 @@ static gd_GIF * gif_open(gd_GIF * gif_base)
f_gif_read(gif_base, &aspect, 1);
/* Create gd_GIF Structure. */
#if LV_GIF_CACHE_DECODE_DATA
gif = lv_malloc(sizeof(gd_GIF) + 5 * width * height + LZW_CACHE_SIZE);
gif = (gd_GIF *)aicos_malloc_try_cma(sizeof(gd_GIF) + 5 * width * height + LZW_CACHE_SIZE);
aicos_dcache_clean_invalid_range((ulong *)gif,
(ulong)ALIGN_UP(sizeof(gd_GIF) + 5 * width * height + LZW_CACHE_SIZE, CACHE_LINE_SIZE));
#else
gif = lv_malloc(sizeof(gd_GIF) + 5 * width * height);
gif = (gd_GIF *)aicos_malloc_try_cma(sizeof(gd_GIF) + 5 * width * height);
aicos_dcache_clean_invalid_range((ulong *)gif,
(ulong)ALIGN_UP(sizeof(gd_GIF) + 5 * width * height, CACHE_LINE_SIZE));
#endif
if(!gif) goto fail;
memcpy(gif, gif_base, sizeof(gd_GIF));

View File

@@ -11,6 +11,8 @@
#include "gifdec.h"
#include <aic_core.h>
/*********************
* DEFINES
*********************/
@@ -183,6 +185,11 @@ static void next_frame_task_cb(lv_timer_t * t)
gd_render_frame(gifobj->gif, (uint8_t *)gifobj->imgdsc.data);
/* gif decode image format = LV_COLOR_FORMAT_ARGB8888, bpp = 32 */
uint32_t flush_size = gifobj->imgdsc.header.h * 4 * gifobj->imgdsc.header.w;
aicos_dcache_clean_invalid_range((unsigned long *)gifobj->imgdsc.data,
(unsigned long)ALIGN_UP(flush_size, CACHE_LINE_SIZE));
lv_image_cache_drop(lv_image_get_src(obj));
lv_obj_invalidate(obj);
}

View File

@@ -245,6 +245,7 @@ static inline void lv_obj_move_background(lv_obj_t * obj)
#define lv_obj_set_style_bg_img_src lv_obj_set_style_bg_image_src
#define lv_obj_set_style_bg_img_recolor lv_obj_set_style_bg_image_recolor
#define lv_obj_set_style_bg_img_recolor_opa lv_obj_set_style_bg_image_recolor_opa
#define lv_obj_set_style_arc_img_src lv_obj_set_style_arc_image_src
#define lv_style_set_anim_time lv_style_set_anim_duration
#define lv_style_set_img_opa lv_style_set_image_opa

View File

@@ -274,14 +274,14 @@ static void mem_observer_cb(lv_observer_t * observer, lv_subject_t * subject)
lv_obj_t * label = lv_observer_get_target(observer);
const lv_mem_monitor_t * mon = lv_subject_get_pointer(subject);
size_t used_size = mon->total_size - mon->free_size;;
size_t used_kb = used_size / 1024;
size_t used_kb_tenth = (used_size - (used_kb * 1024)) / 102;
size_t max_used_kb = mon->max_used / 1024;
size_t max_used_kb_tenth = (mon->max_used - (max_used_kb * 1024)) / 102;
unsigned long used_size = mon->total_size - mon->free_size;;
unsigned long used_kb = used_size / 1024;
unsigned long used_kb_tenth = (used_size - (used_kb * 1024)) / 102;
unsigned long max_used_kb = mon->max_used / 1024;
unsigned long max_used_kb_tenth = (mon->max_used - (max_used_kb * 1024)) / 102;
lv_label_set_text_fmt(label,
"%zu.%zu kB (%d%%)\n"
"%zu.%zu kB max, %d%% frag.",
"%lu.%lu kB (%d%%)\n"
"%lu.%lu kB max, %d%% frag.",
used_kb, used_kb_tenth, mon->used_pct,
max_used_kb, max_used_kb_tenth,
mon->frag_pct);

View File

@@ -58,6 +58,26 @@ lv_result_t lv_mem_test_core(void);
/**********************
* GLOBAL FUNCTIONS
**********************/
#if defined(KERNEL_RTTHREAD) && defined(RT_USING_MEMTRACE) && defined(RT_USING_FINSH)
#include <rtdef.h>
#include <rtthread.h>
extern int msh_exec(char *cmd, rt_size_t length);
int rtt_cmd_exec(char *command)
{
static char cmd[256] = {0};
strncpy(cmd, command, sizeof(cmd) - 1);
cmd[sizeof(cmd) - 1] = '\0';
return msh_exec(cmd, strlen(cmd));
}
static void rtt_memheaptrace_debug(void)
{
rtt_cmd_exec("memheaptrace");
rt_kprintf("lvgl thread mdelay 9999999 ms\n");
rt_thread_mdelay(9999999);
}
#endif
void * lv_malloc(size_t size)
{
@@ -70,7 +90,10 @@ void * lv_malloc(size_t size)
void * alloc = lv_malloc_core(size);
if(alloc == NULL) {
LV_LOG_INFO("couldn't allocate memory (%lu bytes)", (unsigned long)size);
LV_LOG_ERROR("couldn't allocate memory (%lu bytes)", (unsigned long)size);
#if defined(KERNEL_RTTHREAD) && defined(RT_USING_MEMTRACE) && defined(RT_USING_FINSH)
rtt_memheaptrace_debug();
#endif
#if LV_LOG_LEVEL <= LV_LOG_LEVEL_INFO
lv_mem_monitor_t mon;
lv_mem_monitor(&mon);
@@ -99,7 +122,10 @@ void * lv_malloc_zeroed(size_t size)
void * alloc = lv_malloc_core(size);
if(alloc == NULL) {
LV_LOG_INFO("couldn't allocate memory (%lu bytes)", (unsigned long)size);
LV_LOG_ERROR("couldn't allocate memory (%lu bytes)", (unsigned long)size);
#if defined(KERNEL_RTTHREAD) && defined(RT_USING_MEMTRACE) && defined(RT_USING_FINSH)
rtt_memheaptrace_debug();
#endif
#if LV_LOG_LEVEL <= LV_LOG_LEVEL_INFO
lv_mem_monitor_t mon;
lv_mem_monitor(&mon);
@@ -140,6 +166,9 @@ void * lv_realloc(void * data_p, size_t new_size)
if(new_p == NULL) {
LV_LOG_ERROR("couldn't reallocate memory");
#if defined(KERNEL_RTTHREAD) && defined(RT_USING_MEMTRACE) && defined(RT_USING_FINSH)
rtt_memheaptrace_debug();
#endif
return NULL;
}

View File

@@ -38,7 +38,7 @@ typedef struct {
lv_anim_t anim;
/*picture sequence */
const void ** dsc;
int8_t pic_count;
int32_t pic_count;
} lv_animimg_t;
/*Image parts*/