format code

This commit is contained in:
xianjimli 2020-06-05 17:16:19 +08:00
parent 1880868939
commit edf44dca47
21 changed files with 2060 additions and 712 deletions

View File

@ -769,7 +769,7 @@ static ret_t on_screen_saver(void* ctx, event_t* e) {
static ret_t on_key_record_play_events(void* ctx, event_t* e) {
#ifdef WITH_EVENT_RECORDER_PLAYER
key_event_t* evt = (key_event_t*)e;
if (evt->key == TK_KEY_F5) {
event_recorder_player_start_record("event_log.bin");
return RET_STOP;

View File

@ -618,7 +618,6 @@ canvas_t* canvas_cast(canvas_t* c);
*/
ret_t canvas_reset(canvas_t* c);
/**
* @method canvas_draw_image_at
*
@ -703,7 +702,6 @@ ret_t canvas_set_assets_manager(canvas_t* c, assets_manager_t* assets_manager);
*/
ret_t canvas_begin_frame(canvas_t* c, rect_t* dirty_rect, lcd_draw_mode_t draw_mode);
/**
* @method canvas_end_frame
*

View File

@ -608,7 +608,6 @@ bool_t lcd_is_swappable(lcd_t* lcd);
*/
ret_t lcd_end_frame(lcd_t* lcd);
/**
* @method lcd_destroy
* lcd对象

View File

@ -1063,7 +1063,7 @@ ret_t widget_dispatch_recursive(widget_t* widget, event_t* e) {
}
uint32_t widget_on_with_tag(widget_t* widget, uint32_t type, event_func_t on_event, void* ctx,
uint32_t tag) {
uint32_t tag) {
return_value_if_fail(widget != NULL && on_event != NULL, RET_BAD_PARAMS);
if (widget->emitter == NULL) {
widget->emitter = emitter_create();
@ -1077,7 +1077,7 @@ uint32_t widget_on(widget_t* widget, uint32_t type, event_func_t on_event, void*
}
uint32_t widget_child_on(widget_t* widget, const char* name, uint32_t type, event_func_t on_event,
void* ctx) {
void* ctx) {
return widget_on(widget_lookup(widget, name, TRUE), type, on_event, ctx);
}

View File

@ -1302,7 +1302,7 @@ uint32_t widget_on(widget_t* widget, uint32_t type, event_func_t on_event, void*
* @return {uint32_t} idwidget_off
*/
uint32_t widget_on_with_tag(widget_t* widget, uint32_t type, event_func_t on_event, void* ctx,
uint32_t tag);
uint32_t tag);
/**
* @method widget_off
@ -1328,7 +1328,7 @@ ret_t widget_off(widget_t* widget, uint32_t id);
* @return {uint32_t} idwidget_off
*/
uint32_t widget_child_on(widget_t* widget, const char* name, uint32_t type, event_func_t on_event,
void* ctx);
void* ctx);
/**
* @method widget_off_by_func

View File

@ -120,10 +120,10 @@ ret_t soft_clear_rect(bitmap_t* dst, rect_t* dst_r, color_t c) {
case BITMAP_FMT_RGBA8888: {
return clear_rgba8888_rect(dst, dst_r, c);
}
#ifndef LCD_BGR565_LITE
#ifndef LCD_BGR565_LITE
case BITMAP_FMT_RGB565: {
return clear_rgb565_rect(dst, dst_r, c);
}
}
case BITMAP_FMT_BGR888: {
return clear_bgr888_rect(dst, dst_r, c);
}
@ -139,7 +139,7 @@ ret_t soft_clear_rect(bitmap_t* dst, rect_t* dst_r, color_t c) {
case BITMAP_FMT_ABGR8888: {
return clear_abgr8888_rect(dst, dst_r, c);
}
#endif/*LCD_BGR565_LITE*/
#endif /*LCD_BGR565_LITE*/
default:
break;
}
@ -159,11 +159,11 @@ ret_t soft_fill_rect(bitmap_t* dst, rect_t* dst_r, color_t c) {
case BITMAP_FMT_RGBA8888: {
return fill_rgba8888_rect(dst, dst_r, c);
}
#ifndef LCD_BGR565_LITE
#ifndef LCD_BGR565_LITE
case BITMAP_FMT_RGB565: {
return fill_rgb565_rect(dst, dst_r, c);
}
}
case BITMAP_FMT_BGR888: {
return fill_bgr888_rect(dst, dst_r, c);
}
@ -179,7 +179,7 @@ ret_t soft_fill_rect(bitmap_t* dst, rect_t* dst_r, color_t c) {
case BITMAP_FMT_ABGR8888: {
return fill_abgr8888_rect(dst, dst_r, c);
}
#endif/*LCD_BGR565_LITE*/
#endif /*LCD_BGR565_LITE*/
default:
break;
}
@ -196,11 +196,11 @@ ret_t soft_rotate_image(bitmap_t* dst, bitmap_t* src, rect_t* src_r, lcd_orienta
switch (dst->format) {
case BITMAP_FMT_BGR565: {
return rotate_bgr565_image(dst, src, src_r, o);
}
}
case BITMAP_FMT_RGBA8888: {
return rotate_rgba8888_image(dst, src, src_r, o);
}
#ifndef LCD_BGR565_LITE
#ifndef LCD_BGR565_LITE
case BITMAP_FMT_RGB565: {
return rotate_rgb565_image(dst, src, src_r, o);
}
@ -213,7 +213,7 @@ ret_t soft_rotate_image(bitmap_t* dst, bitmap_t* src, rect_t* src_r, lcd_orienta
case BITMAP_FMT_BGRA8888: {
return rotate_bgra8888_image(dst, src, src_r, o);
}
#endif/*LCD_BGR565_LITE*/
#endif /*LCD_BGR565_LITE*/
default:
break;
}
@ -240,20 +240,20 @@ ret_t soft_blend_image(bitmap_t* dst, bitmap_t* src, rect_t* dst_r, rect_t* src_
case BITMAP_FMT_RGBA8888: {
return blend_image_bgr565_rgba8888(dst, src, dst_r, src_r, alpha);
}
#ifndef LCD_BGR565_LITE
#ifndef LCD_BGR565_LITE
case BITMAP_FMT_RGB565: {
return blend_image_bgr565_rgb565(dst, src, dst_r, src_r, alpha);
}
case BITMAP_FMT_BGRA8888: {
return blend_image_bgr565_bgra8888(dst, src, dst_r, src_r, alpha);
}
#endif/*LCD_BGR565_LITE*/
#endif /*LCD_BGR565_LITE*/
default:
break;
}
break;
}
#ifndef LCD_BGR565_LITE
#ifndef LCD_BGR565_LITE
case BITMAP_FMT_RGB565: {
switch (src->format) {
case BITMAP_FMT_RGB565: {
@ -367,7 +367,7 @@ ret_t soft_blend_image(bitmap_t* dst, bitmap_t* src, rect_t* dst_r, rect_t* src_
}
break;
}
#endif/*LCD_BGR565_LITE*/
#endif /*LCD_BGR565_LITE*/
default:
break;
}

View File

@ -55,7 +55,7 @@ ret_t file_browser_view_set_filter(widget_t* widget, const char* filter) {
file_browser_set_filter(file_browser_view->fb, fb_filter_files_only, NULL);
} else if (tk_str_eq(filter, STR_FILTER_DIR_ONLY)) {
file_browser_set_filter(file_browser_view->fb, fb_filter_directories_only, NULL);
} else if(filter != NULL) {
} else if (filter != NULL) {
file_browser_set_filter(file_browser_view->fb, fb_filter_by_ext_names,
file_browser_view->filter);
} else {

View File

@ -76,7 +76,7 @@ typedef struct _file_browser_view_t {
*
*/
char* init_dir;
/**
* @property {char*} filter
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]

View File

@ -85,7 +85,7 @@ lcd_t* lcd_mem_bgr565_create_double_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8
* @return {lcd_t*} lcd对象
*/
lcd_t* lcd_mem_bgr565_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb,
uint8_t* next_fb);
uint8_t* next_fb);
END_C_DECLS

View File

@ -87,7 +87,6 @@ lcd_t* lcd_mem_bgra8888_create_double_fb(wh_t w, wh_t h, uint8_t* online_fb, uin
lcd_t* lcd_mem_bgra8888_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb,
uint8_t* next_fb);
END_C_DECLS
#endif /*TK_LCD_MEM_BGRA8888_H*/

View File

@ -85,8 +85,7 @@ lcd_t* lcd_mem_rgb565_create_double_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8
* @return {lcd_t*} lcd对象
*/
lcd_t* lcd_mem_rgb565_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb,
uint8_t* next_fb);
uint8_t* next_fb);
END_C_DECLS

