diff --git a/demos/assets.c b/demos/assets.c index 054a70c5b..ffb046a7c 100644 --- a/demos/assets.c +++ b/demos/assets.c @@ -393,7 +393,7 @@ #include "assets/default/inc/images/visible.data" #include "assets/default/inc/images/warn.data" #include "assets/default/inc/images/zh.data" -#endif/*WITH_STB_IMAGE*/ +#endif /*WITH_STB_IMAGE*/ #ifdef WITH_VGCANVAS #include "assets/default/inc/images/ball.bsvg" #include "assets/default/inc/images/china.bsvg" @@ -401,13 +401,13 @@ #include "assets/default/inc/images/pointer.bsvg" #include "assets/default/inc/images/pointer_1.bsvg" #include "assets/default/inc/images/pointer_4.bsvg" -#endif/*WITH_VGCANVAS*/ +#endif /*WITH_VGCANVAS*/ #if defined(WITH_TRUETYPE_FONT) #include "assets/default/inc/fonts/default.res" -#else/*WITH_TRUETYPE_FONT*/ +#else /*WITH_TRUETYPE_FONT*/ #include "assets/default/inc/fonts/default.data" -#endif/*WITH_TRUETYPE_FONT*/ -#endif/*WITH_FS_RES*/ +#endif /*WITH_TRUETYPE_FONT*/ +#endif /*WITH_FS_RES*/ ret_t assets_init(void) { assets_manager_t* am = assets_manager(); @@ -693,7 +693,7 @@ ret_t assets_init(void) { assets_manager_add(am, image_pointer); assets_manager_add(am, image_pointer_1); assets_manager_add(am, image_pointer_4); -#endif/*WITH_VGCANVAS*/ +#endif /*WITH_VGCANVAS*/ #endif tk_init_assets(); diff --git a/demos/demo1_app.c b/demos/demo1_app.c index c34a6b6fb..009e6ea3f 100644 --- a/demos/demo1_app.c +++ b/demos/demo1_app.c @@ -137,6 +137,7 @@ ret_t application_init() { progress_bar = progress_bar_create(win, 260, 80, 20, 118); widget_set_value(progress_bar, 40); progress_bar_set_vertical(progress_bar, TRUE); + timer_add(on_timer, progress_bar, 500); slider = slider_create(win, 230, 80, 20, 118); widget_set_value(slider, 40); diff --git a/src/base/image_manager.c b/src/base/image_manager.c index 7474523bb..2485247fa 100644 --- a/src/base/image_manager.c +++ b/src/base/image_manager.c @@ -1,4 +1,4 @@ -/** +/** * File: image_manager.c * Author: AWTK Develop Team * Brief: bitmap manager @@ -178,11 +178,11 @@ static ret_t image_manager_get_bitmap_impl(image_manager_t* imm, const char* nam image->format = header->format; image->name = res->name; image->image_manager = imm; - image->buffer = - GRAPHIC_BUFFER_CREATE_WITH_DATA(header->data, header->w, header->h, header->format); -#if defined(WITH_NANOVG_GPU) || defined(WITH_NANOVG_SOFT) + image->buffer = GRAPHIC_BUFFER_CREATE_WITH_DATA(header->data, header->w, header->h, + (bitmap_format_t)(header->format)); + image_manager_add(imm, name, image); -#endif + return RET_OK; } else if (res->subtype != ASSET_TYPE_IMAGE_BSVG) { ret_t ret = image_loader_load_image(res, image); diff --git a/src/lcd/lcd_mem.inc b/src/lcd/lcd_mem.inc index c8d894e1e..25476c358 100644 --- a/src/lcd/lcd_mem.inc +++ b/src/lcd/lcd_mem.inc @@ -35,7 +35,8 @@ typedef struct _lcd_mem_graphic_buffer_cache_t { static darray_t lcd_mem_graphic_buffer_cache; -static int lcd_mem_graphic_buffer_cache_cmp(const lcd_mem_graphic_buffer_cache_t* a, const lcd_mem_graphic_buffer_cache_t* b) { +static int lcd_mem_graphic_buffer_cache_cmp(const lcd_mem_graphic_buffer_cache_t* a, + const lcd_mem_graphic_buffer_cache_t* b) { if (a->fb == b->fb) { return 0; } @@ -95,7 +96,8 @@ static bitmap_t* lcd_mem_init_online_fb(lcd_t* lcd, bitmap_t* fb, lcd_orientatio return fb; } -static inline graphic_buffer_t* lcd_mem_get_graphic_buffer(uint8_t* fb, uint32_t w, uint32_t h, bitmap_format_t format) { +static inline graphic_buffer_t* lcd_mem_get_graphic_buffer(uint8_t* fb, uint32_t w, uint32_t h, + bitmap_format_t format) { graphic_buffer_t* gb = NULL; lcd_mem_graphic_buffer_cache_t tmp; lcd_mem_graphic_buffer_cache_t* cache = NULL; @@ -107,12 +109,11 @@ static inline graphic_buffer_t* lcd_mem_get_graphic_buffer(uint8_t* fb, uint32_t if (cache == NULL) { cache = (lcd_mem_graphic_buffer_cache_t*)TKMEM_ZALLOC(lcd_mem_graphic_buffer_cache_t); gb = graphic_buffer_create_with_data(fb, w, h, format); - + cache->fb = fb; cache->gb = gb; darray_push(&lcd_mem_graphic_buffer_cache, cache); - } - else { + } else { gb = cache->gb; } return gb; @@ -428,7 +429,7 @@ static lcd_t* lcd_mem_create(wh_t w, wh_t h, bool_t alloc) { system_info_set_lcd_type(info, base->type); system_info_set_device_pixel_ratio(info, 1); - darray_init(&lcd_mem_graphic_buffer_cache, LCD_MEM_GRAPHIC_BUFFER_CACHE_MAX_NUMBER, + darray_init(&lcd_mem_graphic_buffer_cache, LCD_MEM_GRAPHIC_BUFFER_CACHE_MAX_NUMBER, (tk_destroy_t)lcd_mem_graphic_buffer_cache_destroy, (tk_compare_t)lcd_mem_graphic_buffer_cache_cmp); diff --git a/src/lcd/lcd_reg.inc b/src/lcd/lcd_reg.inc index 2c5d2f7aa..419efe35a 100644 --- a/src/lcd/lcd_reg.inc +++ b/src/lcd/lcd_reg.inc @@ -77,6 +77,8 @@ static inline ret_t lcd_reg_image_copy(lcd_t* lcd, bitmap_t* img, rect_t* src, r return_value_if_fail(src->w == dst->w && src->h == dst->h, RET_BAD_PARAMS); data = (pixel_t*)bitmap_lock_buffer_for_read(img); + return_value_if_fail(data != NULL, RET_BAD_PARAMS); + if (reg->ffb != NULL) { fragment_frame_buffer_image_copy(reg->ffb, img, src, dst); } else { @@ -190,6 +192,7 @@ static ret_t lcd_reg_draw_image_bgr565(lcd_t* lcd, bitmap_t* img, rect_t* src, r wh_t dh = dst->h; const uint16_t* data = (uint16_t*)bitmap_lock_buffer_for_read(img); + return_value_if_fail(data != NULL, RET_BAD_PARAMS); lcd_reg_set_window(lcd, x, y, x + dw - 1, y + dh - 1); if (src->w == dst->w && src->h == dst->h) { lcd_reg_image_copy(lcd, img, src, dst); @@ -231,6 +234,7 @@ static ret_t lcd_reg_draw_image_8888(lcd_t* lcd, bitmap_t* img, rect_t* src, rec pixel_t fill_pixel = color_to_pixel(fill_color); const color_t* data = (color_t*)bitmap_lock_buffer_for_read(img); + return_value_if_fail(data != NULL, RET_BAD_PARAMS); lcd_reg_set_window(lcd, x, y, x + dw - 1, y + dh - 1); if (src->w == dst->w && src->h == dst->h) { const color_t* src_p = data + img->w * src->y + src->x;