1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

Merge pull request #405 from aenchevich/dev-5.2

Fixing some compile-time errors and warning (on mipsel-gcc 4.6)
This commit is contained in:
Gabor Kiss-Vamosi 2018-09-14 12:19:20 +02:00 committed by GitHub
commit 071343da5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 295 additions and 321 deletions

View File

@ -21,7 +21,7 @@
* STATIC PROTOTYPES
**********************/
static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mask,
const void * src, const lv_style_t * style, lv_opa_t opa_scale);
const void * src, const lv_style_t * style, lv_opa_t opa_scale);
static const uint8_t * lv_img_decoder_open(const void * src, const lv_style_t * style);
static lv_res_t lv_img_decoder_read_line(lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t * buf);
@ -38,7 +38,7 @@ static lv_img_src_t decoder_src_type;
static lv_img_header_t decoder_header;
static const lv_style_t * decoder_style;
static lv_fs_file_t decoder_file;
static lv_color_t decoder_index_map[256] = {LV_COLOR_RED, LV_COLOR_BLUE, LV_COLOR_GREEN, LV_COLOR_PURPLE};
static lv_color_t decoder_index_map[256] = {{{0}}};
static lv_img_decoder_info_f_t lv_img_decoder_info_custom;
static lv_img_decoder_open_f_t lv_img_decoder_open_custom;
@ -102,8 +102,7 @@ lv_res_t lv_img_dsc_get_info(const char * src, lv_img_header_t * header)
lv_img_src_t src_type = lv_img_src_get_type(src);
if(src_type == LV_IMG_SRC_VARIABLE) {
header->cf =
header->w = ((lv_img_dsc_t *)src)->header.w;
header->w = ((lv_img_dsc_t *)src)->header.w;
header->h = ((lv_img_dsc_t *)src)->header.h;
header->cf = ((lv_img_dsc_t *)src)->header.cf;
}
@ -144,75 +143,75 @@ lv_res_t lv_img_dsc_get_info(const char * src, lv_img_header_t * header)
uint8_t lv_img_color_format_get_px_size(lv_img_cf_t cf)
{
switch(cf) {
case LV_IMG_CF_UNKOWN:
case LV_IMG_CF_RAW:
return 0;
case LV_IMG_CF_TRUE_COLOR:
case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED:
return LV_COLOR_SIZE;
case LV_IMG_CF_TRUE_COLOR_ALPHA:
switch(cf) {
case LV_IMG_CF_UNKOWN:
case LV_IMG_CF_RAW:
return 0;
case LV_IMG_CF_TRUE_COLOR:
case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED:
return LV_COLOR_SIZE;
case LV_IMG_CF_TRUE_COLOR_ALPHA:
#if LV_COLOR_DEPTH != 24
return LV_COLOR_SIZE;
return LV_COLOR_SIZE;
#else
return LV_COLOR_SIZE + 1;
return LV_COLOR_SIZE + 1;
#endif
case LV_IMG_CF_INDEXED_1BIT:
case LV_IMG_CF_ALPHA_1BIT:
return 1;
case LV_IMG_CF_INDEXED_1BIT:
case LV_IMG_CF_ALPHA_1BIT:
return 1;
case LV_IMG_CF_INDEXED_2BIT:
case LV_IMG_CF_ALPHA_2BIT:
return 2;
case LV_IMG_CF_INDEXED_2BIT:
case LV_IMG_CF_ALPHA_2BIT:
return 2;
case LV_IMG_CF_INDEXED_4BIT:
case LV_IMG_CF_ALPHA_4BIT:
return 4;
case LV_IMG_CF_INDEXED_4BIT:
case LV_IMG_CF_ALPHA_4BIT:
return 4;
case LV_IMG_CF_INDEXED_8BIT:
case LV_IMG_CF_ALPHA_8BIT:
return 8;
case LV_IMG_CF_INDEXED_8BIT:
case LV_IMG_CF_ALPHA_8BIT:
return 8;
default:
return 0;
}
default:
return 0;
}
return 0;
return 0;
}
bool lv_img_color_format_is_chroma_keyed(lv_img_cf_t cf)
{
switch(cf) {
case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED:
switch(cf) {
case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED:
case LV_IMG_CF_RAW_CHROMA_KEYED:
case LV_IMG_CF_INDEXED_1BIT:
case LV_IMG_CF_INDEXED_2BIT:
case LV_IMG_CF_INDEXED_4BIT:
case LV_IMG_CF_INDEXED_8BIT:
return true;
default:
return false;
}
case LV_IMG_CF_INDEXED_1BIT:
case LV_IMG_CF_INDEXED_2BIT:
case LV_IMG_CF_INDEXED_4BIT:
case LV_IMG_CF_INDEXED_8BIT:
return true;
default:
return false;
}
return false;
return false;
}
bool lv_img_color_format_has_alpha(lv_img_cf_t cf)
{
switch(cf) {
case LV_IMG_CF_TRUE_COLOR_ALPHA:
switch(cf) {
case LV_IMG_CF_TRUE_COLOR_ALPHA:
case LV_IMG_CF_RAW_ALPHA:
case LV_IMG_CF_ALPHA_1BIT:
case LV_IMG_CF_ALPHA_2BIT:
case LV_IMG_CF_ALPHA_4BIT:
case LV_IMG_CF_ALPHA_8BIT:
return true;
default:
return false;
}
case LV_IMG_CF_ALPHA_1BIT:
case LV_IMG_CF_ALPHA_2BIT:
case LV_IMG_CF_ALPHA_4BIT:
case LV_IMG_CF_ALPHA_8BIT:
return true;
default:
return false;
}
return false;
return false;
}
/**
@ -231,11 +230,9 @@ lv_img_src_t lv_img_src_get_type(const void * src)
/*The first byte shows the type of the image source*/
if(u8_p[0] >= 0x20 && u8_p[0] <= 0x7F) {
return LV_IMG_SRC_FILE; /*If it's an ASCII character then it's file name*/
}
else if(u8_p[0] >= 0x80) {
} else if(u8_p[0] >= 0x80) {
return LV_IMG_SRC_SYMBOL; /*Symbols begins after 0x7F*/
}
else {
} else {
return LV_IMG_SRC_VARIABLE; /*`lv_img_dsc_t` is design to the first byte < 0x20*/
}
@ -250,11 +247,11 @@ lv_img_src_t lv_img_src_get_type(const void * src)
* @param close_fp clode function
*/
void lv_img_decoder_set_custom(lv_img_decoder_info_f_t info_fp, lv_img_decoder_open_f_t open_fp,
lv_img_decoder_read_line_f_t read_fp, lv_img_decoder_close_f_t close_fp)
lv_img_decoder_read_line_f_t read_fp, lv_img_decoder_close_f_t close_fp)
{
lv_img_decoder_info_custom = info_fp;
lv_img_decoder_open_custom = open_fp;
lv_img_decoder_read_line_custom= read_fp;
lv_img_decoder_read_line_custom = read_fp;
lv_img_decoder_close_custom = close_fp;
}
@ -265,7 +262,7 @@ void lv_img_decoder_set_custom(lv_img_decoder_info_f_t info_fp, lv_img_decoder_
static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mask,
const void * src, const lv_style_t * style, lv_opa_t opa_scale)
const void * src, const lv_style_t * style, lv_opa_t opa_scale)
{
lv_area_t mask_com; /*Common area of mask and coords*/
@ -387,8 +384,7 @@ static const uint8_t * lv_img_decoder_open(const void * src, const lv_style_t *
lv_img_cf_t cf = decoder_header.cf;
if(cf == LV_IMG_CF_TRUE_COLOR ||
cf == LV_IMG_CF_TRUE_COLOR_ALPHA ||
cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED)
{
cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) {
if(decoder_src_type == LV_IMG_SRC_VARIABLE) {
/*In case of uncompressed formats if the image stored in the ROM/RAM simply give it's pointer*/
return ((lv_img_dsc_t *)decoder_src)->data;
@ -396,12 +392,10 @@ static const uint8_t * lv_img_decoder_open(const void * src, const lv_style_t *
/*If it's file it need to be read line by line later*/
return NULL;
}
}
else if (cf == LV_IMG_CF_INDEXED_1BIT ||
cf == LV_IMG_CF_INDEXED_2BIT ||
cf == LV_IMG_CF_INDEXED_4BIT ||
cf == LV_IMG_CF_INDEXED_8BIT)
{
} else if(cf == LV_IMG_CF_INDEXED_1BIT ||
cf == LV_IMG_CF_INDEXED_2BIT ||
cf == LV_IMG_CF_INDEXED_4BIT ||
cf == LV_IMG_CF_INDEXED_8BIT) {
lv_color24_t palette_file[256];
lv_color24_t * palette_p = NULL;
uint8_t px_size = lv_img_color_format_get_px_size(cf);
@ -416,7 +410,7 @@ static const uint8_t * lv_img_decoder_open(const void * src, const lv_style_t *
palette_file[0] = 0; /*Just to solve warnings*/
#endif
} else {
palette_p = (lv_color_t*)((lv_img_dsc_t *)decoder_src)->data;
palette_p = (lv_color_t *)((lv_img_dsc_t *)decoder_src)->data;
}
uint32_t i;
@ -424,16 +418,12 @@ static const uint8_t * lv_img_decoder_open(const void * src, const lv_style_t *
decoder_index_map[i] = LV_COLOR_MAKE(palette_p[i].red, palette_p[i].green, palette_p[i].blue);
}
return NULL;
}
else if (cf == LV_IMG_CF_ALPHA_1BIT ||
cf == LV_IMG_CF_ALPHA_2BIT ||
cf == LV_IMG_CF_ALPHA_4BIT ||
cf == LV_IMG_CF_ALPHA_8BIT)
{
} else if(cf == LV_IMG_CF_ALPHA_1BIT ||
cf == LV_IMG_CF_ALPHA_2BIT ||
cf == LV_IMG_CF_ALPHA_4BIT ||
cf == LV_IMG_CF_ALPHA_8BIT) {
return NULL; /*Nothing to process*/
}
else
{
} else {
LV_LOG_WARN("Image decoder open: unknown color format")
return LV_IMG_DECODER_OPEN_FAIL;
}
@ -461,9 +451,8 @@ static lv_res_t lv_img_decoder_read_line(lv_coord_t x, lv_coord_t y, lv_coord_t
lv_fs_res_t res;
if(decoder_header.cf == LV_IMG_CF_TRUE_COLOR ||
decoder_header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA ||
decoder_header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED)
{
decoder_header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA ||
decoder_header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) {
uint32_t pos = ((y * decoder_header.w + x) * px_size) >> 3;
res = lv_fs_seek(&decoder_file, pos);
if(res != LV_FS_RES_OK) {
@ -477,18 +466,15 @@ static lv_res_t lv_img_decoder_read_line(lv_coord_t x, lv_coord_t y, lv_coord_t
LV_LOG_WARN("Built-in image decoder read failed");
return false;
}
}
else if(decoder_header.cf == LV_IMG_CF_ALPHA_1BIT ||
decoder_header.cf == LV_IMG_CF_ALPHA_2BIT ||
decoder_header.cf == LV_IMG_CF_ALPHA_4BIT ||
decoder_header.cf == LV_IMG_CF_ALPHA_8BIT)
{
} else if(decoder_header.cf == LV_IMG_CF_ALPHA_1BIT ||
decoder_header.cf == LV_IMG_CF_ALPHA_2BIT ||
decoder_header.cf == LV_IMG_CF_ALPHA_4BIT ||
decoder_header.cf == LV_IMG_CF_ALPHA_8BIT) {
lv_img_built_in_decoder_line_alpha(x, y, len, buf);
} else if(decoder_header.cf == LV_IMG_CF_INDEXED_1BIT ||
decoder_header.cf == LV_IMG_CF_INDEXED_2BIT ||
decoder_header.cf == LV_IMG_CF_INDEXED_4BIT ||
decoder_header.cf == LV_IMG_CF_INDEXED_8BIT)
{
decoder_header.cf == LV_IMG_CF_INDEXED_8BIT) {
lv_img_built_in_decoder_line_indexed(x, y, len, buf);
} else {
LV_LOG_WARN("Built-in image decoder read not supports the color format");
@ -498,20 +484,18 @@ static lv_res_t lv_img_decoder_read_line(lv_coord_t x, lv_coord_t y, lv_coord_t
LV_LOG_WARN("Image built-in decoder can't read file because USE_LV_FILESYSTEM = 0");
return false;
#endif
} else if (decoder_src_type == LV_IMG_SRC_VARIABLE) {
} else if(decoder_src_type == LV_IMG_SRC_VARIABLE) {
const lv_img_dsc_t * img_dsc = decoder_src;
if(img_dsc->header.cf == LV_IMG_CF_ALPHA_1BIT ||
img_dsc->header.cf == LV_IMG_CF_ALPHA_2BIT ||
img_dsc->header.cf == LV_IMG_CF_ALPHA_4BIT ||
img_dsc->header.cf == LV_IMG_CF_ALPHA_8BIT)
{
img_dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) {
lv_img_built_in_decoder_line_alpha(x, y, len, buf);
} else if(img_dsc->header.cf == LV_IMG_CF_INDEXED_1BIT ||
img_dsc->header.cf == LV_IMG_CF_INDEXED_2BIT ||
img_dsc->header.cf == LV_IMG_CF_INDEXED_4BIT ||
img_dsc->header.cf == LV_IMG_CF_INDEXED_8BIT)
{
img_dsc->header.cf == LV_IMG_CF_INDEXED_2BIT ||
img_dsc->header.cf == LV_IMG_CF_INDEXED_4BIT ||
img_dsc->header.cf == LV_IMG_CF_INDEXED_8BIT) {
lv_img_built_in_decoder_line_indexed(x, y, len, buf);
} else {
LV_LOG_WARN("Built-in image decoder not supports the color format");
@ -546,9 +530,9 @@ static lv_res_t lv_img_built_in_decoder_line_alpha(lv_coord_t x, lv_coord_t y, l
const lv_opa_t alpha1_opa_table[2] = {0, 255}; /*Opacity mapping with bpp = 1 (Just for compatibility)*/
const lv_opa_t alpha2_opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping with bpp = 2*/
const lv_opa_t alpha4_opa_table[16] = {0, 17, 34, 51, /*Opacity mapping with bpp = 4*/
68, 85, 102, 119,
136, 153, 170, 187,
204, 221, 238, 255
68, 85, 102, 119,
136, 153, 170, 187,
204, 221, 238, 255
};
/*Simply fill the buffer with the color. Later only the alpha value will be modified.*/
@ -562,54 +546,54 @@ static lv_res_t lv_img_built_in_decoder_line_alpha(lv_coord_t x, lv_coord_t y, l
buf[i * LV_IMG_PX_SIZE_ALPHA_BYTE] = bg_color.full & 0xFF;
buf[i * LV_IMG_PX_SIZE_ALPHA_BYTE + 1] = (bg_color.full >> 8) & 0xFF;
#elif LV_COLOR_DEPTH == 24
*((uint32_t*)&buf[i * LV_IMG_PX_SIZE_ALPHA_BYTE]) = bg_color.full;
*((uint32_t *)&buf[i * LV_IMG_PX_SIZE_ALPHA_BYTE]) = bg_color.full;
#endif
}
const lv_opa_t * opa_table = NULL;
uint8_t px_size = lv_img_color_format_get_px_size(decoder_header.cf);
uint16_t mask = (1 << px_size) - 1; /*E.g. px_size = 2; mask = 0x03*/
const lv_opa_t * opa_table = NULL;
uint8_t px_size = lv_img_color_format_get_px_size(decoder_header.cf);
uint16_t mask = (1 << px_size) - 1; /*E.g. px_size = 2; mask = 0x03*/
lv_coord_t w = 0;
uint32_t ofs = 0;
int8_t pos = 0;
switch(decoder_header.cf) {
case LV_IMG_CF_ALPHA_1BIT:
w = (decoder_header.w >> 3); /*E.g. w = 20 -> w = 2 + 1*/
if(decoder_header.w & 0x7) w++;
ofs += w * y + (x >> 3); /*First pixel*/
pos = 7 - (x & 0x7);
opa_table = alpha1_opa_table;
break;
lv_coord_t w = 0;
uint32_t ofs = 0;
int8_t pos = 0;
switch(decoder_header.cf) {
case LV_IMG_CF_ALPHA_1BIT:
w = (decoder_header.w >> 3); /*E.g. w = 20 -> w = 2 + 1*/
if(decoder_header.w & 0x7) w++;
ofs += w * y + (x >> 3); /*First pixel*/
pos = 7 - (x & 0x7);
opa_table = alpha1_opa_table;
break;
case LV_IMG_CF_ALPHA_2BIT:
w = (decoder_header.w >> 2); /*E.g. w = 13 -> w = 3 + 1 (bytes)*/
if(decoder_header.w & 0x3) w++;
ofs += w * y + (x >> 2); /*First pixel*/
pos = 6 - ((x & 0x3) * 2);
opa_table = alpha2_opa_table;
break;
break;
case LV_IMG_CF_ALPHA_4BIT:
w = (decoder_header.w >> 1); /*E.g. w = 13 -> w = 6 + 1 (bytes)*/
if(decoder_header.w & 0x1) w++;
ofs += w * y + (x >> 1); /*First pixel*/
pos = 4 - ((x & 0x1) * 4);
opa_table = alpha4_opa_table;
break;
break;
case LV_IMG_CF_ALPHA_8BIT:
w = decoder_header.w; /*E.g. x = 7 -> w = 7 (bytes)*/
ofs += w * y + x; /*First pixel*/
pos = 0;
break;
}
break;
}
#if USE_LV_FILESYSTEM
# if LV_COMPILER_VLA_SUPPORTED
uint8_t fs_buf[w];
uint8_t fs_buf[w];
# else
# if LV_HOR_RES > LV_VER_RES
uint8_t fs_buf[LV_HOR_RES];
uint8_t fs_buf[LV_HOR_RES];
# else
uint8_t fs_buf[LV_VER_RES];
uint8_t fs_buf[LV_VER_RES];
# endif
# endif
#endif
@ -630,22 +614,22 @@ static lv_res_t lv_img_built_in_decoder_line_alpha(lv_coord_t x, lv_coord_t y, l
}
uint8_t byte_act = 0;
uint8_t val_act;
for(i = 0; i < len; i ++) {
val_act = (data_tmp[byte_act] & (mask << pos)) >> pos;
uint8_t byte_act = 0;
uint8_t val_act;
for(i = 0; i < len; i ++) {
val_act = (data_tmp[byte_act] & (mask << pos)) >> pos;
buf[i * LV_IMG_PX_SIZE_ALPHA_BYTE + LV_IMG_PX_SIZE_ALPHA_BYTE - 1] =
decoder_header.cf == LV_IMG_CF_ALPHA_8BIT ? val_act : opa_table[val_act];
buf[i * LV_IMG_PX_SIZE_ALPHA_BYTE + LV_IMG_PX_SIZE_ALPHA_BYTE - 1] =
decoder_header.cf == LV_IMG_CF_ALPHA_8BIT ? val_act : opa_table[val_act];
pos -= px_size;
if(pos < 0) {
pos = 8 - px_size;
data_tmp++;
}
}
pos -= px_size;
if(pos < 0) {
pos = 8 - px_size;
data_tmp++;
}
}
return LV_RES_OK;
return LV_RES_OK;
}
static lv_res_t lv_img_built_in_decoder_line_indexed(lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t * buf)
@ -664,37 +648,37 @@ static lv_res_t lv_img_built_in_decoder_line_indexed(lv_coord_t x, lv_coord_t y,
ofs += w * y + (x >> 3); /*First pixel*/
ofs += 8; /*Skip the palette*/
pos = 7 - (x & 0x7);
break;
break;
case LV_IMG_CF_INDEXED_2BIT:
w = (decoder_header.w >> 2); /*E.g. w = 13 -> w = 3 + 1 (bytes)*/
if(decoder_header.w & 0x3) w++;
ofs += w * y + (x >> 2); /*First pixel*/
ofs += 16; /*Skip the palette*/
pos = 6 - ((x & 0x3) * 2);
break;
break;
case LV_IMG_CF_INDEXED_4BIT:
w = (decoder_header.w >> 1); /*E.g. w = 13 -> w = 6 + 1 (bytes)*/
if(decoder_header.w & 0x1) w++;
ofs += w * y + (x >> 1); /*First pixel*/
ofs += 64; /*Skip the palette*/
pos = 4 - ((x & 0x1) * 4);
break;
break;
case LV_IMG_CF_INDEXED_8BIT:
w = decoder_header.w; /*E.g. x = 7 -> w = 7 (bytes)*/
ofs += w * y + x; /*First pixel*/
ofs += 1024; /*Skip the palette*/
pos = 0;
break;
break;
}
#if USE_LV_FILESYSTEM
# if LV_COMPILER_VLA_SUPPORTED
uint8_t fs_buf[w];
uint8_t fs_buf[w];
# else
# if LV_HOR_RES > LV_VER_RES
uint8_t fs_buf[LV_HOR_RES];
uint8_t fs_buf[LV_HOR_RES];
# else
uint8_t fs_buf[LV_VER_RES];
uint8_t fs_buf[LV_VER_RES];
# endif
# endif
#endif

View File

@ -62,8 +62,8 @@ static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_
*/
void lv_vpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa)
{
if(opa < LV_OPA_MIN) return;
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
if(opa < LV_OPA_MIN) return;
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
lv_vdb_t * vdb_p = lv_vdb_get();
if(!vdb_p) {
@ -85,14 +85,14 @@ void lv_vpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t col
lv_disp_t * disp = lv_disp_get_active();
if(disp->driver.vdb_wr) {
disp->driver.vdb_wr((uint8_t*)vdb_p->buf, vdb_width, x, y, color, opa);
disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width, x, y, color, opa);
} else {
lv_color_t * vdb_px_p = vdb_p->buf + y * vdb_width + x;
if(opa == LV_OPA_COVER) {
*vdb_px_p = color;
} else {
*vdb_px_p = lv_color_mix(color, *vdb_px_p, opa);
}
lv_color_t * vdb_px_p = vdb_p->buf + y * vdb_width + x;
if(opa == LV_OPA_COVER) {
*vdb_px_p = color;
} else {
*vdb_px_p = lv_color_mix(color, *vdb_px_p, opa);
}
}
}
@ -107,8 +107,8 @@ void lv_vpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t col
void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
lv_color_t color, lv_opa_t opa)
{
if(opa < LV_OPA_MIN) return;
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
if(opa < LV_OPA_MIN) return;
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
lv_area_t res_a;
bool union_ok;
@ -229,16 +229,16 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
const uint8_t bpp1_opa_table[2] = {0, 255}; /*Opacity mapping with bpp = 1 (Just for compatibility)*/
const uint8_t bpp2_opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping with bpp = 2*/
const uint8_t bpp4_opa_table[16] = {0, 17, 34, 51, /*Opacity mapping with bpp = 4*/
68, 85, 102, 119,
136, 153, 170, 187,
204, 221, 238, 255
};
if(opa < LV_OPA_MIN) return;
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
68, 85, 102, 119,
136, 153, 170, 187,
204, 221, 238, 255
};
if(opa < LV_OPA_MIN) return;
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
if(font_p == NULL) {
LV_LOG_WARN("Font: character's bitmap not found");
return;
LV_LOG_WARN("Font: character's bitmap not found");
return;
}
lv_coord_t pos_x = pos_p->x;
@ -246,12 +246,12 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
uint8_t letter_w = lv_font_get_real_width(font_p, letter);
uint8_t letter_h = lv_font_get_height(font_p);
uint8_t bpp = lv_font_get_bpp(font_p, letter); /*Bit per pixel (1,2, 4 or 8)*/
uint8_t * bpp_opa_table;
const uint8_t * bpp_opa_table;
uint8_t mask_init;
uint8_t mask;
if(lv_font_is_monospace(font_p, letter)) {
pos_x += (lv_font_get_width(font_p, letter) - letter_w) / 2;
pos_x += (lv_font_get_width(font_p, letter) - letter_w) / 2;
}
@ -327,21 +327,21 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
for(col = col_start; col < col_end; col ++) {
letter_px = (*map_p & mask) >> (8 - col_bit - bpp);
if(letter_px != 0) {
if(opa == LV_OPA_COVER) {
px_opa = bpp == 8 ? letter_px : bpp_opa_table[letter_px];
} else {
px_opa = bpp == 8 ?
(uint16_t)((uint16_t)letter_px * opa) >> 8 :
(uint16_t)((uint16_t)bpp_opa_table[letter_px] * opa) >> 8;
}
if(opa == LV_OPA_COVER) {
px_opa = bpp == 8 ? letter_px : bpp_opa_table[letter_px];
} else {
px_opa = bpp == 8 ?
(uint16_t)((uint16_t)letter_px * opa) >> 8 :
(uint16_t)((uint16_t)bpp_opa_table[letter_px] * opa) >> 8;
}
if(disp->driver.vdb_wr) {
disp->driver.vdb_wr((uint8_t*)vdb_p->buf, vdb_width,
(col + pos_x) - vdb_p->area.x1, (row + pos_y) - vdb_p->area.y1,
color, px_opa);
} else {
*vdb_buf_tmp = lv_color_mix(color, *vdb_buf_tmp, px_opa);
}
if(disp->driver.vdb_wr) {
disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width,
(col + pos_x) - vdb_p->area.x1, (row + pos_y) - vdb_p->area.y1,
color, px_opa);
} else {
*vdb_buf_tmp = lv_color_mix(color, *vdb_buf_tmp, px_opa);
}
}
vdb_buf_tmp++;
@ -378,8 +378,8 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
lv_color_t recolor, lv_opa_t recolor_opa)
{
if(opa < LV_OPA_MIN) return;
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
if(opa < LV_OPA_MIN) return;
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
lv_area_t masked_a;
bool union_ok;
@ -428,33 +428,33 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
/*The simplest case just copy the pixels into the VDB*/
if(chroma_key == false && alpha_byte == false && opa == LV_OPA_COVER && recolor_opa == LV_OPA_TRANSP) {
/*Use the custom VDB write function is exists*/
if(disp->driver.vdb_wr) {
lv_coord_t col;
for(row = masked_a.y1; row <= masked_a.y2; row++) {
for(col = 0; col < map_useful_w; col++) {
lv_color_t px_color = (lv_color_t) *((lv_color_t *)&map_p[(uint32_t)col * px_size_byte]);
disp->driver.vdb_wr((uint8_t*)vdb_p->buf, vdb_width, col + masked_a.x1, row, px_color, opa);
}
map_p += map_width * px_size_byte; /*Next row on the map*/
}
}
/*Normal native VDB*/
else {
for(row = masked_a.y1; row <= masked_a.y2; row++) {
/*Use the custom VDB write function is exists*/
if(disp->driver.vdb_wr) {
lv_coord_t col;
for(row = masked_a.y1; row <= masked_a.y2; row++) {
for(col = 0; col < map_useful_w; col++) {
lv_color_t px_color = (lv_color_t) * ((lv_color_t *)&map_p[(uint32_t)col * px_size_byte]);
disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width, col + masked_a.x1, row, px_color, opa);
}
map_p += map_width * px_size_byte; /*Next row on the map*/
}
}
/*Normal native VDB*/
else {
for(row = masked_a.y1; row <= masked_a.y2; row++) {
#if USE_LV_GPU
if(lv_disp_is_mem_blend_supported() == false) {
sw_mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa);
} else {
lv_disp_mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa);
}
if(lv_disp_is_mem_blend_supported() == false) {
sw_mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa);
} else {
lv_disp_mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa);
}
#else
sw_mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa);
sw_mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa);
#endif
map_p += map_width * px_size_byte; /*Next row on the map*/
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
}
}
map_p += map_width * px_size_byte; /*Next row on the map*/
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
}
}
}
/*In the other cases every pixel need to be checked one-by-one*/
@ -497,28 +497,28 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
}
/*Handle custom VDB write is present*/
if(disp->driver.vdb_wr) {
disp->driver.vdb_wr((uint8_t*)vdb_p->buf, vdb_width, col + masked_a.x1, row, recolored_px, opa_result);
disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width, col + masked_a.x1, row, recolored_px, opa_result);
}
/*Normal native VDB write*/
else {
if(opa_result == LV_OPA_COVER) vdb_buf_tmp[col].full = recolored_px.full;
else vdb_buf_tmp[col] = lv_color_mix(recolored_px, vdb_buf_tmp[col], opa_result);
if(opa_result == LV_OPA_COVER) vdb_buf_tmp[col].full = recolored_px.full;
else vdb_buf_tmp[col] = lv_color_mix(recolored_px, vdb_buf_tmp[col], opa_result);
}
} else {
/*Handle custom VDB write is present*/
if(disp->driver.vdb_wr) {
disp->driver.vdb_wr((uint8_t*)vdb_p->buf, vdb_width, col + masked_a.x1, row, px_color, opa_result);
}
/*Normal native VDB write*/
else {
if(opa_result == LV_OPA_COVER) vdb_buf_tmp[col] = px_color;
else vdb_buf_tmp[col] = lv_color_mix(px_color, vdb_buf_tmp[col], opa_result);
}
disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width, col + masked_a.x1, row, px_color, opa_result);
}
/*Normal native VDB write*/
else {
if(opa_result == LV_OPA_COVER) vdb_buf_tmp[col] = px_color;
else vdb_buf_tmp[col] = lv_color_mix(px_color, vdb_buf_tmp[col], opa_result);
}
}
}
map_p += map_width * px_size_byte; /*Next row on the map*/
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
map_p += map_width * px_size_byte; /*Next row on the map*/
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
}
}
}
@ -563,48 +563,48 @@ static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_
lv_disp_t * disp = lv_disp_get_active();
if(disp->driver.vdb_wr) {
for(col = fill_area->x1; col <= fill_area->x2; col++) {
for(row = fill_area->y1; row <= fill_area->y2; row++) {
disp->driver.vdb_wr((uint8_t*)mem, mem_width, col, row, color, opa);
}
}
for(col = fill_area->x1; col <= fill_area->x2; col++) {
for(row = fill_area->y1; row <= fill_area->y2; row++) {
disp->driver.vdb_wr((uint8_t *)mem, mem_width, col, row, color, opa);
}
}
} else {
mem += fill_area->y1 * mem_width; /*Go to the first row*/
mem += fill_area->y1 * mem_width; /*Go to the first row*/
/*Run simpler function without opacity*/
if(opa == LV_OPA_COVER) {
/*Run simpler function without opacity*/
if(opa == LV_OPA_COVER) {
/*Fill the first row with 'color'*/
for(col = fill_area->x1; col <= fill_area->x2; col++) {
mem[col] = color;
}
/*Fill the first row with 'color'*/
for(col = fill_area->x1; col <= fill_area->x2; col++) {
mem[col] = color;
}
/*Copy the first row to all other rows*/
lv_color_t * mem_first = &mem[fill_area->x1];
lv_coord_t copy_size = (fill_area->x2 - fill_area->x1 + 1) * sizeof(lv_color_t);
mem += mem_width;
/*Copy the first row to all other rows*/
lv_color_t * mem_first = &mem[fill_area->x1];
lv_coord_t copy_size = (fill_area->x2 - fill_area->x1 + 1) * sizeof(lv_color_t);
mem += mem_width;
for(row = fill_area->y1 + 1; row <= fill_area->y2; row++) {
memcpy(&mem[fill_area->x1], mem_first, copy_size);
mem += mem_width;
}
}
/*Calculate with alpha too*/
else {
lv_color_t bg_tmp = LV_COLOR_BLACK;
lv_color_t opa_tmp = lv_color_mix(color, bg_tmp, opa);
for(row = fill_area->y1; row <= fill_area->y2; row++) {
for(col = fill_area->x1; col <= fill_area->x2; col++) {
/*If the bg color changed recalculate the result color*/
if(mem[col].full != bg_tmp.full) {
bg_tmp = mem[col];
opa_tmp = lv_color_mix(color, bg_tmp, opa);
}
mem[col] = opa_tmp;
}
mem += mem_width;
}
}
for(row = fill_area->y1 + 1; row <= fill_area->y2; row++) {
memcpy(&mem[fill_area->x1], mem_first, copy_size);
mem += mem_width;
}
}
/*Calculate with alpha too*/
else {
lv_color_t bg_tmp = LV_COLOR_BLACK;
lv_color_t opa_tmp = lv_color_mix(color, bg_tmp, opa);
for(row = fill_area->y1; row <= fill_area->y2; row++) {
for(col = fill_area->x1; col <= fill_area->x2; col++) {
/*If the bg color changed recalculate the result color*/
if(mem[col].full != bg_tmp.full) {
bg_tmp = mem[col];
opa_tmp = lv_color_mix(color, bg_tmp, opa);
}
mem[col] = opa_tmp;
}
mem += mem_width;
}
}
}
}