View File

@ -165,18 +165,17 @@ tk_iostream_t* tk_iostream_serial_create(const char* port) {
return TK_IOSTREAM(obj);
}
ret_t tk_iostream_serial_config(tk_iostream_t* iostream, int32_t baudrate,
bytesize_t bytesize, parity_t parity, stopbits_t stopbits, flowcontrol_t flowcontrol) {
return_value_if_fail(iostream != NULL, RET_BAD_PARAMS);
ret_t tk_iostream_serial_config(tk_iostream_t* iostream, int32_t baudrate, bytesize_t bytesize,
parity_t parity, stopbits_t stopbits, flowcontrol_t flowcontrol) {
return_value_if_fail(iostream != NULL, RET_BAD_PARAMS);
object_set_prop_int(OBJECT(iostream), TK_IOSTREAM_SERIAL_PROP_STOPBITS, stopbits);
object_set_prop_int(OBJECT(iostream), TK_IOSTREAM_SERIAL_PROP_BAUDRATE, baudrate);
object_set_prop_int(OBJECT(iostream), TK_IOSTREAM_SERIAL_PROP_PARITY, parity);
object_set_prop_int(OBJECT(iostream), TK_IOSTREAM_SERIAL_PROP_BYTESIZE, bytesize);
object_set_prop_int(OBJECT(iostream), TK_IOSTREAM_SERIAL_PROP_FLOWCONTROL, flowcontrol);
object_set_prop_int(OBJECT(iostream), TK_IOSTREAM_SERIAL_PROP_STOPBITS, stopbits);
object_set_prop_int(OBJECT(iostream), TK_IOSTREAM_SERIAL_PROP_BAUDRATE, baudrate);
object_set_prop_int(OBJECT(iostream), TK_IOSTREAM_SERIAL_PROP_PARITY, parity);
object_set_prop_int(OBJECT(iostream), TK_IOSTREAM_SERIAL_PROP_BYTESIZE, bytesize);
object_set_prop_int(OBJECT(iostream), TK_IOSTREAM_SERIAL_PROP_FLOWCONTROL, flowcontrol);
object_exec(OBJECT(iostream), TK_IOSTREAM_SERIAL_CMD_CONFIG, NULL);
return RET_OK;
}

View File

@ -64,7 +64,6 @@ struct _tk_iostream_serial_t {
*/
tk_iostream_t* tk_iostream_serial_create(const char* port);
/**
* @method tk_iostream_serial_config
*
@ -80,8 +79,8 @@ tk_iostream_t* tk_iostream_serial_create(const char* port);
* @return {ret_t} RET_OK表示成功
*
*/
ret_t tk_iostream_serial_config(tk_iostream_t* iostream, int32_t baudrate,
bytesize_t bytesize, parity_t parity, stopbits_t stopbits, flowcontrol_t flowcontrol);
ret_t tk_iostream_serial_config(tk_iostream_t* iostream, int32_t baudrate, bytesize_t bytesize,
parity_t parity, stopbits_t stopbits, flowcontrol_t flowcontrol);
#define TK_IOSTREAM_SERIAL_PROP_PARITY "parity"
#define TK_IOSTREAM_SERIAL_PROP_STOPBITS "stopbits"

View File

@ -192,9 +192,7 @@ ret_t path_normalize(const char* path, char* result, int32_t size) {
}
break;
}
default: {
*d++ = *s++;
}
default: { *d++ = *s++; }
}
}

View File

@ -334,9 +334,9 @@ TEST(DArrayTest, bsearch) {
#include "tkc/mem.h"
typedef struct _my_data_t {
char name[TK_NAME_LEN+1];
char name[TK_NAME_LEN + 1];
int value;
}my_data_t;
} my_data_t;
static my_data_t* my_data_create(const char* name, int value) {
my_data_t* data = TKMEM_ZALLOC(my_data_t);
@ -361,13 +361,13 @@ TEST(DArrayTest, struct) {
darray_push(&darray, my_data_create("jack", 100));
darray_push(&darray, my_data_create("tom", 10));
ASSERT_EQ(darray.size, 2);
p = (my_data_t*)darray_get(&darray, 0);
ASSERT_STREQ(p->name, "jack");
ASSERT_EQ(p->value, 100);
p = (my_data_t*)darray_get(&darray, 1);
ASSERT_STREQ(p->name, "tom");
ASSERT_EQ(p->value, 10);

View File

@ -48,4 +48,4 @@ TEST(FontGen, basic) {
TKMEM_FREE(bmp_buff);
TKMEM_FREE(ttf_buff);
}
#endif/**/
#endif /**/

View File

@ -28,7 +28,7 @@ TEST(Label, value) {
widget_t* l = label_create(NULL, 10, 20, 30, 40);
ASSERT_EQ(widget_set_value(l, 100), RET_OK);
ASSERT_EQ(widget_get_value(l), 100);
ASSERT_EQ(widget_add_value(l, 100), RET_OK);
ASSERT_EQ(widget_get_value(l), 200);

View File

@ -65,10 +65,10 @@ TEST(Path, normalize) {
ASSERT_EQ(path_normalize("/a/b", result, sizeof(result)), RET_OK);
ASSERT_EQ(string(result), normalPath("/a/b"));
ASSERT_EQ(path_normalize("/a//b", result, sizeof(result)), RET_OK);
ASSERT_EQ(string(result), normalPath("/a/b"));
ASSERT_EQ(path_normalize("/a//./////././/b", result, sizeof(result)), RET_OK);
ASSERT_EQ(string(result), normalPath("/a/b"));
@ -98,19 +98,19 @@ TEST(Path, normalize) {
ASSERT_EQ(path_normalize("/a/b/../../c", result, sizeof(result)), RET_OK);
ASSERT_EQ(string(result), normalPath("/c"));
ASSERT_EQ(path_normalize("/a/b/../", result, sizeof(result)), RET_OK);
ASSERT_EQ(string(result), normalPath("/a/"));
ASSERT_EQ(path_normalize("/a/b/..", result, sizeof(result)), RET_OK);
ASSERT_EQ(string(result), normalPath("/a/"));
ASSERT_EQ(path_normalize("/a/b/..\\", result, sizeof(result)), RET_OK);
ASSERT_EQ(string(result), normalPath("/a/"));
ASSERT_EQ(path_normalize("/a/b\\..", result, sizeof(result)), RET_OK);
ASSERT_EQ(string(result), normalPath("/a/"));
ASSERT_EQ(path_normalize("\\a\\b/../../c", result, sizeof(result)), RET_OK);
ASSERT_EQ(string(result), normalPath("/c"));
}

File diff suppressed because it is too large Load Diff

View File

@ -26,7 +26,8 @@
BEGIN_C_DECLS
ret_t image_dither_load_image(const uint8_t* buff, uint32_t buff_size, bitmap_t* image, bitmap_format_t bitmap_format);
ret_t image_dither_load_image(const uint8_t* buff, uint32_t buff_size, bitmap_t* image,
bitmap_format_t bitmap_format);
ret_t image_dither_image_wirte_png_file(const char* output_file, bitmap_t* image);

View File

@ -42,11 +42,10 @@ bitmap_format_t get_image_format(const wchar_t* format) {
} else if (wcsstr(format, L"rgba")) {
return BITMAP_FMT_RGBA8888;
} else if (wcsstr(format, L"bgr565")) {
return BITMAP_FMT_BGR565;
return BITMAP_FMT_BGR565;
} else if (wcsstr(format, L"rgb565")) {
return BITMAP_FMT_RGB565;
};
}
return BITMAP_FMT_NONE;
}
@ -65,7 +64,6 @@ output_format_t get_output_format(const wchar_t* format) {
}
ret_t res_image_gen(str_t* out_file, bitmap_t* bitmap, const char* theme) {
str_t temp_file;
uint32_t size = 0;
uint8_t* buff = NULL;
@ -80,7 +78,8 @@ ret_t res_image_gen(str_t* out_file, bitmap_t* bitmap, const char* theme) {
buff = (uint8_t*)read_file(temp_file.str, &size);
if (buff != NULL) {
ret = output_res_c_source(out_file->str, theme, ASSET_TYPE_IMAGE, ASSET_TYPE_IMAGE_PNG, buff, size);
ret = output_res_c_source(out_file->str, theme, ASSET_TYPE_IMAGE, ASSET_TYPE_IMAGE_PNG, buff,
size);
}
file_remove(temp_file.str);
@ -99,7 +98,6 @@ ret_t gen_one(str_t* in_file, str_t* out_file, const char* theme, output_format_
uint8_t* buff = NULL;
buff = (uint8_t*)read_file(in_file->str, &size);
if (buff != NULL) {
if (output_format == OUTPUT_FORMAT_DATA) {
ret = image_dither_load_image(buff, size, &bitmap, image_format);
if (ret == RET_OK) {
@ -107,13 +105,13 @@ ret_t gen_one(str_t* in_file, str_t* out_file, const char* theme, output_format_
}
} else {
bitmap_format_t temp_image_format = BITMAP_FMT_RGBA8888;
if(image_format == BITMAP_FMT_BGRA8888) {
if (image_format == BITMAP_FMT_BGRA8888) {
temp_image_format = BITMAP_FMT_BGRA8888;
}
ret = image_dither_load_image(buff, size, &bitmap, temp_image_format);
if (ret == RET_OK) {
if(output_format == OUTPUT_FORMAT_RES) {
if (output_format == OUTPUT_FORMAT_RES) {
res_image_gen(out_file, &bitmap, theme);
} else {
image_dither_image_wirte_png_file(out_file->str, &bitmap);
@ -134,7 +132,6 @@ ret_t gen_one(str_t* in_file, str_t* out_file, const char* theme, output_format_
}
int wmain(int argc, wchar_t* argv[]) {
str_t in_file;
str_t out_file;
@ -148,7 +145,8 @@ int wmain(int argc, wchar_t* argv[]) {
TKMEM_INIT(4 * 1024 * 1024);
if (argc < 4) {
printf("Usage: %S in_filename out_filename (png|res|data) (bgra|rgba|bgr565|rgb565) \n", argv[0]);
printf("Usage: %S in_filename out_filename (png|res|data) (bgra|rgba|bgr565|rgb565) \n",
argv[0]);
return 0;
}
@ -167,7 +165,7 @@ int wmain(int argc, wchar_t* argv[]) {
format = argv[4];
}
image_format = get_image_format(format);
image_format = get_image_format(format);
if (image_format == BITMAP_FMT_NONE && output_format == OUTPUT_FORMAT_DATA) {
printf("set (bgra|rgba|bgr565|rgb565) \n");
return 0;