View File

@ -10,11 +10,14 @@
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#ifdef LV_CONF_INCLUDE_SIMPLE
#include "lv_conf.h"
#else
#include "../../lv_conf.h"
#endif
#if USE_LV_FILESYSTEM

View File

@ -13,7 +13,11 @@ extern "C" {
/*********************
* INCLUDES
*********************/
#ifdef LV_CONF_INCLUDE_SIMPLE
#include "lv_conf.h"
#else
#include "../../lv_conf.h"
#endif
#include <stdint.h>
/*********************

View File

@ -64,7 +64,7 @@ static lv_signal_func_t ancestor_signal;
*/
lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
{
LV_LOG_TRACE("button matrix create started");
LV_LOG_TRACE("button matrix create started");
/*Create the ancestor object*/
lv_obj_t * new_btnm = lv_obj_create(par, copy);
@ -124,7 +124,7 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
lv_btnm_set_map(new_btnm, lv_btnm_get_map(copy));
}
LV_LOG_INFO("button matrix created");
LV_LOG_INFO("button matrix created");
return new_btnm;
}
@ -505,11 +505,9 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
lv_point_t p;
if(sign == LV_SIGNAL_CLEANUP) {
lv_mem_free(ext->button_areas);
}
else if(sign == LV_SIGNAL_STYLE_CHG || sign == LV_SIGNAL_CORD_CHG) {
} else if(sign == LV_SIGNAL_STYLE_CHG || sign == LV_SIGNAL_CORD_CHG) {
lv_btnm_set_map(btnm, ext->map_p);
}
else if(sign == LV_SIGNAL_PRESSING) {
} else if(sign == LV_SIGNAL_PRESSING) {
uint16_t btn_pr;
/*Search the pressed area*/
lv_indev_get_point(param, &p);
@ -549,8 +547,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
}
}
}
}
else if(sign == LV_SIGNAL_RELEASED) {
} else if(sign == LV_SIGNAL_RELEASED) {
if(ext->btn_id_pr != LV_BTNM_PR_NONE) {
if(ext->action) {
uint16_t txt_i = get_button_text(btnm, ext->btn_id_pr);
@ -586,34 +583,31 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
/*Leave the clicked button as pressed if this the focused object in a group*/
lv_group_t * g = lv_obj_get_group(btnm);
if(lv_group_get_focused(g) != btnm) {
ext->btn_id_pr = LV_BTNM_PR_NONE;
ext->btn_id_pr = LV_BTNM_PR_NONE;
}
#else
ext->btn_id_pr = LV_BTNM_PR_NONE;
#endif
}
}
else if(sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_DEFOCUS) {
} else if(sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_DEFOCUS) {
ext->btn_id_pr = LV_BTNM_PR_NONE;
lv_obj_invalidate(btnm);
}
else if(sign == LV_SIGNAL_FOCUS) {
} else if(sign == LV_SIGNAL_FOCUS) {
#if USE_LV_GROUP
lv_indev_t * indev = lv_indev_get_act();
if(lv_obj_is_focused(btnm) && lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER) {
lv_point_t p;
lv_indev_get_point(indev, &p);
uint16_t btn_i = get_button_from_point(btnm, &p);
ext->btn_id_pr = btn_i;
} else {
lv_indev_t * indev = lv_indev_get_act();
if(lv_obj_is_focused(btnm) && lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER) {
lv_point_t p1;
lv_indev_get_point(indev, &p1);
uint16_t btn_i = get_button_from_point(btnm, &p1);
ext->btn_id_pr = btn_i;
} else {
ext->btn_id_pr = 0;
}
}
#else
ext->btn_id_pr = 0;
#endif
lv_obj_invalidate(btnm);
}
else if(sign == LV_SIGNAL_CONTROLL) {
} else if(sign == LV_SIGNAL_CONTROLL) {
char c = *((char *)param);
if(c == LV_GROUP_KEY_RIGHT) {
if(ext->btn_id_pr == LV_BTNM_PR_NONE) ext->btn_id_pr = 0;
@ -624,8 +618,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
if(ext->btn_id_pr == LV_BTNM_PR_NONE) ext->btn_id_pr = 0;
if(ext->btn_id_pr > 0) ext->btn_id_pr--;
lv_obj_invalidate(btnm);
}
else if(c == LV_GROUP_KEY_DOWN) {
} else if(c == LV_GROUP_KEY_DOWN) {
lv_style_t * style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BG);
/*Find the area below the the current*/
if(ext->btn_id_pr == LV_BTNM_PR_NONE) {
@ -645,8 +638,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
if(area_below < ext->btn_cnt) ext->btn_id_pr = area_below;
}
lv_obj_invalidate(btnm);
}
else if(c == LV_GROUP_KEY_UP) {
} else if(c == LV_GROUP_KEY_UP) {
lv_style_t * style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BG);
/*Find the area below the the current*/
if(ext->btn_id_pr == LV_BTNM_PR_NONE) {
@ -666,8 +658,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
}
lv_obj_invalidate(btnm);
}
else if(c == LV_GROUP_KEY_ENTER) {
} else if(c == LV_GROUP_KEY_ENTER) {
if(ext->action != NULL) {
uint16_t txt_i = get_button_text(btnm, ext->btn_id_pr);
if(txt_i != LV_BTNM_PR_NONE) {
@ -675,19 +666,17 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
}
}
}
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
bool * editable = (bool *)param;
*editable = true;
} else if(sign == LV_SIGNAL_GET_TYPE) {
lv_obj_type_t * buf = param;
uint8_t i;
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
if(buf->type[i] == NULL) break;
}
buf->type[i] = "lv_btnm";
}
else if(sign == LV_SIGNAL_GET_EDITABLE) {
bool * editable = (bool *)param;
*editable = true;
}
else if(sign == LV_SIGNAL_GET_TYPE) {
lv_obj_type_t * buf = param;
uint8_t i;
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
if(buf->type[i] == NULL) break;
}
buf->type[i] = "lv_btnm";
}
return res;

View File

@ -54,7 +54,7 @@ static lv_signal_func_t ancestor_signal;
*/
lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy)
{
LV_LOG_TRACE("image create started");
LV_LOG_TRACE("image create started");
lv_obj_t * new_img = NULL;
@ -83,15 +83,15 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy)
if(copy == NULL) {
lv_obj_set_click(new_img, false);
/* Enable auto size for non screens
/* Enable auto size for non screens
* because image screens are wallpapers
* and must be screen sized*/
if(par != NULL) {
ext->auto_size = 1;
lv_obj_set_style(new_img, NULL); /*Inherit the style by default*/
ext->auto_size = 1;
lv_obj_set_style(new_img, NULL); /*Inherit the style by default*/
} else {
ext->auto_size = 0;
lv_obj_set_style(new_img, &lv_style_plain); /*Set a style for screens*/
ext->auto_size = 0;
lv_obj_set_style(new_img, &lv_style_plain); /*Set a style for screens*/
}
} else {
lv_img_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
@ -103,7 +103,7 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy)
}
LV_LOG_INFO("image created");
LV_LOG_INFO("image created");
return new_img;
}
@ -135,13 +135,12 @@ void lv_img_set_src(lv_obj_t * img, const void * src_img)
}
lv_img_header_t header;
lv_img_dsc_get_info(src_img, &header);
lv_img_dsc_get_info(src_img, &header);
/*Save the source*/
if(src_type == LV_IMG_SRC_VARIABLE) {
ext->src = src_img;
}
else if(src_type == LV_IMG_SRC_FILE || src_type == LV_IMG_SRC_SYMBOL) {
/*Save the source*/
if(src_type == LV_IMG_SRC_VARIABLE) {
ext->src = src_img;
} else if(src_type == LV_IMG_SRC_FILE || src_type == LV_IMG_SRC_SYMBOL) {
/* If the new and the old src are the same then it was only a refresh.*/
if(ext->src != src_img) {
lv_mem_free(ext->src);
@ -151,21 +150,19 @@ void lv_img_set_src(lv_obj_t * img, const void * src_img)
strcpy(new_str, src_img);
ext->src = new_str;
}
}
if(src_type == LV_IMG_SRC_SYMBOL) {
/*`lv_img_dsc_get_info` couldn't set the with and height of a font so set it here*/
lv_style_t * style = lv_img_get_style(img);
lv_point_t size;
lv_txt_get_size(&size, src_img, style->text.font, style->text.letter_space, style->text.line_space, LV_COORD_MAX, LV_TXT_FLAG_NONE);
header.w = size.x;
header.h = size.y;
}
} else if(src_type == LV_IMG_SRC_SYMBOL) {
/*`lv_img_dsc_get_info` couldn't set the with and height of a font so set it here*/
lv_style_t * style = lv_img_get_style(img);
lv_point_t size;
lv_txt_get_size(&size, src_img, style->text.font, style->text.letter_space, style->text.line_space, LV_COORD_MAX, LV_TXT_FLAG_NONE);
header.w = size.x;
header.h = size.y;
}
ext->src_type = src_type;
ext->w = header.w;
ext->h = header.h;
ext->cf = header.cf;
ext->w = header.w;
ext->h = header.h;
ext->cf = header.cf;
if(lv_img_get_auto_size(img) != false) {
lv_obj_set_size(img, ext->w, ext->h);
@ -278,12 +275,9 @@ static bool lv_img_design(lv_obj_t * img, const lv_area_t * mask, lv_design_mode
}
} else if(ext->src_type == LV_IMG_SRC_SYMBOL) {
lv_draw_label(&coords, mask, style, opa_scale, ext->src, LV_TXT_FLAG_NONE, NULL);
} else {
/*Trigger the error handler of image drawer*/
lv_draw_img(&img->coords, mask, NULL, style, opa_scale);
}
}