relace lv_coord_t with int32_t in some performance ciritcal functions
This commit is contained in:
@@ -269,6 +269,11 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in the i
|
||||
/*Checks is the memory is successfully allocated or no. (Quite fast)*/
|
||||
#define LV_USE_ASSERT_MEM 1
|
||||
|
||||
/*Check the integrity of `lv_mem` after critical operations. (Slow)*/
|
||||
#ifndef LV_USE_ASSERT_MEM_INTEGRITY
|
||||
#define LV_USE_ASSERT_MEM_INTEGRITY 0
|
||||
#endif
|
||||
|
||||
/* Check the strings.
|
||||
* Search for NULL, very long strings, invalid characters, and unnatural repetitions. (Slow)
|
||||
* If disabled `LV_USE_ASSERT_NULL` will be performed instead (if it's enabled) */
|
||||
|
||||
@@ -363,6 +363,11 @@
|
||||
#define LV_USE_ASSERT_MEM 1
|
||||
#endif
|
||||
|
||||
/*Check the integrity of `lv_mem` after critical operations. (Slow)*/
|
||||
#ifndef LV_USE_ASSERT_MEM_INTEGRITY
|
||||
#define LV_USE_ASSERT_MEM_INTEGRITY 0
|
||||
#endif
|
||||
|
||||
/* Check the strings.
|
||||
* Search for NULL, very long strings, invalid characters, and unnatural repetitions. (Slow)
|
||||
* If disabled `LV_USE_ASSERT_NULL` will be performed instead (if it's enabled) */
|
||||
|
||||
@@ -49,6 +49,11 @@ bool lv_debug_check_null(const void * p)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool lv_debug_check_mem_integrity(void)
|
||||
{
|
||||
return lv_mem_test() == LV_RES_OK ? true : false;
|
||||
}
|
||||
|
||||
bool lv_debug_check_obj_type(const lv_obj_t * obj, const char * obj_type)
|
||||
{
|
||||
if(obj_type[0] == '\0') return true;
|
||||
|
||||
@@ -30,6 +30,8 @@ extern "C" {
|
||||
**********************/
|
||||
bool lv_debug_check_null(const void * p);
|
||||
|
||||
bool lv_debug_check_mem_integrity(void);
|
||||
|
||||
bool lv_debug_check_obj_type(const lv_obj_t * obj, const char * obj_type);
|
||||
|
||||
bool lv_debug_check_obj_valid(const lv_obj_t * obj);
|
||||
@@ -63,6 +65,11 @@ do { \
|
||||
#define LV_DEBUG_IS_NULL(p) (lv_debug_check_null(p))
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef LV_DEBUG_CHECK_MEM_INTEGRITY
|
||||
#define LV_DEBUG_CHECK_MEM_INTEGRITY() (lv_debug_check_mem_integrity())
|
||||
#endif
|
||||
|
||||
#ifndef LV_DEBUG_IS_STR
|
||||
#define LV_DEBUG_IS_STR(str) (lv_debug_check_null(str) && \
|
||||
lv_debug_check_str(str))
|
||||
@@ -100,6 +107,14 @@ do { \
|
||||
# define LV_ASSERT_MEM(p) true
|
||||
#endif
|
||||
|
||||
#if LV_USE_ASSERT_MEM_INTEGRITY
|
||||
# ifndef LV_ASSERT_MEM_INTEGRITY
|
||||
# define LV_ASSERT_MEM_INTEGRITY() LV_DEBUG_ASSERT(LV_DEBUG_CHECK_MEM_INTEGRITY(), "Memory integrity error", 0);
|
||||
# endif
|
||||
#else
|
||||
# define LV_ASSERT_MEM_INTEGRITY() true
|
||||
#endif
|
||||
|
||||
#if LV_USE_ASSERT_STR
|
||||
# ifndef LV_ASSERT_STR
|
||||
# define LV_ASSERT_STR(str) LV_DEBUG_ASSERT(LV_DEBUG_IS_STR(str), "Strange or invalid string", str);
|
||||
@@ -112,7 +127,6 @@ do { \
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if LV_USE_ASSERT_OBJ
|
||||
# ifndef LV_ASSERT_OBJ
|
||||
# define LV_ASSERT_OBJ(obj_p, obj_type) LV_DEBUG_ASSERT(LV_DEBUG_IS_OBJ(obj_p, obj_type), "Invalid object", obj_p);
|
||||
|
||||
@@ -2502,12 +2502,7 @@ lv_obj_state_dsc_t * lv_obj_get_state_dsc(const lv_obj_t * obj, uint8_t part)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
if(part < _LV_OBJ_PART_REAL_LAST) return &obj->state_dsc;
|
||||
|
||||
|
||||
static uint32_t x = 0;
|
||||
x++;
|
||||
printf("%d\n", x);
|
||||
if(part < _LV_OBJ_PART_REAL_LAST) return &((lv_obj_t*)obj)->state_dsc;
|
||||
|
||||
/*If a real part is asked, then use the object's signal to get its state.
|
||||
* A real object can be in different state then the main part
|
||||
@@ -2802,10 +2797,10 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
|
||||
}
|
||||
|
||||
if(draw_dsc->border_opa != LV_OPA_TRANSP) {
|
||||
draw_dsc->border_opa = lv_obj_get_style_border_opa(obj, part);
|
||||
if(draw_dsc->border_opa > LV_OPA_MIN) {
|
||||
draw_dsc->border_width = lv_obj_get_style_border_width(obj, part);
|
||||
if(draw_dsc->border_width) {
|
||||
draw_dsc->border_width = lv_obj_get_style_border_width(obj, part);
|
||||
if(draw_dsc->border_width) {
|
||||
draw_dsc->border_opa = lv_obj_get_style_border_opa(obj, part);
|
||||
if(draw_dsc->border_opa > LV_OPA_MIN) {
|
||||
draw_dsc->border_side = lv_obj_get_style_border_side(obj, part);
|
||||
draw_dsc->border_color = lv_obj_get_style_border_color(obj, part);
|
||||
}
|
||||
@@ -2831,10 +2826,10 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
|
||||
}
|
||||
|
||||
if(draw_dsc->shadow_opa > LV_OPA_MIN) {
|
||||
draw_dsc->shadow_opa = lv_obj_get_style_shadow_opa(obj, part);
|
||||
if(draw_dsc->shadow_opa > LV_OPA_MIN) {
|
||||
draw_dsc->shadow_width = lv_obj_get_style_shadow_width(obj, part);
|
||||
if(draw_dsc->shadow_width) {
|
||||
draw_dsc->shadow_width = lv_obj_get_style_shadow_width(obj, part);
|
||||
if(draw_dsc->shadow_width) {
|
||||
draw_dsc->shadow_opa = lv_obj_get_style_shadow_opa(obj, part);
|
||||
if(draw_dsc->shadow_opa > LV_OPA_MIN) {
|
||||
draw_dsc->shadow_ofs_x = lv_obj_get_style_shadow_offset_x(obj, part);
|
||||
draw_dsc->shadow_ofs_y = lv_obj_get_style_shadow_offset_y(obj, part);
|
||||
draw_dsc->shadow_spread = lv_obj_get_style_shadow_spread(obj, part);
|
||||
@@ -2975,10 +2970,10 @@ static lv_design_res_t lv_obj_design(lv_obj_t * obj, const lv_area_t * clip_area
|
||||
lv_mem_buf_release(param);
|
||||
}
|
||||
|
||||
lv_draw_rect_dsc_t draw_dsc;
|
||||
lv_draw_rect_dsc_init(&draw_dsc);
|
||||
/*If the border is drawn later disable loading other properties*/
|
||||
if(lv_obj_get_style_border_post(obj, LV_OBJ_PART_MAIN)) {
|
||||
lv_draw_rect_dsc_t draw_dsc;
|
||||
lv_draw_rect_dsc_init(&draw_dsc);
|
||||
draw_dsc.bg_opa = LV_OPA_TRANSP;
|
||||
draw_dsc.pattern_opa = LV_OPA_TRANSP;
|
||||
draw_dsc.shadow_opa = LV_OPA_TRANSP;
|
||||
|
||||
@@ -908,6 +908,14 @@ static inline void lv_obj_set_style_##func_name (lv_obj_t * obj, uint8_t part, v
|
||||
{ \
|
||||
lv_obj_set_style##style_type (obj, part, LV_STYLE_##prop_name, value); \
|
||||
} \
|
||||
static inline int16_t lv_style_get_##func_name (lv_style_t * style, void * res) \
|
||||
{ \
|
||||
return lv_style_get##style_type (style, LV_STYLE_##prop_name, res); \
|
||||
} \
|
||||
static inline void lv_style_set_##func_name (lv_style_t * style, lv_style_state_t state, value_type value) \
|
||||
{ \
|
||||
lv_style_set##style_type (style, LV_STYLE_##prop_name | (state), value); \
|
||||
} \
|
||||
|
||||
|
||||
LV_OBJ_STYLE_SET_GET_DECLARE(RADIUS, radius, lv_style_int_t,_int);
|
||||
|
||||
@@ -75,7 +75,7 @@ void lv_style_copy(lv_style_t * style_dest, const lv_style_t * style_src)
|
||||
|
||||
if(style_src->map == NULL) return;
|
||||
|
||||
uint16_t size = lv_style_get_size(style_src);
|
||||
uint16_t size = lv_style_get_mem_size(style_src);
|
||||
|
||||
style_dest->map = lv_mem_alloc(size);
|
||||
memcpy(style_dest->map, style_src->map, size);
|
||||
@@ -200,7 +200,7 @@ void lv_style_reset(lv_style_t * style)
|
||||
style->map = NULL;
|
||||
}
|
||||
|
||||
uint16_t lv_style_get_size(lv_style_t * style)
|
||||
uint16_t lv_style_get_mem_size(lv_style_t * style)
|
||||
{
|
||||
if(style->map == NULL) return 0;
|
||||
|
||||
@@ -240,7 +240,7 @@ void lv_style_set_int(lv_style_t * style, lv_style_property_t prop, lv_style_int
|
||||
lv_style_property_t end_mark = _LV_STYLE_CLOSEING_PROP;
|
||||
uint8_t end_mark_size = sizeof(end_mark);
|
||||
|
||||
uint16_t size = lv_style_get_size(style);
|
||||
uint16_t size = lv_style_get_mem_size(style);
|
||||
if(size == 0) size += end_mark_size;
|
||||
size += sizeof(lv_style_property_t) + sizeof(lv_style_int_t);
|
||||
style->map = lv_mem_realloc(style->map, size);
|
||||
@@ -274,7 +274,7 @@ void lv_style_set_color(lv_style_t * style, lv_style_property_t prop, lv_color_t
|
||||
lv_style_property_t end_mark = _LV_STYLE_CLOSEING_PROP;
|
||||
uint8_t end_mark_size = sizeof(end_mark);
|
||||
|
||||
uint16_t size = lv_style_get_size(style);
|
||||
uint16_t size = lv_style_get_mem_size(style);
|
||||
if(size == 0) size += end_mark_size;
|
||||
|
||||
size += sizeof(lv_style_property_t) + sizeof(lv_color_t);
|
||||
@@ -309,7 +309,7 @@ void lv_style_set_opa(lv_style_t * style, lv_style_property_t prop, lv_opa_t opa
|
||||
lv_style_property_t end_mark = _LV_STYLE_CLOSEING_PROP;
|
||||
uint8_t end_mark_size = sizeof(end_mark);
|
||||
|
||||
uint16_t size = lv_style_get_size(style);
|
||||
uint16_t size = lv_style_get_mem_size(style);
|
||||
if(size == 0) size += end_mark_size;
|
||||
|
||||
size += sizeof(lv_style_property_t) + sizeof(lv_opa_t);
|
||||
@@ -344,7 +344,7 @@ void lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, const void *
|
||||
lv_style_property_t end_mark = _LV_STYLE_CLOSEING_PROP;
|
||||
uint8_t end_mark_size = sizeof(end_mark);
|
||||
|
||||
uint16_t size = lv_style_get_size(style);
|
||||
uint16_t size = lv_style_get_mem_size(style);
|
||||
if(size == 0) size += end_mark_size;
|
||||
|
||||
size += sizeof(lv_style_property_t) + sizeof(void *);
|
||||
|
||||
@@ -78,7 +78,7 @@ typedef union {
|
||||
enum {
|
||||
LV_STYLE_PROP_INIT(LV_STYLE_RADIUS, 0x0, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
|
||||
LV_STYLE_PROP_INIT(LV_STYLE_CLIP_CORNER, 0x0, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE),
|
||||
LV_STYLE_PROP_INIT(LV_STYLE_TRANSITION_TIME, 0x0, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE),
|
||||
LV_STYLE_PROP_INIT(LV_STYLE_TRANSITION_TIME, 0x0, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE),
|
||||
LV_STYLE_PROP_INIT(LV_STYLE_OPA_SCALE, 0x0, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_INHERIT),
|
||||
|
||||
LV_STYLE_PROP_INIT(LV_STYLE_PAD_TOP, 0x1, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
|
||||
@@ -153,6 +153,7 @@ typedef uint16_t lv_style_property_t;
|
||||
#define LV_STYLE_STATE_MASK 0x7F00
|
||||
|
||||
enum {
|
||||
LV_STYLE_STATE_NORMAL = 0,
|
||||
LV_STYLE_STATE_CHECKED = (1 << (0 + LV_STYLE_STATE_POS)),
|
||||
LV_STYLE_STATE_FOCUS = (1 << (1 + LV_STYLE_STATE_POS)),
|
||||
LV_STYLE_STATE_EDIT = (1 << (2 + LV_STYLE_STATE_POS)),
|
||||
@@ -213,8 +214,7 @@ void lv_style_list_reset(lv_style_list_t * style_dsc);
|
||||
|
||||
static inline lv_style_t * lv_style_list_get_style(lv_style_list_t * style_dsc, uint8_t id)
|
||||
{
|
||||
if(style_dsc->style_cnt == 0) return NULL;
|
||||
if(id >= style_dsc->style_cnt) return NULL;
|
||||
if(style_dsc->style_cnt == 0 || id >= style_dsc->style_cnt) return NULL;
|
||||
|
||||
return style_dsc->style_list[id];
|
||||
|
||||
@@ -222,7 +222,7 @@ static inline lv_style_t * lv_style_list_get_style(lv_style_list_t * style_dsc,
|
||||
|
||||
void lv_style_reset(lv_style_t * style);
|
||||
|
||||
uint16_t lv_style_get_size(lv_style_t * style);
|
||||
uint16_t lv_style_get_mem_size(lv_style_t * style);
|
||||
|
||||
/**
|
||||
* Copy a style to an other
|
||||
|
||||
@@ -48,6 +48,9 @@ static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t tickness,
|
||||
*/
|
||||
void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uint16_t start_angle, uint16_t end_angle, const lv_area_t * clip_area, lv_draw_line_dsc_t * dsc)
|
||||
{
|
||||
if(dsc->opa <= LV_OPA_MIN) return;
|
||||
if(dsc->width == 0) return;
|
||||
|
||||
lv_draw_rect_dsc_t cir_dsc;
|
||||
lv_draw_rect_dsc_init(&cir_dsc);
|
||||
cir_dsc.radius = LV_RADIUS_CIRCLE;
|
||||
@@ -114,8 +117,8 @@ static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t tickness,
|
||||
int32_t thick_half = tickness / 2;
|
||||
uint8_t thick_corr = tickness & 0x01 ? 0 : 1;
|
||||
|
||||
lv_coord_t rx_corr;
|
||||
lv_coord_t ry_corr;
|
||||
int32_t rx_corr;
|
||||
int32_t ry_corr;
|
||||
|
||||
if(angle > 90 && angle < 270) rx_corr = 0;
|
||||
else rx_corr = 0;
|
||||
|
||||
@@ -110,8 +110,8 @@ void lv_blend_fill(const lv_area_t * clip_area, const lv_area_t * fill_area,
|
||||
|
||||
/*Round the values in the mask if anti-aliasing is disabled*/
|
||||
if(mask && disp->driver.antialiasing == 0) {
|
||||
lv_coord_t mask_w = lv_area_get_width(&draw_area);
|
||||
lv_coord_t i;
|
||||
int32_t mask_w = lv_area_get_width(&draw_area);
|
||||
int32_t i;
|
||||
for (i = 0; i < mask_w; i++) mask[i] = mask[i] > 128 ? LV_OPA_COVER : LV_OPA_TRANSP;
|
||||
}
|
||||
|
||||
@@ -156,8 +156,8 @@ void lv_blend_map(const lv_area_t * clip_area, const lv_area_t * map_area, const
|
||||
|
||||
/*Round the values in the mask if anti-aliasing is disabled*/
|
||||
if(mask && disp->driver.antialiasing == 0) {
|
||||
lv_coord_t mask_w = lv_area_get_width(&draw_area);
|
||||
lv_coord_t i;
|
||||
int32_t mask_w = lv_area_get_width(&draw_area);
|
||||
int32_t i;
|
||||
for (i = 0; i < mask_w; i++) mask[i] = mask[i] > 128 ? LV_OPA_COVER : LV_OPA_TRANSP;
|
||||
}
|
||||
if(disp->driver.set_px_cb) {
|
||||
@@ -183,10 +183,10 @@ static void fill_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, con
|
||||
lv_disp_t * disp = lv_refr_get_disp_refreshing();
|
||||
|
||||
/*Get the width of the `disp_area` it will be used to go to the next line*/
|
||||
lv_coord_t disp_w = lv_area_get_width(disp_area);
|
||||
int32_t disp_w = lv_area_get_width(disp_area);
|
||||
|
||||
lv_coord_t x;
|
||||
lv_coord_t y;
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
|
||||
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) {
|
||||
for(y = draw_area->y1; y <= draw_area->y2; y++) {
|
||||
@@ -201,11 +201,11 @@ static void fill_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, con
|
||||
const lv_opa_t * mask_tmp = mask - draw_area->x1;
|
||||
|
||||
/*Get the width of the `draw_area` it will be used to go to the next line of the mask*/
|
||||
lv_coord_t draw_area_w = lv_area_get_width(draw_area);
|
||||
int32_t draw_area_w = lv_area_get_width(draw_area);
|
||||
|
||||
for(y = draw_area->y1; y <= draw_area->y2; y++) {
|
||||
for(x = draw_area->x1; x <= draw_area->x2; x++) {
|
||||
disp->driver.set_px_cb(&disp->driver, (void*)disp_buf, disp_w, x, y, color, (uint16_t)((uint16_t)opa * mask_tmp[x]) >> 8);
|
||||
disp->driver.set_px_cb(&disp->driver, (void*)disp_buf, disp_w, x, y, color, (uint32_t)((uint32_t)opa * mask_tmp[x]) >> 8);
|
||||
}
|
||||
mask_tmp += draw_area_w;
|
||||
}
|
||||
@@ -220,16 +220,16 @@ static void fill_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, con
|
||||
lv_disp_t * disp = lv_refr_get_disp_refreshing();
|
||||
|
||||
/*Get the width of the `disp_area` it will be used to go to the next line*/
|
||||
lv_coord_t disp_w = lv_area_get_width(disp_area);
|
||||
int32_t disp_w = lv_area_get_width(disp_area);
|
||||
|
||||
/*Get the width of the `draw_area` it will be used to go to the next line of the mask*/
|
||||
lv_coord_t draw_area_w = lv_area_get_width(draw_area);
|
||||
int32_t draw_area_w = lv_area_get_width(draw_area);
|
||||
|
||||
/*Create a temp. disp_buf which always point to current line to draw*/
|
||||
lv_color_t * disp_buf_tmp = disp_buf + disp_w * draw_area->y1;
|
||||
|
||||
lv_coord_t x;
|
||||
lv_coord_t y;
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
|
||||
/*Simple fill (maybe with opacity), no masking*/
|
||||
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) {
|
||||
@@ -245,7 +245,7 @@ static void fill_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, con
|
||||
|
||||
/*Fill the first line. Use `memcpy` because it's faster then simple value assignment*/
|
||||
/*Set the first pixels manually*/
|
||||
lv_coord_t direct_fill_end = LV_MATH_MIN(draw_area->x2, draw_area->x1 + FILL_DIRECT_LEN + (draw_area_w & FILL_DIRECT_MASK) - 1);
|
||||
int32_t direct_fill_end = LV_MATH_MIN(draw_area->x2, draw_area->x1 + FILL_DIRECT_LEN + (draw_area_w & FILL_DIRECT_MASK) - 1);
|
||||
for(x = draw_area->x1; x <= direct_fill_end ; x++) {
|
||||
disp_buf_tmp[x].full = color.full;
|
||||
}
|
||||
@@ -344,7 +344,7 @@ static void fill_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, con
|
||||
for(x = draw_area->x1; x <= draw_area->x2; x++) {
|
||||
if(mask_tmp[x] == 0) continue;
|
||||
if(mask_tmp[x] != last_mask || last_dest_color.full != disp_buf_tmp[x].full) {
|
||||
lv_opa_t opa_tmp = (uint16_t)((uint16_t)mask_tmp[x] * opa) >> 8;
|
||||
lv_opa_t opa_tmp = (uint32_t)((uint32_t)mask_tmp[x] * opa) >> 8;
|
||||
#if LV_COLOR_SCREEN_TRANSP
|
||||
if(disp->driver.screen_transp) {
|
||||
lv_color_mix_with_alpha(disp_buf_tmp[x], disp_buf_tmp[x].ch.alpha, color, opa_tmp, &last_res_color, &last_res_color.ch.alpha);
|
||||
@@ -373,7 +373,7 @@ static void fill_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, co
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode)
|
||||
{
|
||||
/*Get the width of the `disp_area` it will be used to go to the next line*/
|
||||
lv_coord_t disp_w = lv_area_get_width(disp_area);
|
||||
int32_t disp_w = lv_area_get_width(disp_area);
|
||||
|
||||
/*Create a temp. disp_buf which always point to current line to draw*/
|
||||
lv_color_t * disp_buf_tmp = disp_buf + disp_w * draw_area->y1;
|
||||
@@ -393,8 +393,8 @@ static void fill_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, co
|
||||
break;
|
||||
}
|
||||
|
||||
lv_coord_t x;
|
||||
lv_coord_t y;
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
|
||||
/*Simple fill (maybe with opacity), no masking*/
|
||||
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) {
|
||||
@@ -414,7 +414,7 @@ static void fill_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, co
|
||||
/*Masked*/
|
||||
else {
|
||||
/*Get the width of the `draw_area` it will be used to go to the next line of the mask*/
|
||||
lv_coord_t draw_area_w = lv_area_get_width(draw_area);
|
||||
int32_t draw_area_w = lv_area_get_width(draw_area);
|
||||
|
||||
/* The mask is relative to the clipped area.
|
||||
* In the cycles below mask will be indexed from `draw_area.x1`
|
||||
@@ -432,7 +432,7 @@ static void fill_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, co
|
||||
for(x = draw_area->x1; x <= draw_area->x2; x++) {
|
||||
if(mask_tmp[x] == 0) continue;
|
||||
if(mask_tmp[x] != last_mask || last_dest_color.full != disp_buf_tmp[x].full) {
|
||||
lv_opa_t opa_tmp = mask_tmp[x] >= LV_OPA_MAX ? opa : (uint16_t)((uint16_t)mask_tmp[x] * opa) >> 8;
|
||||
lv_opa_t opa_tmp = mask_tmp[x] >= LV_OPA_MAX ? opa : (uint32_t)((uint32_t)mask_tmp[x] * opa) >> 8;
|
||||
|
||||
last_res_color = blend_fp(color, disp_buf_tmp[x], opa_tmp);
|
||||
last_mask = mask_tmp[x];
|
||||
@@ -454,21 +454,21 @@ static void map_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, cons
|
||||
lv_disp_t * disp = lv_refr_get_disp_refreshing();
|
||||
|
||||
/*Get the width of the `disp_area` it will be used to go to the next line*/
|
||||
lv_coord_t disp_w = lv_area_get_width(disp_area);
|
||||
int32_t disp_w = lv_area_get_width(disp_area);
|
||||
|
||||
/*Get the width of the `draw_area` it will be used to go to the next line of the mask*/
|
||||
lv_coord_t draw_area_w = lv_area_get_width(draw_area);
|
||||
int32_t draw_area_w = lv_area_get_width(draw_area);
|
||||
|
||||
/*Get the width of the `mask_area` it will be used to go to the next line*/
|
||||
lv_coord_t map_w = lv_area_get_width(map_area);
|
||||
int32_t map_w = lv_area_get_width(map_area);
|
||||
|
||||
/*Create a temp. map_buf which always point to current line to draw*/
|
||||
const lv_color_t * map_buf_tmp = map_buf + map_w * (draw_area->y1 - (map_area->y1 - disp_area->y1));
|
||||
|
||||
map_buf_tmp += (draw_area->x1 - (map_area->x1 - disp_area->x1));
|
||||
map_buf_tmp -= draw_area->x1;
|
||||
lv_coord_t x;
|
||||
lv_coord_t y;
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
|
||||
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) {
|
||||
for(y = draw_area->y1; y <= draw_area->y2; y++) {
|
||||
@@ -485,7 +485,7 @@ static void map_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, cons
|
||||
|
||||
for(y = draw_area->y1; y <= draw_area->y2; y++) {
|
||||
for(x = draw_area->x1; x <= draw_area->x2; x++) {
|
||||
disp->driver.set_px_cb(&disp->driver, (void*)disp_buf, disp_w, x, y, map_buf_tmp[x], (uint16_t)((uint16_t)opa * mask_tmp[x]) >> 8);
|
||||
disp->driver.set_px_cb(&disp->driver, (void*)disp_buf, disp_w, x, y, map_buf_tmp[x], (uint32_t)((uint32_t)opa * mask_tmp[x]) >> 8);
|
||||
}
|
||||
mask_tmp += draw_area_w;
|
||||
map_buf_tmp += map_w;
|
||||
@@ -500,13 +500,13 @@ static void map_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, cons
|
||||
{
|
||||
|
||||
/*Get the width of the `disp_area` it will be used to go to the next line*/
|
||||
lv_coord_t disp_w = lv_area_get_width(disp_area);
|
||||
int32_t disp_w = lv_area_get_width(disp_area);
|
||||
|
||||
/*Get the width of the `draw_area` it will be used to go to the next line of the mask*/
|
||||
lv_coord_t draw_area_w = lv_area_get_width(draw_area);
|
||||
int32_t draw_area_w = lv_area_get_width(draw_area);
|
||||
|
||||
/*Get the width of the `mask_area` it will be used to go to the next line*/
|
||||
lv_coord_t map_w = lv_area_get_width(map_area);
|
||||
int32_t map_w = lv_area_get_width(map_area);
|
||||
|
||||
/*Create a temp. disp_buf which always point to current line to draw*/
|
||||
lv_color_t * disp_buf_tmp = disp_buf + disp_w * draw_area->y1;
|
||||
@@ -519,8 +519,8 @@ static void map_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, cons
|
||||
lv_opa_t opa_composed;
|
||||
#endif
|
||||
|
||||
lv_coord_t x;
|
||||
lv_coord_t y;
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
|
||||
/*Simple fill (maybe with opacity), no masking*/
|
||||
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) {
|
||||
@@ -633,13 +633,13 @@ static void map_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, con
|
||||
{
|
||||
|
||||
/*Get the width of the `disp_area` it will be used to go to the next line*/
|
||||
lv_coord_t disp_w = lv_area_get_width(disp_area);
|
||||
int32_t disp_w = lv_area_get_width(disp_area);
|
||||
|
||||
/*Get the width of the `draw_area` it will be used to go to the next line of the mask*/
|
||||
lv_coord_t draw_area_w = lv_area_get_width(draw_area);
|
||||
int32_t draw_area_w = lv_area_get_width(draw_area);
|
||||
|
||||
/*Get the width of the `mask_area` it will be used to go to the next line*/
|
||||
lv_coord_t map_w = lv_area_get_width(map_area);
|
||||
int32_t map_w = lv_area_get_width(map_area);
|
||||
|
||||
/*Create a temp. disp_buf which always point to current line to draw*/
|
||||
lv_color_t * disp_buf_tmp = disp_buf + disp_w * draw_area->y1;
|
||||
@@ -661,8 +661,8 @@ static void map_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, con
|
||||
break;
|
||||
}
|
||||
|
||||
lv_coord_t x;
|
||||
lv_coord_t y;
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
|
||||
/*Simple fill (maybe with opacity), no masking*/
|
||||
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) {
|
||||
@@ -706,7 +706,7 @@ static inline lv_color_t color_blend_true_color_additive(lv_color_t fg, lv_color
|
||||
|
||||
if(opa <= LV_OPA_MIN) return bg;
|
||||
|
||||
uint16_t tmp;
|
||||
uint32_t tmp;
|
||||
#if LV_COLOR_DEPTH == 1
|
||||
tmp = bg.full + fg.full;
|
||||
fg.full = LV_MATH_MIN(tmp, 1);
|
||||
@@ -757,7 +757,7 @@ static inline lv_color_t color_blend_true_color_subtractive(lv_color_t fg, lv_co
|
||||
|
||||
if(opa <= LV_OPA_MIN) return bg;
|
||||
|
||||
int16_t tmp;
|
||||
int32_t tmp;
|
||||
tmp = bg.ch.red - fg.ch.red;
|
||||
fg.ch.red = LV_MATH_MAX(tmp, 0);
|
||||
|
||||
|
||||
@@ -66,12 +66,16 @@ void lv_draw_img_dsc_init(lv_draw_img_dsc_t * dsc)
|
||||
*/
|
||||
void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * src, lv_draw_img_dsc_t * dsc)
|
||||
{
|
||||
|
||||
|
||||
if(src == NULL) {
|
||||
LV_LOG_WARN("Image draw: src is NULL");
|
||||
show_error(coords, mask, "No\ndata");
|
||||
return;
|
||||
}
|
||||
|
||||
if(dsc->opa <= LV_OPA_MIN) return;
|
||||
|
||||
lv_res_t res;
|
||||
res = lv_img_draw_core(coords, mask, src, dsc);
|
||||
|
||||
@@ -221,16 +225,16 @@ static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mas
|
||||
lv_area_copy(&map_area_rot, coords);
|
||||
if(draw_dsc->angle || draw_dsc->zoom != LV_IMG_ZOOM_NONE) {
|
||||
/*Get the exact area which is required to show the rotated image*/
|
||||
lv_coord_t pivot_x = lv_area_get_width(coords) / 2 + coords->x1;
|
||||
lv_coord_t pivot_y = lv_area_get_height(coords) / 2 + coords->y1;
|
||||
int32_t pivot_x = lv_area_get_width(coords) / 2 + coords->x1;
|
||||
int32_t pivot_y = lv_area_get_height(coords) / 2 + coords->y1;
|
||||
|
||||
pivot_x = draw_dsc->pivot.x + coords->x1;
|
||||
pivot_y = draw_dsc->pivot.y + coords->y1;
|
||||
|
||||
lv_coord_t w = lv_area_get_width(coords);
|
||||
lv_coord_t w_zoom = (((w * draw_dsc->zoom) >> 8) - w) / 2;
|
||||
lv_coord_t h = lv_area_get_height(coords);
|
||||
lv_coord_t h_zoom = (((h * draw_dsc->zoom) >> 8) - h) / 2;
|
||||
int32_t w = lv_area_get_width(coords);
|
||||
int32_t w_zoom = (((w * draw_dsc->zoom) >> 8) - w) / 2;
|
||||
int32_t h = lv_area_get_height(coords);
|
||||
int32_t h_zoom = (((h * draw_dsc->zoom) >> 8) - h) / 2;
|
||||
|
||||
lv_area_t norm;
|
||||
norm.x1 = coords->x1 - pivot_x - w_zoom;
|
||||
@@ -283,16 +287,16 @@ static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mas
|
||||
successfully.*/
|
||||
}
|
||||
|
||||
lv_coord_t width = lv_area_get_width(&mask_com);
|
||||
int32_t width = lv_area_get_width(&mask_com);
|
||||
|
||||
uint8_t * buf = lv_mem_buf_get(lv_area_get_width(&mask_com) * LV_IMG_PX_SIZE_ALPHA_BYTE); /*+1 because of the possible alpha byte*/
|
||||
|
||||
lv_area_t line;
|
||||
lv_area_copy(&line, &mask_com);
|
||||
lv_area_set_height(&line, 1);
|
||||
lv_coord_t x = mask_com.x1 - coords->x1;
|
||||
lv_coord_t y = mask_com.y1 - coords->y1;
|
||||
lv_coord_t row;
|
||||
int32_t x = mask_com.x1 - coords->x1;
|
||||
int32_t y = mask_com.y1 - coords->y1;
|
||||
int32_t row;
|
||||
lv_res_t read_res;
|
||||
for(row = mask_com.y1; row <= mask_com.y2; row++) {
|
||||
lv_area_t mask_line;
|
||||
@@ -369,8 +373,8 @@ static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area,
|
||||
lv_opa_t * mask_buf = lv_mem_buf_get(mask_buf_size);
|
||||
|
||||
/*Go to the first displayed pixel of the map*/
|
||||
lv_coord_t map_w = lv_area_get_width(map_area);
|
||||
lv_coord_t map_h = lv_area_get_height(map_area);
|
||||
int32_t map_w = lv_area_get_width(map_area);
|
||||
int32_t map_h = lv_area_get_height(map_area);
|
||||
const uint8_t * map_buf_tmp = map_p;
|
||||
map_buf_tmp += map_w * (draw_area.y1 - (map_area->y1 - disp_area->y1)) * px_size_byte;
|
||||
map_buf_tmp += (draw_area.x1 - (map_area->x1 - disp_area->x1)) * px_size_byte;
|
||||
@@ -419,8 +423,8 @@ static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area,
|
||||
|
||||
lv_draw_mask_res_t mask_res;
|
||||
mask_res = (alpha_byte || chroma_key || draw_dsc->angle) ? LV_DRAW_MASK_RES_CHANGED : LV_DRAW_MASK_RES_FULL_COVER;
|
||||
lv_coord_t x;
|
||||
lv_coord_t y;
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
for(y = 0; y < lv_area_get_height(&draw_area); y++) {
|
||||
map_px = map_buf_tmp;
|
||||
px_i_start = px_i;
|
||||
@@ -452,8 +456,8 @@ static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area,
|
||||
} else {
|
||||
/*Rotate*/
|
||||
bool ret;
|
||||
lv_coord_t rot_x = x + (disp_area->x1 + draw_area.x1) - map_area->x1;
|
||||
lv_coord_t rot_y = y + (disp_area->y1 + draw_area.y1) - map_area->y1;
|
||||
int32_t rot_x = x + (disp_area->x1 + draw_area.x1) - map_area->x1;
|
||||
int32_t rot_y = y + (disp_area->y1 + draw_area.y1) - map_area->y1;
|
||||
ret = lv_img_buf_transform(&trans_dsc, rot_x, rot_y);
|
||||
if(ret == false) {
|
||||
mask_buf[px_i] = LV_OPA_TRANSP;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "../lv_hal/lv_hal_disp.h"
|
||||
#include "../lv_core/lv_refr.h"
|
||||
#include "../lv_misc/lv_bidi.h"
|
||||
#include "../lv_core/lv_debug.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -81,8 +82,9 @@ void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc)
|
||||
void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_label_dsc_t * dsc,
|
||||
const char * txt, lv_draw_label_hint_t * hint)
|
||||
{
|
||||
if(dsc->opa <= LV_OPA_MIN) return;
|
||||
const lv_font_t * font = dsc->font;
|
||||
lv_coord_t w;
|
||||
int32_t w;
|
||||
|
||||
/*No need to waste processor time if string is empty*/
|
||||
if (txt[0] == '\0') return;
|
||||
@@ -98,16 +100,16 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab
|
||||
w = p.x;
|
||||
}
|
||||
|
||||
lv_coord_t line_height = lv_font_get_line_height(font) + dsc->line_space;
|
||||
int32_t line_height = lv_font_get_line_height(font) + dsc->line_space;
|
||||
|
||||
/*Init variables for the first line*/
|
||||
lv_coord_t line_width = 0;
|
||||
int32_t line_width = 0;
|
||||
lv_point_t pos;
|
||||
pos.x = coords->x1;
|
||||
pos.y = coords->y1;
|
||||
|
||||
lv_coord_t x_ofs = 0;
|
||||
lv_coord_t y_ofs = 0;
|
||||
int32_t x_ofs = 0;
|
||||
int32_t y_ofs = 0;
|
||||
x_ofs = dsc->ofs_x;
|
||||
y_ofs = dsc->ofs_y;
|
||||
pos.y += y_ofs;
|
||||
@@ -186,14 +188,14 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab
|
||||
uint32_t i;
|
||||
uint16_t par_start = 0;
|
||||
lv_color_t recolor;
|
||||
lv_coord_t letter_w;
|
||||
int32_t letter_w;
|
||||
|
||||
|
||||
lv_draw_rect_dsc_t draw_dsc_sel;
|
||||
lv_draw_rect_dsc_init(&draw_dsc_sel);
|
||||
draw_dsc_sel.bg_color = dsc->sel_color;
|
||||
|
||||
lv_coord_t pos_x_start = pos.x;
|
||||
int32_t pos_x_start = pos.x;
|
||||
/*Write out all lines*/
|
||||
while(txt[line_start] != '\0') {
|
||||
pos.x += x_ofs;
|
||||
@@ -337,7 +339,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab
|
||||
if(pos.y > mask->y2) return;
|
||||
}
|
||||
|
||||
lv_mem_test();
|
||||
LV_ASSERT_MEM_INTEGRITY();
|
||||
}
|
||||
|
||||
/**********************
|
||||
@@ -376,8 +378,8 @@ static void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * clip_area
|
||||
return;
|
||||
}
|
||||
|
||||
lv_coord_t pos_x = pos_p->x + g.ofs_x;
|
||||
lv_coord_t pos_y = pos_p->y + (font_p->line_height - font_p->base_line) - g.box_h - g.ofs_y;
|
||||
int32_t pos_x = pos_p->x + g.ofs_x;
|
||||
int32_t pos_y = pos_p->y + (font_p->line_height - font_p->base_line) - g.box_h - g.ofs_y;
|
||||
|
||||
/*If the letter is completely out of mask don't draw it */
|
||||
if(pos_x + g.box_w < clip_area->x1 ||
|
||||
@@ -404,12 +406,12 @@ static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph
|
||||
{
|
||||
|
||||
const uint8_t * bpp_opa_table;
|
||||
uint8_t bitmask_init;
|
||||
uint8_t bitmask;
|
||||
uint32_t bitmask_init;
|
||||
uint32_t bitmask;
|
||||
uint32_t bpp = g->bpp;
|
||||
if(bpp == 3) bpp = 4;
|
||||
|
||||
if(g->bpp == 3) g->bpp = 4;
|
||||
|
||||
switch(g->bpp) {
|
||||
switch(bpp) {
|
||||
case 1:
|
||||
bpp_opa_table = bpp1_opa_table;
|
||||
bitmask_init = 0x80;
|
||||
@@ -433,32 +435,32 @@ static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph
|
||||
|
||||
|
||||
|
||||
lv_coord_t col, row;
|
||||
int32_t col, row;
|
||||
|
||||
uint8_t width_byte_scr = g->box_w >> 3; /*Width in bytes (on the screen finally) (e.g. w = 11 -> 2 bytes wide)*/
|
||||
if(g->box_w & 0x7) width_byte_scr++;
|
||||
uint16_t width_bit = g->box_w * g->bpp; /*Letter width in bits*/
|
||||
uint16_t width_bit = g->box_w * bpp; /*Letter width in bits*/
|
||||
|
||||
|
||||
/* Calculate the col/row start/end on the map*/
|
||||
lv_coord_t col_start = pos_x >= clip_area->x1 ? 0 : clip_area->x1 - pos_x;
|
||||
lv_coord_t col_end = pos_x + g->box_w <= clip_area->x2 ? g->box_w : clip_area->x2 - pos_x + 1;
|
||||
lv_coord_t row_start = pos_y >= clip_area->y1 ? 0 : clip_area->y1 - pos_y;
|
||||
lv_coord_t row_end = pos_y + g->box_h <= clip_area->y2 ? g->box_h : clip_area->y2 - pos_y + 1;
|
||||
int32_t col_start = pos_x >= clip_area->x1 ? 0 : clip_area->x1 - pos_x;
|
||||
int32_t col_end = pos_x + g->box_w <= clip_area->x2 ? g->box_w : clip_area->x2 - pos_x + 1;
|
||||
int32_t row_start = pos_y >= clip_area->y1 ? 0 : clip_area->y1 - pos_y;
|
||||
int32_t row_end = pos_y + g->box_h <= clip_area->y2 ? g->box_h : clip_area->y2 - pos_y + 1;
|
||||
|
||||
/*Move on the map too*/
|
||||
uint32_t bit_ofs = (row_start * width_bit) + (col_start * g->bpp);
|
||||
uint32_t bit_ofs = (row_start * width_bit) + (col_start * bpp);
|
||||
map_p += bit_ofs >> 3;
|
||||
|
||||
uint8_t letter_px;
|
||||
lv_opa_t px_opa;
|
||||
uint16_t col_bit;
|
||||
uint32_t col_bit;
|
||||
col_bit = bit_ofs & 0x7; /* "& 0x7" equals to "% 8" just faster */
|
||||
|
||||
uint32_t mask_buf_size = g->box_w * g->box_h > LV_HOR_RES_MAX ? g->box_w * g->box_h : LV_HOR_RES_MAX;
|
||||
lv_opa_t * mask_buf = lv_mem_buf_get(mask_buf_size);
|
||||
lv_coord_t mask_p = 0;
|
||||
lv_coord_t mask_p_start;
|
||||
int32_t mask_p = 0;
|
||||
int32_t mask_p_start;
|
||||
|
||||
lv_area_t fill_area;
|
||||
fill_area.x1 = col_start + pos_x;
|
||||
@@ -474,12 +476,12 @@ static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph
|
||||
for(col = col_start; col < col_end; col++) {
|
||||
|
||||
/*Load the pixel's opacity into the mask*/
|
||||
letter_px = (*map_p & bitmask) >> (8 - col_bit - g->bpp);
|
||||
letter_px = (*map_p & bitmask) >> (8 - col_bit - bpp);
|
||||
if(letter_px != 0) {
|
||||
if(opa == LV_OPA_COVER) {
|
||||
px_opa = g->bpp == 8 ? letter_px : bpp_opa_table[letter_px];
|
||||
px_opa = bpp == 8 ? letter_px : bpp_opa_table[letter_px];
|
||||
} else {
|
||||
px_opa = g->bpp == 8 ? (uint16_t)((uint16_t)letter_px * opa) >> 8
|
||||
px_opa = bpp == 8 ? (uint16_t)((uint16_t)letter_px * opa) >> 8
|
||||
: (uint16_t)((uint16_t)bpp_opa_table[letter_px] * opa) >> 8;
|
||||
}
|
||||
|
||||
@@ -490,9 +492,9 @@ static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph
|
||||
}
|
||||
|
||||
/*Go to the next column*/
|
||||
if(col_bit < 8 - g->bpp) {
|
||||
col_bit += g->bpp;
|
||||
bitmask = bitmask >> g->bpp;
|
||||
if(col_bit < 8 - bpp) {
|
||||
col_bit += bpp;
|
||||
bitmask = bitmask >> bpp;
|
||||
} else {
|
||||
col_bit = 0;
|
||||
bitmask = bitmask_init;
|
||||
@@ -523,7 +525,7 @@ static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph
|
||||
mask_p = 0;
|
||||
}
|
||||
|
||||
col_bit += ((g->box_w - col_end) + col_start) * g->bpp;
|
||||
col_bit += ((g->box_w - col_end) + col_start) * bpp;
|
||||
|
||||
map_p += (col_bit >> 3);
|
||||
col_bit = col_bit & 0x7;
|
||||
@@ -544,12 +546,12 @@ static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph
|
||||
static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_dsc_t * g, const lv_area_t * clip_area, const uint8_t * map_p, lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
const uint8_t * bpp_opa_table;
|
||||
uint8_t bitmask_init;
|
||||
uint8_t bitmask;
|
||||
uint32_t bitmask_init;
|
||||
uint32_t bitmask;
|
||||
uint32_t bpp = g->bpp;
|
||||
if(bpp == 3) bpp = 4;
|
||||
|
||||
if(g->bpp == 3) g->bpp = 4;
|
||||
|
||||
switch(g->bpp) {
|
||||
switch(bpp) {
|
||||
case 1:
|
||||
bpp_opa_table = bpp1_opa_table;
|
||||
bitmask_init = 0x80;
|
||||
@@ -571,38 +573,38 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
|
||||
return; /*Invalid bpp. Can't render the letter*/
|
||||
}
|
||||
|
||||
lv_coord_t col, row;
|
||||
int32_t col, row;
|
||||
|
||||
uint8_t width_byte_scr = g->box_w >> 3; /*Width in bytes (on the screen finally) (e.g. w = 11 -> 2 bytes wide)*/
|
||||
uint32_t width_byte_scr = g->box_w >> 3; /*Width in bytes (on the screen finally) (e.g. w = 11 -> 2 bytes wide)*/
|
||||
if(g->box_w & 0x7) width_byte_scr++;
|
||||
uint16_t width_bit = g->box_w * g->bpp; /*Letter width in bits*/
|
||||
uint16_t width_bit = g->box_w * bpp; /*Letter width in bits*/
|
||||
|
||||
|
||||
/* Calculate the col/row start/end on the map*/
|
||||
lv_coord_t col_start = pos_x >= clip_area->x1 ? 0 : (clip_area->x1 - pos_x) * 3;
|
||||
lv_coord_t col_end = pos_x + g->box_w / 3 <= clip_area->x2 ? g->box_w : (clip_area->x2 - pos_x + 1) * 3;
|
||||
lv_coord_t row_start = pos_y >= clip_area->y1 ? 0 : clip_area->y1 - pos_y;
|
||||
lv_coord_t row_end = pos_y + g->box_h <= clip_area->y2 ? g->box_h : clip_area->y2 - pos_y + 1;
|
||||
int32_t col_start = pos_x >= clip_area->x1 ? 0 : (clip_area->x1 - pos_x) * 3;
|
||||
int32_t col_end = pos_x + g->box_w / 3 <= clip_area->x2 ? g->box_w : (clip_area->x2 - pos_x + 1) * 3;
|
||||
int32_t row_start = pos_y >= clip_area->y1 ? 0 : clip_area->y1 - pos_y;
|
||||
int32_t row_end = pos_y + g->box_h <= clip_area->y2 ? g->box_h : clip_area->y2 - pos_y + 1;
|
||||
|
||||
/*Move on the map too*/
|
||||
uint32_t bit_ofs = (row_start * width_bit) + (col_start * g->bpp);
|
||||
uint32_t bit_ofs = (row_start * width_bit) + (col_start * bpp);
|
||||
map_p += bit_ofs >> 3;
|
||||
|
||||
uint8_t letter_px;
|
||||
lv_opa_t px_opa;
|
||||
uint16_t col_bit;
|
||||
uint32_t col_bit;
|
||||
col_bit = bit_ofs & 0x7; /* "& 0x7" equals to "% 8" just faster */
|
||||
|
||||
uint32_t mask_buf_size = g->box_w * g->box_h > LV_HOR_RES_MAX ? g->box_w * g->box_h : LV_HOR_RES_MAX;
|
||||
lv_opa_t * mask_buf = lv_mem_buf_get(mask_buf_size);
|
||||
lv_coord_t mask_p = 0;
|
||||
lv_coord_t mask_p_start;
|
||||
int32_t mask_p = 0;
|
||||
int32_t mask_p_start;
|
||||
lv_color_t * color_buf = lv_mem_buf_get(mask_buf_size * sizeof(lv_color_t));
|
||||
|
||||
lv_disp_t * disp = lv_refr_get_disp_refreshing();
|
||||
lv_disp_buf_t * vdb = lv_disp_get_buf(disp);
|
||||
|
||||
lv_coord_t vdb_width = lv_area_get_width(&vdb->area);
|
||||
int32_t vdb_width = lv_area_get_width(&vdb->area);
|
||||
lv_color_t * vdb_buf_tmp = vdb->buf_act;
|
||||
|
||||
/*Set a pointer on VDB to the first pixel of the letter*/
|
||||
@@ -628,18 +630,18 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
|
||||
#endif
|
||||
|
||||
for(row = row_start ; row < row_end; row++) {
|
||||
uint8_t subpx_cnt = 0;
|
||||
uint32_t subpx_cnt = 0;
|
||||
bitmask = bitmask_init >> col_bit;
|
||||
mask_p_start = mask_p;
|
||||
for(col = col_start; col < col_end; col++) {
|
||||
/*Load the pixel's opacity into the mask*/
|
||||
letter_px = (*map_p & bitmask) >> (8 - col_bit - g->bpp);
|
||||
letter_px = (*map_p & bitmask) >> (8 - col_bit - bpp);
|
||||
if(letter_px != 0) {
|
||||
if(opa == LV_OPA_COVER) {
|
||||
px_opa = g->bpp == 8 ? letter_px : bpp_opa_table[letter_px];
|
||||
px_opa = bpp == 8 ? letter_px : bpp_opa_table[letter_px];
|
||||
} else {
|
||||
px_opa = g->bpp == 8 ? (uint16_t)((uint16_t)letter_px * opa) >> 8
|
||||
: (uint16_t)((uint16_t)bpp_opa_table[letter_px] * opa) >> 8;
|
||||
px_opa = bpp == 8 ? (uint32_t)((uint32_t)letter_px * opa) >> 8
|
||||
: (uint32_t)((uint32_t)bpp_opa_table[letter_px] * opa) >> 8;
|
||||
}
|
||||
} else {
|
||||
px_opa = 0;
|
||||
@@ -686,9 +688,9 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
|
||||
}
|
||||
|
||||
/*Go to the next column*/
|
||||
if(col_bit < 8 - g->bpp) {
|
||||
col_bit += g->bpp;
|
||||
bitmask = bitmask >> g->bpp;
|
||||
if(col_bit < 8 - bpp) {
|
||||
col_bit += bpp;
|
||||
bitmask = bitmask >> bpp;
|
||||
} else {
|
||||
col_bit = 0;
|
||||
bitmask = bitmask_init;
|
||||
@@ -714,7 +716,7 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
|
||||
mask_p = 0;
|
||||
}
|
||||
|
||||
col_bit += ((g->box_w - col_end) + col_start) * g->bpp;
|
||||
col_bit += ((g->box_w - col_end) + col_start) * bpp;
|
||||
|
||||
map_p += (col_bit >> 3);
|
||||
col_bit = col_bit & 0x7;
|
||||
|
||||
@@ -29,7 +29,6 @@ static void draw_line_skew(const lv_point_t * point1, const lv_point_t * point2,
|
||||
static void draw_line_hor(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, lv_draw_line_dsc_t * dsc);
|
||||
static void draw_line_ver(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, lv_draw_line_dsc_t * dsc);
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
@@ -61,6 +60,8 @@ void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc)
|
||||
void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, lv_draw_line_dsc_t * dsc)
|
||||
{
|
||||
if(dsc->width == 0) return;
|
||||
if(dsc->opa <= LV_OPA_MIN) return;
|
||||
|
||||
if(point1->x == point2->x && point1->y == point2->y) return;
|
||||
|
||||
lv_area_t clip_line;
|
||||
@@ -85,8 +86,8 @@ void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv
|
||||
cir_dsc.radius = LV_RADIUS_CIRCLE;
|
||||
cir_dsc.bg_opa = dsc->opa;
|
||||
|
||||
lv_coord_t r = (dsc->width >> 1);
|
||||
lv_coord_t r_corr = (dsc->width & 1) ? 0 : 1;
|
||||
int32_t r = (dsc->width >> 1);
|
||||
int32_t r_corr = (dsc->width & 1) ? 0 : 1;
|
||||
lv_area_t cir_area;
|
||||
|
||||
if(dsc->round_start) {
|
||||
@@ -120,9 +121,9 @@ static void draw_line_hor(const lv_point_t * point1, const lv_point_t * point2,
|
||||
|
||||
const lv_area_t * disp_area = &vdb->area;
|
||||
|
||||
lv_coord_t w = dsc->width - 1;
|
||||
lv_coord_t w_half0 = w >> 1;
|
||||
lv_coord_t w_half1 = w_half0 + (w & 0x1); /*Compensate rounding error*/
|
||||
int32_t w = dsc->width - 1;
|
||||
int32_t w_half0 = w >> 1;
|
||||
int32_t w_half1 = w_half0 + (w & 0x1); /*Compensate rounding error*/
|
||||
|
||||
bool dashed = dsc->dash_gap && dsc->dash_width ? true : false;
|
||||
|
||||
@@ -157,7 +158,7 @@ static void draw_line_hor(const lv_point_t * point1, const lv_point_t * point2,
|
||||
draw_area.x2 -= disp_area->x1;
|
||||
draw_area.y2 -= disp_area->y1;
|
||||
|
||||
lv_coord_t draw_area_w = lv_area_get_width(&draw_area);
|
||||
int32_t draw_area_w = lv_area_get_width(&draw_area);
|
||||
|
||||
lv_area_t fill_area;
|
||||
fill_area.x1 = draw_area.x1 + disp_area->x1;
|
||||
@@ -168,7 +169,7 @@ static void draw_line_hor(const lv_point_t * point1, const lv_point_t * point2,
|
||||
lv_style_int_t dash_start = (vdb->area.x1 + draw_area.x1) % (dsc->dash_gap + dsc->dash_width);
|
||||
|
||||
lv_opa_t * mask_buf = lv_mem_buf_get(draw_area_w);
|
||||
lv_coord_t h;
|
||||
int32_t h;
|
||||
lv_draw_mask_res_t mask_res;
|
||||
for(h = draw_area.y1; h <= draw_area.y2; h++) {
|
||||
memset(mask_buf, LV_OPA_COVER, draw_area_w);
|
||||
@@ -215,9 +216,9 @@ static void draw_line_ver(const lv_point_t * point1, const lv_point_t * point2,
|
||||
|
||||
const lv_area_t * disp_area = &vdb->area;
|
||||
|
||||
lv_coord_t w = dsc->width - 1;
|
||||
lv_coord_t w_half0 = w >> 1;
|
||||
lv_coord_t w_half1 = w_half0 + (w & 0x1); /*Compensate rounding error*/
|
||||
int32_t w = dsc->width - 1;
|
||||
int32_t w_half0 = w >> 1;
|
||||
int32_t w_half1 = w_half0 + (w & 0x1); /*Compensate rounding error*/
|
||||
|
||||
bool dashed = dsc->dash_gap && dsc->dash_width ? true : false;
|
||||
|
||||
@@ -252,7 +253,7 @@ static void draw_line_ver(const lv_point_t * point1, const lv_point_t * point2,
|
||||
draw_area.x2 -= vdb->area.x1;
|
||||
draw_area.y2 -= vdb->area.y1;
|
||||
|
||||
lv_coord_t draw_area_w = lv_area_get_width(&draw_area);
|
||||
int32_t draw_area_w = lv_area_get_width(&draw_area);
|
||||
|
||||
lv_area_t fill_area;
|
||||
fill_area.x1 = draw_area.x1 + disp_area->x1;
|
||||
@@ -265,7 +266,7 @@ static void draw_line_ver(const lv_point_t * point1, const lv_point_t * point2,
|
||||
lv_style_int_t dash_start = (vdb->area.y1 + draw_area.y1) % (dsc->dash_gap + dsc->dash_width);
|
||||
lv_style_int_t dash_cnt = dash_start;
|
||||
|
||||
lv_coord_t h;
|
||||
int32_t h;
|
||||
lv_draw_mask_res_t mask_res;
|
||||
for(h = draw_area.y1; h <= draw_area.y2; h++) {
|
||||
memset(mask_buf, LV_OPA_COVER, draw_area_w);
|
||||
@@ -315,8 +316,8 @@ static void draw_line_skew(const lv_point_t * point1, const lv_point_t * point2,
|
||||
p2.x = point1->x;
|
||||
}
|
||||
|
||||
lv_coord_t xdiff = p2.x - p1.x;
|
||||
lv_coord_t ydiff = p2.y - p1.y;
|
||||
int32_t xdiff = p2.x - p1.x;
|
||||
int32_t ydiff = p2.y - p1.y;
|
||||
bool flat = LV_MATH_ABS(xdiff) > LV_MATH_ABS(ydiff) ? true : false;
|
||||
|
||||
static const uint8_t wcorr[] = {
|
||||
@@ -327,14 +328,14 @@ static void draw_line_skew(const lv_point_t * point1, const lv_point_t * point2,
|
||||
181,
|
||||
};
|
||||
|
||||
lv_coord_t w = dsc->width;
|
||||
lv_coord_t wcorr_i = 0;
|
||||
int32_t w = dsc->width;
|
||||
int32_t wcorr_i = 0;
|
||||
if(flat) wcorr_i = (LV_MATH_ABS(ydiff) << 5) / LV_MATH_ABS(xdiff);
|
||||
else wcorr_i = (LV_MATH_ABS(xdiff) << 5) / LV_MATH_ABS(ydiff);
|
||||
|
||||
w = (w * wcorr[wcorr_i]) >> 7;
|
||||
lv_coord_t w_half0 = w >> 1;
|
||||
lv_coord_t w_half1 = w_half0 + (w & 0x1); /*Compensate rounding error*/
|
||||
int32_t w_half0 = w >> 1;
|
||||
int32_t w_half1 = w_half0 + (w & 0x1); /*Compensate rounding error*/
|
||||
|
||||
lv_area_t draw_area;
|
||||
draw_area.x1 = LV_MATH_MIN(p1.x, p2.x) - w;
|
||||
@@ -386,10 +387,10 @@ static void draw_line_skew(const lv_point_t * point1, const lv_point_t * point2,
|
||||
draw_area.x2 -= disp_area->x1;
|
||||
draw_area.y2 -= disp_area->y1;
|
||||
|
||||
lv_coord_t draw_area_w = lv_area_get_width(&draw_area);
|
||||
int32_t draw_area_w = lv_area_get_width(&draw_area);
|
||||
|
||||
/*Draw the background line by line*/
|
||||
lv_coord_t h;
|
||||
int32_t h;
|
||||
lv_draw_mask_res_t mask_res;
|
||||
lv_opa_t * mask_buf = lv_mem_buf_get(draw_area_w);
|
||||
lv_area_t fill_area;
|
||||
|
||||
@@ -200,8 +200,8 @@ void lv_draw_mask_line_points_init(lv_draw_mask_line_param_t * param, lv_coord_t
|
||||
param->dsc.cb = (lv_draw_mask_cb_t)lv_draw_mask_line;
|
||||
param->dsc.type = LV_DRAW_MASK_TYPE_LINE;
|
||||
|
||||
lv_coord_t dx = p2x-p1x;
|
||||
lv_coord_t dy = p2y-p1y;
|
||||
int32_t dx = p2x-p1x;
|
||||
int32_t dy = p2y-p1y;
|
||||
|
||||
if(param->flat) {
|
||||
/*Normalize the steep. Delta x should be relative to delta x = 1024*/
|
||||
@@ -267,8 +267,8 @@ void lv_draw_mask_line_angle_init(lv_draw_mask_line_param_t* param, lv_coord_t p
|
||||
if(angle > 180) angle -= 180; /*> 180 will swap the origo*/
|
||||
|
||||
|
||||
lv_coord_t p2x;
|
||||
lv_coord_t p2y;
|
||||
int32_t p2x;
|
||||
int32_t p2y;
|
||||
|
||||
p2x = (lv_trigo_sin(angle + 90) >> 5) + p1x;
|
||||
p2y = (lv_trigo_sin(angle) >> 5) + py;
|
||||
@@ -347,7 +347,7 @@ void lv_draw_mask_angle_init(lv_draw_mask_angle_param_t * param, lv_coord_t vert
|
||||
void lv_draw_mask_radius_init(lv_draw_mask_radius_param_t * param, const lv_area_t * rect, lv_coord_t radius, bool inv)
|
||||
{
|
||||
|
||||
lv_coord_t short_side = LV_MATH_MIN(lv_area_get_width(rect), lv_area_get_height(rect));
|
||||
int32_t short_side = LV_MATH_MIN(lv_area_get_width(rect), lv_area_get_height(rect));
|
||||
if(radius > short_side >> 1) radius = short_side >> 1;
|
||||
|
||||
lv_area_copy(¶m->cfg.rect, rect);
|
||||
@@ -455,7 +455,7 @@ static lv_draw_mask_res_t lv_draw_mask_line(lv_opa_t * mask_buf, lv_coord_t abs_
|
||||
|
||||
static lv_draw_mask_res_t line_mask_flat(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len, lv_draw_mask_line_param_t * p)
|
||||
{
|
||||
lv_coord_t y_at_x;
|
||||
int32_t y_at_x;
|
||||
y_at_x = (int32_t)((int32_t)p->yx_steep * abs_x) >> 10;
|
||||
|
||||
if(p->yx_steep > 0) {
|
||||
@@ -565,7 +565,7 @@ static lv_draw_mask_res_t line_mask_flat(lv_opa_t * mask_buf, lv_coord_t abs_x,
|
||||
static lv_draw_mask_res_t line_mask_steep(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len, lv_draw_mask_line_param_t * p)
|
||||
{
|
||||
int32_t k;
|
||||
lv_coord_t x_at_y;
|
||||
int32_t x_at_y;
|
||||
/* At the beginning of the mask if the limit line is greater then the mask's y.
|
||||
* Then the mask is in the "wrong" area*/
|
||||
x_at_y = (int32_t)((int32_t)p->xy_steep * abs_y) >> 10;
|
||||
@@ -697,8 +697,8 @@ static lv_draw_mask_res_t line_mask_steep(lv_opa_t * mask_buf, lv_coord_t abs_x,
|
||||
|
||||
static lv_draw_mask_res_t lv_draw_mask_angle(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len, lv_draw_mask_angle_param_t * p)
|
||||
{
|
||||
lv_coord_t rel_y = abs_y - p->cfg.vertex_p.y;
|
||||
lv_coord_t rel_x = abs_x - p->cfg.vertex_p.x;
|
||||
int32_t rel_y = abs_y - p->cfg.vertex_p.y;
|
||||
int32_t rel_x = abs_x - p->cfg.vertex_p.x;
|
||||
|
||||
|
||||
if(p->cfg.start_angle < 180 && p->cfg.end_angle < 180 &&
|
||||
@@ -710,8 +710,8 @@ static lv_draw_mask_res_t lv_draw_mask_angle(lv_opa_t * mask_buf, lv_coord_t abs
|
||||
}
|
||||
|
||||
/*Start angle mask can work only from the end of end angle mask */
|
||||
lv_coord_t end_angle_first = (rel_y * p->end_line.xy_steep) >> 10;
|
||||
lv_coord_t start_angle_last= ((rel_y+1) * p->start_line.xy_steep) >> 10;
|
||||
int32_t end_angle_first = (rel_y * p->end_line.xy_steep) >> 10;
|
||||
int32_t start_angle_last= ((rel_y+1) * p->start_line.xy_steep) >> 10;
|
||||
|
||||
|
||||
/*Do not let the line end cross the vertex else it will affect the opposite part*/
|
||||
@@ -754,8 +754,8 @@ static lv_draw_mask_res_t lv_draw_mask_angle(lv_opa_t * mask_buf, lv_coord_t abs
|
||||
}
|
||||
|
||||
/*Start angle mask can work only from the end of end angle mask */
|
||||
lv_coord_t end_angle_first = (rel_y * p->end_line.xy_steep) >> 10;
|
||||
lv_coord_t start_angle_last= ((rel_y+1) * p->start_line.xy_steep) >> 10;
|
||||
int32_t end_angle_first = (rel_y * p->end_line.xy_steep) >> 10;
|
||||
int32_t start_angle_last= ((rel_y+1) * p->start_line.xy_steep) >> 10;
|
||||
|
||||
/*Do not let the line end cross the vertex else it will affect the opposite part*/
|
||||
if(p->cfg.start_angle > 270 && p->cfg.start_angle <= 359 && start_angle_last < 0) start_angle_last = 0;
|
||||
@@ -878,8 +878,8 @@ static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * mask_buf, lv_coord_t ab
|
||||
}
|
||||
|
||||
int32_t k = p->cfg.rect.x1 -abs_x; /*First relevant coordinate on the of the mask*/
|
||||
lv_coord_t w = lv_area_get_width(&p->cfg.rect);
|
||||
lv_coord_t h = lv_area_get_height(&p->cfg.rect);
|
||||
int32_t w = lv_area_get_width(&p->cfg.rect);
|
||||
int32_t h = lv_area_get_height(&p->cfg.rect);
|
||||
abs_x -= p->cfg.rect.x1;
|
||||
abs_y -= p->cfg.rect.y1;
|
||||
|
||||
@@ -888,7 +888,7 @@ static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * mask_buf, lv_coord_t ab
|
||||
/*Handle corner areas*/
|
||||
if(abs_y < p->cfg.radius || abs_y > h - p->cfg.radius - 1) {
|
||||
/* y = 0 should mean the top of the circle */
|
||||
lv_coord_t y;
|
||||
int32_t y;
|
||||
if(abs_y < p->cfg.radius) y = p->cfg.radius - abs_y;
|
||||
else y = p->cfg.radius - (h - abs_y) + 1;
|
||||
|
||||
@@ -1049,13 +1049,13 @@ static lv_draw_mask_res_t lv_draw_mask_fade(lv_opa_t * mask_buf, lv_coord_t abs_
|
||||
if(abs_x + len > p->cfg.coords.x2) len -= abs_x + len - p->cfg.coords.x2 - 1;
|
||||
|
||||
if(abs_x < p->cfg.coords.x1) {
|
||||
lv_coord_t x_ofs = 0;
|
||||
int32_t x_ofs = 0;
|
||||
x_ofs = p->cfg.coords.x1 - abs_x;
|
||||
len -= x_ofs;
|
||||
mask_buf += x_ofs;
|
||||
}
|
||||
|
||||
lv_coord_t i;
|
||||
int32_t i;
|
||||
|
||||
if(abs_y <= p->cfg.y_top) {
|
||||
for(i = 0; i < len; i++) {
|
||||
@@ -1070,7 +1070,7 @@ static lv_draw_mask_res_t lv_draw_mask_fade(lv_opa_t * mask_buf, lv_coord_t abs_
|
||||
} else {
|
||||
/*Calculate the opa proportionally*/
|
||||
int16_t opa_diff = p->cfg.opa_bottom - p->cfg.opa_top;
|
||||
lv_coord_t y_diff = p->cfg.y_bottom - p->cfg.y_top + 1;
|
||||
int32_t y_diff = p->cfg.y_bottom - p->cfg.y_top + 1;
|
||||
lv_opa_t opa_act = (int32_t)((int32_t)(abs_y - p->cfg.y_top) * opa_diff) / y_diff;
|
||||
opa_act += p->cfg.opa_top;
|
||||
|
||||
@@ -1100,7 +1100,7 @@ static lv_draw_mask_res_t lv_draw_mask_map(lv_opa_t * mask_buf, lv_coord_t abs_x
|
||||
if(abs_x + len > p->cfg.coords.x2) len -= abs_x + len - p->cfg.coords.x2 - 1;
|
||||
|
||||
if(abs_x < p->cfg.coords.x1) {
|
||||
lv_coord_t x_ofs = 0;
|
||||
int32_t x_ofs = 0;
|
||||
x_ofs = p->cfg.coords.x1 - abs_x;
|
||||
len -= x_ofs;
|
||||
mask_buf += x_ofs;
|
||||
@@ -1108,7 +1108,7 @@ static lv_draw_mask_res_t lv_draw_mask_map(lv_opa_t * mask_buf, lv_coord_t abs_x
|
||||
map_tmp += (abs_x - p->cfg.coords.x1);
|
||||
}
|
||||
|
||||
lv_coord_t i;
|
||||
int32_t i;
|
||||
for(i = 0; i < len; i++) {
|
||||
mask_buf[i] = mask_mix(mask_buf[i], map_tmp[i]);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "../lv_misc/lv_circ.h"
|
||||
#include "../lv_misc/lv_math.h"
|
||||
#include "../lv_core/lv_refr.h"
|
||||
#include "../lv_core/lv_debug.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -29,7 +30,7 @@
|
||||
static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc);
|
||||
static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc);
|
||||
static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc);
|
||||
static lv_color_t grad_get(lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i);
|
||||
static inline lv_color_t grad_get(lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i);
|
||||
static void shadow_draw_corner_buf(const lv_area_t * coords, lv_opa_t * sh_buf, lv_coord_t s, lv_coord_t r);
|
||||
static void shadow_blur_corner(lv_coord_t size, lv_coord_t sw, lv_opa_t * res_buf, uint16_t * sh_ups_buf);
|
||||
static void draw_img(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc);
|
||||
@@ -78,7 +79,7 @@ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect
|
||||
draw_img(coords, clip, dsc);
|
||||
draw_border(coords, clip, dsc);
|
||||
|
||||
lv_mem_test();
|
||||
LV_ASSERT_MEM_INTEGRITY();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,6 +120,8 @@ void lv_draw_px(const lv_point_t * point, const lv_area_t * clip_area, const lv_
|
||||
|
||||
static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc)
|
||||
{
|
||||
if(dsc->bg_opa <= LV_OPA_MIN) return;
|
||||
|
||||
lv_area_t coords_bg;
|
||||
lv_area_copy(&coords_bg, coords);
|
||||
|
||||
@@ -153,7 +156,7 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
|
||||
draw_area.x2 -= disp_area->x1;
|
||||
draw_area.y2 -= disp_area->y1;
|
||||
|
||||
lv_coord_t draw_area_w = lv_area_get_width(&draw_area);
|
||||
int32_t draw_area_w = lv_area_get_width(&draw_area);
|
||||
|
||||
/*Create a mask if there is a radius*/
|
||||
lv_opa_t * mask_buf = lv_mem_buf_get(draw_area_w);
|
||||
@@ -164,12 +167,12 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
|
||||
|
||||
int16_t mask_rout_id = LV_MASK_ID_INV;
|
||||
|
||||
lv_coord_t coords_w = lv_area_get_width(&coords_bg);
|
||||
lv_coord_t coords_h = lv_area_get_height(&coords_bg);
|
||||
int32_t coords_w = lv_area_get_width(&coords_bg);
|
||||
int32_t coords_h = lv_area_get_height(&coords_bg);
|
||||
|
||||
/*Get the real radius*/
|
||||
lv_coord_t rout = dsc->radius;
|
||||
lv_coord_t short_side = LV_MATH_MIN(coords_w, coords_h);
|
||||
int32_t rout = dsc->radius;
|
||||
int32_t short_side = LV_MATH_MIN(coords_w, coords_h);
|
||||
if(rout > short_side >> 1) rout = short_side >> 1;
|
||||
|
||||
/*Most simple case: just a plain rectangle*/
|
||||
@@ -188,7 +191,7 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
|
||||
|
||||
if(opa >= LV_OPA_MIN) {
|
||||
/*Draw the background line by line*/
|
||||
lv_coord_t h;
|
||||
int32_t h;
|
||||
lv_draw_mask_res_t mask_res = LV_DRAW_MASK_RES_FULL_COVER;
|
||||
lv_color_t grad_color = dsc->bg_color;
|
||||
|
||||
@@ -198,7 +201,7 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
|
||||
if(dsc->bg_grad_dir == LV_GRAD_DIR_HOR && dsc->bg_color.full != dsc->bg_grad_color.full) {
|
||||
grad_map = lv_mem_buf_get(coords_w * sizeof(lv_color_t));
|
||||
|
||||
lv_coord_t i;
|
||||
int32_t i;
|
||||
for(i = 0; i < coords_w; i++) {
|
||||
grad_map[i] = grad_get(dsc, coords_w, i);
|
||||
}
|
||||
@@ -210,7 +213,7 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
|
||||
fill_area.y1 = disp_area->y1 + draw_area.y1;
|
||||
fill_area.y2 = fill_area.y1;
|
||||
for(h = draw_area.y1; h <= draw_area.y2; h++) {
|
||||
lv_coord_t y = h + vdb->area.y1;
|
||||
int32_t y = h + vdb->area.y1;
|
||||
|
||||
/*In not corner areas apply the mask only if required*/
|
||||
if(y > coords_bg.y1 + rout + 1 &&
|
||||
@@ -259,7 +262,7 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
|
||||
fill_area2.x1 = coords_bg.x2 - rout + 1;
|
||||
fill_area2.x2 = coords_bg.x2;
|
||||
|
||||
lv_coord_t mask_ofs = (coords_bg.x2 - rout + 1) - (vdb->area.x1 + draw_area.x1);
|
||||
int32_t mask_ofs = (coords_bg.x2 - rout + 1) - (vdb->area.x1 + draw_area.x1);
|
||||
if(mask_ofs < 0) mask_ofs = 0;
|
||||
lv_blend_fill(clip, &fill_area2,
|
||||
grad_color, mask_buf + mask_ofs, mask_res, opa, dsc->bg_blend_mode);
|
||||
@@ -288,8 +291,8 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
|
||||
|
||||
static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc)
|
||||
{
|
||||
lv_coord_t border_width = dsc->border_width;
|
||||
if(border_width == 0) return;
|
||||
if(dsc->border_opa <= LV_OPA_MIN) return;
|
||||
if(dsc->border_width == 0) return;
|
||||
|
||||
lv_opa_t opa = dsc->border_opa;
|
||||
|
||||
@@ -314,7 +317,7 @@ static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
draw_area.x2 -= disp_area->x1;
|
||||
draw_area.y2 -= disp_area->y1;
|
||||
|
||||
lv_coord_t draw_area_w = lv_area_get_width(&draw_area);
|
||||
int32_t draw_area_w = lv_area_get_width(&draw_area);
|
||||
|
||||
/*Create a mask if there is a radius*/
|
||||
lv_opa_t * mask_buf = lv_mem_buf_get(draw_area_w);
|
||||
@@ -326,12 +329,12 @@ static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
|
||||
int16_t mask_rout_id = LV_MASK_ID_INV;
|
||||
|
||||
lv_coord_t coords_w = lv_area_get_width(coords);
|
||||
lv_coord_t coords_h = lv_area_get_height(coords);
|
||||
int32_t coords_w = lv_area_get_width(coords);
|
||||
int32_t coords_h = lv_area_get_height(coords);
|
||||
|
||||
/*Get the real radius*/
|
||||
lv_coord_t rout = dsc->radius;
|
||||
lv_coord_t short_side = LV_MATH_MIN(coords_w, coords_h);
|
||||
int32_t rout = dsc->radius;
|
||||
int32_t short_side = LV_MATH_MIN(coords_w, coords_h);
|
||||
if(rout > short_side >> 1) rout = short_side >> 1;
|
||||
|
||||
/*Get the outer area*/
|
||||
@@ -343,25 +346,25 @@ static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
|
||||
|
||||
/*Get the inner radius*/
|
||||
lv_coord_t rin = rout - border_width;
|
||||
int32_t rin = rout - dsc->border_width;
|
||||
if(rin < 0) rin = 0;
|
||||
|
||||
/*Get the inner area*/
|
||||
lv_area_t area_small;
|
||||
lv_area_copy(&area_small, coords);
|
||||
area_small.x1 += ((dsc->border_side & LV_BORDER_SIDE_LEFT) ? border_width : - (border_width + rout));
|
||||
area_small.x2 -= ((dsc->border_side & LV_BORDER_SIDE_RIGHT) ? border_width : - (border_width + rout));
|
||||
area_small.y1 += ((dsc->border_side & LV_BORDER_SIDE_TOP) ? border_width : - (border_width + rout));
|
||||
area_small.y2 -= ((dsc->border_side & LV_BORDER_SIDE_BOTTOM) ? border_width : - (border_width + rout));
|
||||
area_small.x1 += ((dsc->border_side & LV_BORDER_SIDE_LEFT) ? dsc->border_width : - (dsc->border_width + rout));
|
||||
area_small.x2 -= ((dsc->border_side & LV_BORDER_SIDE_RIGHT) ? dsc->border_width : - (dsc->border_width + rout));
|
||||
area_small.y1 += ((dsc->border_side & LV_BORDER_SIDE_TOP) ? dsc->border_width : - (dsc->border_width + rout));
|
||||
area_small.y2 -= ((dsc->border_side & LV_BORDER_SIDE_BOTTOM) ? dsc->border_width : - (dsc->border_width + rout));
|
||||
|
||||
/*Create inner the mask*/
|
||||
lv_draw_mask_radius_param_t mask_rin_param;
|
||||
lv_draw_mask_radius_init(&mask_rin_param, &area_small, rout - border_width, true);
|
||||
lv_draw_mask_radius_init(&mask_rin_param, &area_small, rout - dsc->border_width, true);
|
||||
int16_t mask_rin_id = lv_draw_mask_add(&mask_rin_param, NULL);
|
||||
|
||||
lv_coord_t corner_size = LV_MATH_MAX(rout, border_width - 1);
|
||||
int32_t corner_size = LV_MATH_MAX(rout, dsc->border_width - 1);
|
||||
|
||||
lv_coord_t h;
|
||||
int32_t h;
|
||||
lv_draw_mask_res_t mask_res;
|
||||
lv_area_t fill_area;
|
||||
|
||||
@@ -371,7 +374,7 @@ static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
/*Apply some optimization if there is no other mask*/
|
||||
if(simple_mode) {
|
||||
/*Draw the upper corner area*/
|
||||
lv_coord_t upper_corner_end = coords->y1 - disp_area->y1 + corner_size;
|
||||
int32_t upper_corner_end = coords->y1 - disp_area->y1 + corner_size;
|
||||
|
||||
fill_area.x1 = coords->x1;
|
||||
fill_area.x2 = coords->x2;
|
||||
@@ -390,7 +393,8 @@ static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
|
||||
lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode);
|
||||
|
||||
if(fill_area2.y2 < coords->y1 + border_width) {
|
||||
/*Draw the top horizontal line*/
|
||||
if(fill_area2.y2 < coords->y1 + dsc->border_width) {
|
||||
fill_area2.x1 = coords->x1 + rout;
|
||||
fill_area2.x2 = coords->x2 - rout;
|
||||
|
||||
@@ -400,7 +404,7 @@ static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
fill_area2.x1 = coords->x2 - rout + 1;
|
||||
fill_area2.x2 = coords->x2;
|
||||
|
||||
lv_coord_t mask_ofs = (coords->x2 - rout + 1) - (vdb->area.x1 + draw_area.x1);
|
||||
int32_t mask_ofs = (coords->x2 - rout + 1) - (vdb->area.x1 + draw_area.x1);
|
||||
if(mask_ofs < 0) mask_ofs = 0;
|
||||
lv_blend_fill(clip, &fill_area2, color, mask_buf + mask_ofs, mask_res, opa, blend_mode);
|
||||
|
||||
@@ -408,42 +412,40 @@ static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
fill_area.y2++;
|
||||
}
|
||||
|
||||
/*Draw the lower corner area corner area*/
|
||||
if(dsc->border_side & LV_BORDER_SIDE_BOTTOM) {
|
||||
lv_coord_t lower_corner_end = coords->y2 - disp_area->y1 - corner_size;
|
||||
if(lower_corner_end <= upper_corner_end) lower_corner_end = upper_corner_end + 1;
|
||||
fill_area.y1 = disp_area->y1 + lower_corner_end;
|
||||
fill_area.y2 = fill_area.y1;
|
||||
for(h = lower_corner_end; h <= draw_area.y2; h++) {
|
||||
memset(mask_buf, LV_OPA_COVER, draw_area_w);
|
||||
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
|
||||
/*Draw the lower corner area */
|
||||
int32_t lower_corner_end = coords->y2 - disp_area->y1 - corner_size;
|
||||
if(lower_corner_end <= upper_corner_end) lower_corner_end = upper_corner_end + 1;
|
||||
fill_area.y1 = disp_area->y1 + lower_corner_end;
|
||||
fill_area.y2 = fill_area.y1;
|
||||
for(h = lower_corner_end; h <= draw_area.y2; h++) {
|
||||
memset(mask_buf, LV_OPA_COVER, draw_area_w);
|
||||
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
|
||||
|
||||
lv_area_t fill_area2;
|
||||
fill_area2.x1 = coords->x1;
|
||||
fill_area2.x2 = coords->x1 + rout - 1;
|
||||
fill_area2.y1 = fill_area.y1;
|
||||
fill_area2.y2 = fill_area.y2;
|
||||
lv_area_t fill_area2;
|
||||
fill_area2.x1 = coords->x1;
|
||||
fill_area2.x2 = coords->x1 + rout - 1;
|
||||
fill_area2.y1 = fill_area.y1;
|
||||
fill_area2.y2 = fill_area.y2;
|
||||
|
||||
lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode);
|
||||
lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode);
|
||||
|
||||
/*Draw the bottom horizontal line*/
|
||||
if(fill_area2.y2 > coords->y2 - dsc->border_width ) {
|
||||
fill_area2.x1 = coords->x1 + rout;
|
||||
fill_area2.x2 = coords->x2 - rout;
|
||||
|
||||
if(fill_area2.y2 > coords->y2 - border_width ) {
|
||||
fill_area2.x1 = coords->x1 + rout;
|
||||
fill_area2.x2 = coords->x2 - rout;
|
||||
|
||||
lv_blend_fill(clip, &fill_area2, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
|
||||
}
|
||||
fill_area2.x1 = coords->x2 - rout + 1;
|
||||
fill_area2.x2 = coords->x2;
|
||||
|
||||
lv_coord_t mask_ofs = (coords->x2 - rout + 1) - (vdb->area.x1 + draw_area.x1);
|
||||
if(mask_ofs < 0) mask_ofs = 0;
|
||||
lv_blend_fill(clip, &fill_area2, color, mask_buf + mask_ofs, mask_res, opa, blend_mode);
|
||||
|
||||
|
||||
fill_area.y1++;
|
||||
fill_area.y2++;
|
||||
lv_blend_fill(clip, &fill_area2, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
|
||||
}
|
||||
fill_area2.x1 = coords->x2 - rout + 1;
|
||||
fill_area2.x2 = coords->x2;
|
||||
|
||||
int32_t mask_ofs = (coords->x2 - rout + 1) - (vdb->area.x1 + draw_area.x1);
|
||||
if(mask_ofs < 0) mask_ofs = 0;
|
||||
lv_blend_fill(clip, &fill_area2, color, mask_buf + mask_ofs, mask_res, opa, blend_mode);
|
||||
|
||||
|
||||
fill_area.y1++;
|
||||
fill_area.y2++;
|
||||
}
|
||||
|
||||
/*Draw the left vertical border part*/
|
||||
@@ -451,11 +453,11 @@ static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
fill_area.y2 = coords->y2 - corner_size - 1;
|
||||
|
||||
fill_area.x1 = coords->x1;
|
||||
fill_area.x2 = coords->x1 + border_width - 1;
|
||||
fill_area.x2 = coords->x1 + dsc->border_width - 1;
|
||||
lv_blend_fill(clip, &fill_area, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
|
||||
|
||||
/*Draw the right vertical border*/
|
||||
fill_area.x1 = coords->x2 - border_width + 1;
|
||||
fill_area.x1 = coords->x2 - dsc->border_width + 1;
|
||||
fill_area.x2 = coords->x2;
|
||||
|
||||
lv_blend_fill(clip, &fill_area, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
|
||||
@@ -482,15 +484,15 @@ static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
lv_mem_buf_release(mask_buf);
|
||||
}
|
||||
|
||||
static lv_color_t grad_get(lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i)
|
||||
static inline lv_color_t grad_get(lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i)
|
||||
{
|
||||
lv_coord_t min = (dsc->bg_main_color_stop * s) >> 8;
|
||||
int32_t min = (dsc->bg_main_color_stop * s) >> 8;
|
||||
if(i <= min) return dsc->bg_color;
|
||||
|
||||
lv_coord_t max = (dsc->bg_grad_color_stop * s) >> 8;
|
||||
int32_t max = (dsc->bg_grad_color_stop * s) >> 8;
|
||||
if(i >= max) return dsc->bg_grad_color;
|
||||
|
||||
lv_coord_t d = dsc->bg_grad_color_stop - dsc->bg_main_color_stop;
|
||||
int32_t d = dsc->bg_grad_color_stop - dsc->bg_main_color_stop;
|
||||
d = (s * d) >> 8;
|
||||
i -= min;
|
||||
lv_opa_t mix = (i * 255) / d;
|
||||
@@ -501,13 +503,14 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
{
|
||||
/*Check whether the shadow is visible*/
|
||||
if(dsc->shadow_width == 0) return;
|
||||
if(dsc->shadow_opa <= LV_OPA_MIN) return;
|
||||
|
||||
if(dsc->shadow_width == 1 && dsc->shadow_ofs_x == 0 &&
|
||||
dsc->shadow_ofs_y == 0 && dsc->shadow_spread <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
lv_coord_t sw = dsc->shadow_width;
|
||||
int32_t sw = dsc->shadow_width;
|
||||
|
||||
lv_area_t sh_rect_area;
|
||||
sh_rect_area.x1 = coords->x1 + dsc->shadow_ofs_x - dsc->shadow_spread;
|
||||
@@ -553,16 +556,16 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
bg_coords.y2 -= 1;
|
||||
|
||||
/*Get the real radius*/
|
||||
lv_coord_t r_bg = dsc->radius;
|
||||
lv_coord_t short_side = LV_MATH_MIN(lv_area_get_width(&bg_coords), lv_area_get_height(&bg_coords));
|
||||
int32_t r_bg = dsc->radius;
|
||||
int32_t short_side = LV_MATH_MIN(lv_area_get_width(&bg_coords), lv_area_get_height(&bg_coords));
|
||||
if(r_bg > short_side >> 1) r_bg = short_side >> 1;
|
||||
|
||||
lv_coord_t r_sh = dsc->radius;
|
||||
int32_t r_sh = dsc->radius;
|
||||
short_side = LV_MATH_MIN(lv_area_get_width(&sh_rect_area), lv_area_get_height(&sh_rect_area));
|
||||
if(r_sh > short_side >> 1) r_sh = short_side >> 1;
|
||||
|
||||
|
||||
lv_coord_t corner_size = sw + r_sh;
|
||||
int32_t corner_size = sw + r_sh;
|
||||
|
||||
lv_opa_t * sh_buf = lv_mem_buf_get(corner_size * corner_size);
|
||||
shadow_draw_corner_buf(&sh_rect_area, sh_buf, dsc->shadow_width, r_sh);
|
||||
@@ -572,7 +575,7 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
else if(dsc->shadow_ofs_x != 0 || dsc->shadow_ofs_y != 0) simple_mode = false;
|
||||
else if(dsc->shadow_spread != 0) simple_mode = false;
|
||||
|
||||
lv_coord_t y_max;
|
||||
int32_t y_max;
|
||||
|
||||
/*Create a mask*/
|
||||
lv_draw_mask_res_t mask_res;
|
||||
@@ -592,27 +595,27 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
a.y1 = sh_area.y1;
|
||||
a.y2 = a.y1;
|
||||
|
||||
lv_coord_t first_px;
|
||||
int32_t first_px;
|
||||
first_px = 0;
|
||||
if(disp_area->x1 > a.x1) {
|
||||
first_px = disp_area->x1 - a.x1;
|
||||
}
|
||||
|
||||
lv_coord_t hor_mid_dist = (sh_area.x1 + lv_area_get_width(&sh_area) / 2) - (a.x1 + first_px);
|
||||
int32_t hor_mid_dist = (sh_area.x1 + lv_area_get_width(&sh_area) / 2) - (a.x1 + first_px);
|
||||
if(hor_mid_dist > 0) {
|
||||
first_px += hor_mid_dist;
|
||||
}
|
||||
a.x1 += first_px;
|
||||
|
||||
lv_coord_t ver_mid_dist = (a.y1 + corner_size) - (sh_area.y1 + lv_area_get_height(&sh_area) / 2);
|
||||
lv_coord_t ver_mid_corr = 0;
|
||||
int32_t ver_mid_dist = (a.y1 + corner_size) - (sh_area.y1 + lv_area_get_height(&sh_area) / 2);
|
||||
int32_t ver_mid_corr = 0;
|
||||
if(ver_mid_dist <= 0) ver_mid_dist = 0;
|
||||
else {
|
||||
if(lv_area_get_height(&sh_area) & 0x1) ver_mid_corr = 1;
|
||||
}
|
||||
lv_opa_t * sh_buf_tmp = sh_buf;
|
||||
|
||||
lv_coord_t y;
|
||||
int32_t y;
|
||||
for(y = 0; y < corner_size - ver_mid_dist + ver_mid_corr; y++) {
|
||||
memcpy(mask_buf, sh_buf_tmp, corner_size);
|
||||
mask_res = lv_draw_mask_apply(mask_buf + first_px, a.x1, a.y1, lv_area_get_width(&a));
|
||||
@@ -648,7 +651,7 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
a.y2 = a.y1;
|
||||
sh_buf_tmp = sh_buf + corner_size * (corner_size - 1);
|
||||
|
||||
lv_coord_t x;
|
||||
int32_t x;
|
||||
|
||||
if(simple_mode) {
|
||||
/*Draw vertical lines*/
|
||||
@@ -826,7 +829,7 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
}
|
||||
|
||||
/*Fill the bottom side*/
|
||||
lv_coord_t y_min = simple_mode ? (corner_size - (sh_area.y2 - coords->y2)) : ver_mid_dist;
|
||||
int32_t y_min = simple_mode ? (corner_size - (sh_area.y2 - coords->y2)) : ver_mid_dist;
|
||||
if(y_min < 0) y_min = 0;
|
||||
sh_buf_tmp = sh_buf + corner_size * (corner_size - y_min - 1 ) + corner_size - 1;
|
||||
|
||||
@@ -877,8 +880,8 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
|
||||
static void shadow_draw_corner_buf(const lv_area_t * coords, lv_opa_t * sh_buf, lv_coord_t sw, lv_coord_t r)
|
||||
{
|
||||
lv_coord_t sw_ori = sw;
|
||||
lv_coord_t size = sw_ori + r;
|
||||
int32_t sw_ori = sw;
|
||||
int32_t size = sw_ori + r;
|
||||
|
||||
lv_area_t sh_area;
|
||||
lv_area_copy(&sh_area, coords);
|
||||
@@ -900,7 +903,7 @@ static void shadow_draw_corner_buf(const lv_area_t * coords, lv_opa_t * sh_buf,
|
||||
#endif
|
||||
|
||||
lv_draw_mask_res_t mask_res;
|
||||
lv_coord_t y;
|
||||
int32_t y;
|
||||
lv_opa_t * mask_line = lv_mem_buf_get(size);
|
||||
uint16_t * sh_ups_buf = lv_mem_buf_get(size * size * sizeof(uint16_t));
|
||||
uint16_t * sh_ups_tmp_buf = sh_ups_buf;
|
||||
@@ -910,7 +913,7 @@ static void shadow_draw_corner_buf(const lv_area_t * coords, lv_opa_t * sh_buf,
|
||||
if(mask_res == LV_DRAW_MASK_RES_FULL_TRANSP) {
|
||||
memset(sh_ups_tmp_buf, 0x00, size * sizeof(sh_ups_buf[0]));
|
||||
} else {
|
||||
lv_coord_t i;
|
||||
int32_t i;
|
||||
sh_ups_tmp_buf[0] = (mask_line[0] << SHADOW_UPSACALE_SHIFT) / sw;
|
||||
for(i = 1; i < size; i++) {
|
||||
if(mask_line[i] == mask_line[i-1]) sh_ups_tmp_buf[i] = sh_ups_tmp_buf[i-1];
|
||||
@@ -923,7 +926,7 @@ static void shadow_draw_corner_buf(const lv_area_t * coords, lv_opa_t * sh_buf,
|
||||
lv_mem_buf_release(mask_line);
|
||||
|
||||
if(sw == 1) {
|
||||
lv_coord_t i;
|
||||
int32_t i;
|
||||
for(i = 0; i < size * size; i++) {
|
||||
sh_buf[i] = (sh_ups_buf[i] >> SHADOW_UPSACALE_SHIFT);
|
||||
}
|
||||
@@ -955,16 +958,16 @@ static void shadow_draw_corner_buf(const lv_area_t * coords, lv_opa_t * sh_buf,
|
||||
|
||||
static void shadow_blur_corner(lv_coord_t size, lv_coord_t sw, lv_opa_t * res_buf, uint16_t * sh_ups_buf)
|
||||
{
|
||||
lv_coord_t s_left = sw >> 1;
|
||||
lv_coord_t s_right = (sw >> 1);
|
||||
int32_t s_left = sw >> 1;
|
||||
int32_t s_right = (sw >> 1);
|
||||
if((sw & 1) == 0) s_left--;
|
||||
|
||||
/*Horizontal blur*/
|
||||
uint16_t * sh_ups_hor_buf = lv_mem_buf_get(size * size * sizeof(uint16_t));
|
||||
uint16_t * sh_ups_hor_buf_tmp;
|
||||
|
||||
lv_coord_t x;
|
||||
lv_coord_t y;
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
|
||||
uint16_t * sh_ups_tmp_buf = sh_ups_buf;
|
||||
sh_ups_hor_buf_tmp = sh_ups_hor_buf;
|
||||
@@ -1033,8 +1036,8 @@ static void draw_img(const lv_area_t * coords, const lv_area_t * clip, lv_draw_r
|
||||
|
||||
lv_draw_img_dsc_t img_dsc;
|
||||
lv_draw_label_dsc_t label_dsc;
|
||||
lv_coord_t img_w;
|
||||
lv_coord_t img_h;
|
||||
int32_t img_w;
|
||||
int32_t img_h;
|
||||
|
||||
if(src_type == LV_IMG_SRC_FILE || src_type == LV_IMG_SRC_VARIABLE) {
|
||||
lv_img_header_t header;
|
||||
@@ -1077,8 +1080,8 @@ static void draw_img(const lv_area_t * coords, const lv_area_t * clip, lv_draw_r
|
||||
int16_t radius_mask_id = lv_draw_mask_add(&radius_mask_param, NULL);
|
||||
|
||||
/*Align the pattern to the middle*/
|
||||
lv_coord_t ofs_x = (lv_area_get_width(coords) - (lv_area_get_width(coords) / img_w) * img_w) / 2;
|
||||
lv_coord_t ofs_y = (lv_area_get_height(coords) - (lv_area_get_height(coords) / img_h) * img_h) / 2;
|
||||
int32_t ofs_x = (lv_area_get_width(coords) - (lv_area_get_width(coords) / img_w) * img_w) / 2;
|
||||
int32_t ofs_y = (lv_area_get_height(coords) - (lv_area_get_height(coords) / img_h) * img_h) / 2;
|
||||
|
||||
coords_tmp.y1 = coords->y1 - ofs_y;
|
||||
coords_tmp.y2 = coords_tmp.y1 + img_h - 1;
|
||||
@@ -1092,8 +1095,8 @@ static void draw_img(const lv_area_t * coords, const lv_area_t * clip, lv_draw_r
|
||||
}
|
||||
lv_draw_mask_remove_id(radius_mask_id);
|
||||
} else {
|
||||
lv_coord_t obj_w = lv_area_get_width(coords);
|
||||
lv_coord_t obj_h = lv_area_get_height(coords);
|
||||
int32_t obj_w = lv_area_get_width(coords);
|
||||
int32_t obj_h = lv_area_get_height(coords);
|
||||
coords_tmp.x1 = coords->x1 + (obj_w - img_w) / 2;
|
||||
coords_tmp.y1 = coords->y1 + (obj_h - img_h) / 2;
|
||||
coords_tmp.x2 = coords_tmp.x1 + img_w - 1;
|
||||
@@ -1103,7 +1106,7 @@ static void draw_img(const lv_area_t * coords, const lv_area_t * clip, lv_draw_r
|
||||
* It's better round up in case of symbols because probably there is some extra space in the bottom
|
||||
* due to the base line of font*/
|
||||
if(src_type == LV_IMG_SRC_SYMBOL) {
|
||||
lv_coord_t y_corr = (obj_h - img_h) & 0x1;
|
||||
int32_t y_corr = (obj_h - img_h) & 0x1;
|
||||
coords_tmp.y1 += y_corr;
|
||||
coords_tmp.y2 += y_corr;
|
||||
}
|
||||
|
||||
@@ -94,9 +94,14 @@ int32_t lv_bezier3(uint32_t t, int32_t u0, int32_t u1, int32_t u2, int32_t u3)
|
||||
|
||||
return v1 + v2 + v3 + v4;
|
||||
}
|
||||
#define BITSPERLONG 32
|
||||
#define SQRT_BITSPERLONG 32
|
||||
#define TOP2BITS(x) (x >> (SQRT_BITSPERLONG-2))
|
||||
#define SQRT_CORE r = (r << 2) + TOP2BITS(x); x <<= 2; \
|
||||
a <<= 1; \
|
||||
e = (a << 1) + 1; \
|
||||
if (r >= e) { r -= e; a++; } \
|
||||
|
||||
#define TOP2BITS(x) ((x & (3L << (BITSPERLONG-2))) >> (BITSPERLONG-2))
|
||||
#define SQRT_CORE_8_TIMES SQRT_CORE SQRT_CORE SQRT_CORE SQRT_CORE SQRT_CORE SQRT_CORE SQRT_CORE SQRT_CORE
|
||||
|
||||
void lv_sqrt(uint32_t x, lv_sqrt_res_t * q)
|
||||
{
|
||||
@@ -216,16 +221,10 @@ void lv_sqrt(uint32_t x, lv_sqrt_res_t * q)
|
||||
uint32_t r = 0L; /* remainder */
|
||||
uint32_t e = 0L; /* trial product */
|
||||
|
||||
uint32_t i;
|
||||
for (i = 0; i < BITSPERLONG / 2 + 8; i++) {
|
||||
r = (r << 2) + TOP2BITS(x); x <<= 2;
|
||||
a <<= 1;
|
||||
e = (a << 1) + 1;
|
||||
if (r >= e) {
|
||||
r -= e;
|
||||
a++;
|
||||
}
|
||||
}
|
||||
/*Unroll the loop*/
|
||||
SQRT_CORE_8_TIMES
|
||||
SQRT_CORE_8_TIMES
|
||||
SQRT_CORE_8_TIMES
|
||||
|
||||
q->f = a & 0xFF;
|
||||
q->i = a >> 8;
|
||||
|
||||
@@ -356,10 +356,8 @@ lv_res_t lv_mem_test(void)
|
||||
lv_mem_ent_t * e;
|
||||
e = ent_get_next(NULL);
|
||||
while(e) {
|
||||
if((e->header.s.used && e->header.s.d_size > 20000) ||
|
||||
if((e->header.s.used && e->header.s.d_size > LV_MEM_SIZE) ||
|
||||
(e->header.s.used == 0 && e->header.s.d_size > LV_MEM_SIZE)) {
|
||||
printf("mem err\n");
|
||||
while(1);
|
||||
return LV_RES_INV;
|
||||
}
|
||||
e = ent_get_next(e);
|
||||
|
||||
@@ -777,8 +777,12 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
lv_btnm_set_map(btnm, ext->map_p);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_PRESSED) {
|
||||
lv_indev_t * indev = lv_indev_get_act();
|
||||
if(lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER || lv_indev_get_type(indev) == LV_INDEV_TYPE_BUTTON) {
|
||||
invalidate_button_area(btnm, ext->btn_id_pr);
|
||||
invalidate_button_area(btnm, ext->btn_id_focused);
|
||||
|
||||
lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
|
||||
if(indev_type == LV_INDEV_TYPE_POINTER || indev_type == LV_INDEV_TYPE_BUTTON) {
|
||||
uint16_t btn_pr;
|
||||
/*Search the pressed area*/
|
||||
lv_indev_get_point(param, &p);
|
||||
@@ -787,8 +791,13 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
invalidate_button_area(btnm, ext->btn_id_pr) /*Invalidate the old area*/;
|
||||
ext->btn_id_pr = btn_pr;
|
||||
ext->btn_id_act = btn_pr;
|
||||
ext->btn_id_focused = btn_pr;
|
||||
invalidate_button_area(btnm, ext->btn_id_pr); /*Invalidate the new area*/
|
||||
} else if(indev_type == LV_INDEV_TYPE_KEYPAD || (indev_type == LV_INDEV_TYPE_ENCODER && lv_group_get_editing(lv_obj_get_group(btnm)))) {
|
||||
ext->btn_id_pr = ext->btn_id_focused;
|
||||
invalidate_button_area(btnm, ext->btn_id_focused);
|
||||
}
|
||||
|
||||
if(ext->btn_id_act != LV_BTNM_BTN_NONE) {
|
||||
if(button_is_click_trig(ext->ctrl_bits[ext->btn_id_act]) == false &&
|
||||
button_is_inactive(ext->ctrl_bits[ext->btn_id_act]) == false &&
|
||||
@@ -807,6 +816,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
lv_indev_reset_long_press(param); /*Start the log press time again on the new button*/
|
||||
if(ext->btn_id_pr != LV_BTNM_BTN_NONE) {
|
||||
invalidate_button_area(btnm, ext->btn_id_pr);
|
||||
invalidate_button_area(btnm, ext->btn_id_focused);
|
||||
}
|
||||
if(btn_pr != LV_BTNM_BTN_NONE) {
|
||||
uint32_t b = ext->btn_id_act;
|
||||
@@ -818,12 +828,13 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
}
|
||||
|
||||
ext->btn_id_pr = btn_pr;
|
||||
ext->btn_id_focused = btn_pr;
|
||||
ext->btn_id_act = btn_pr;
|
||||
} else if(sign == LV_SIGNAL_RELEASED) {
|
||||
if(ext->btn_id_pr != LV_BTNM_BTN_NONE) {
|
||||
/*Toggle the button if enabled*/
|
||||
if(button_is_tgl_enabled(ext->ctrl_bits[ext->btn_id_pr]) &&
|
||||
!button_is_inactive(ext->ctrl_bits[ext->btn_id_pr])) {
|
||||
!button_is_inactive(ext->ctrl_bits[ext->btn_id_pr])) {
|
||||
if(button_get_tgl_state(ext->ctrl_bits[ext->btn_id_pr])) {
|
||||
ext->ctrl_bits[ext->btn_id_pr] &= (~LV_BTNM_CTRL_CHECHK_STATE);
|
||||
} else {
|
||||
@@ -834,7 +845,6 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
|
||||
/*Invalidate to old pressed area*/;
|
||||
invalidate_button_area(btnm, ext->btn_id_pr);
|
||||
ext->btn_id_focused = ext->btn_id_pr;
|
||||
ext->btn_id_pr = LV_BTNM_BTN_NONE;
|
||||
|
||||
if(button_is_click_trig(ext->ctrl_bits[ext->btn_id_act]) == true &&
|
||||
@@ -870,17 +880,17 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER) {
|
||||
/*In navigation mode don't select any button but in edit mode select the fist*/
|
||||
if(lv_group_get_editing(lv_obj_get_group(btnm)))
|
||||
if(lv_group_get_editing(lv_obj_get_group(btnm))) {
|
||||
ext->btn_id_focused = 0;
|
||||
else
|
||||
} else {
|
||||
ext->btn_id_focused = LV_BTNM_BTN_NONE;
|
||||
}
|
||||
} else if (indev_type == LV_INDEV_TYPE_KEYPAD) {
|
||||
ext->btn_id_focused = 0;
|
||||
}
|
||||
#else
|
||||
ext->btn_id_focused = 0;
|
||||
#endif
|
||||
|
||||
ext->btn_id_act = ext->btn_id_focused;
|
||||
lv_obj_invalidate(btnm);
|
||||
#endif
|
||||
}
|
||||
else if(sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_LEAVE) {
|
||||
if(ext->btn_id_focused != LV_BTNM_BTN_NONE) invalidate_button_area(btnm, ext->btn_id_focused);
|
||||
|
||||
@@ -396,6 +396,7 @@ static lv_design_res_t lv_calendar_design(lv_obj_t * calendar, const lv_area_t *
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DESIGN_DRAW_POST) {
|
||||
ancestor_design(calendar, clip_area, mode);
|
||||
}
|
||||
|
||||
return LV_DESIGN_RES_OK;
|
||||
|
||||
@@ -91,6 +91,9 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_gauge);
|
||||
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_gauge);
|
||||
|
||||
lv_style_list_init(&ext->style_strong);
|
||||
lv_style_list_init(&ext->style_needle);
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_cb(new_gauge, lv_gauge_signal);
|
||||
lv_obj_set_design_cb(new_gauge, lv_gauge_design);
|
||||
@@ -102,10 +105,7 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_gauge_set_critical_value(new_gauge, 80);
|
||||
lv_obj_set_size(new_gauge, 2 * LV_DPI, 2 * LV_DPI);
|
||||
|
||||
lv_style_list_reset(&new_gauge->style_list);
|
||||
lv_style_list_init(&ext->style_strong);
|
||||
_ot(new_gauge, LV_GAUGE_PART_MAIN, GAUGE);
|
||||
_ot(new_gauge, LV_GAUGE_PART_STRONG, GAUGE_STRONG);
|
||||
lv_theme_apply(new_gauge, LV_THEME_GAUGE);
|
||||
|
||||
}
|
||||
/*Copy an existing gauge*/
|
||||
@@ -350,13 +350,16 @@ static lv_design_res_t lv_gauge_design(lv_obj_t * gauge, const lv_area_t * clip_
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
lv_draw_rect_dsc_t bg_dsc;
|
||||
lv_draw_rect_dsc_init(&bg_dsc);
|
||||
lv_obj_init_draw_rect_dsc(gauge, LV_GAUGE_PART_MAIN, &bg_dsc);
|
||||
lv_draw_rect(&gauge->coords, clip_area, &bg_dsc);
|
||||
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
lv_gauge_draw_labels(gauge, clip_area);
|
||||
|
||||
/*Draw the ancestor line meter with max value to show the rainbow like line colors*/
|
||||
uint16_t line_cnt_tmp = ext->lmeter.line_cnt;
|
||||
ancestor_design(gauge, clip_area, mode); /*To draw lines*/
|
||||
|
||||
|
||||
lv_lmeter_draw_scale(gauge, clip_area, LV_GAUGE_PART_MAIN);
|
||||
|
||||
@@ -424,6 +427,9 @@ static lv_style_list_t * lv_gauge_get_style(lv_obj_t * gauge, uint8_t part)
|
||||
case LV_GAUGE_PART_STRONG:
|
||||
style_dsc_p = &ext->style_strong;
|
||||
break;
|
||||
case LV_GAUGE_PART_NEEDLE:
|
||||
style_dsc_p = &ext->style_needle;
|
||||
break;
|
||||
default:
|
||||
style_dsc_p = NULL;
|
||||
}
|
||||
@@ -441,10 +447,13 @@ static void lv_gauge_draw_labels(lv_obj_t * gauge, const lv_area_t * mask)
|
||||
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
lv_style_int_t scale_width = lv_obj_get_style_scale_width(gauge, LV_GAUGE_PART_STRONG);
|
||||
lv_style_int_t txt_pad = lv_obj_get_style_pad_inner(gauge, LV_GAUGE_PART_STRONG);
|
||||
lv_coord_t r = lv_obj_get_width(gauge) / 2 - scale_width - txt_pad;
|
||||
lv_coord_t x_ofs = lv_obj_get_width(gauge) / 2 + gauge->coords.x1;
|
||||
lv_coord_t y_ofs = lv_obj_get_height(gauge) / 2 + gauge->coords.y1;
|
||||
lv_style_int_t left = lv_obj_get_style_pad_left(gauge, LV_GAUGE_PART_MAIN);
|
||||
lv_style_int_t right = lv_obj_get_style_pad_right(gauge, LV_GAUGE_PART_MAIN);
|
||||
lv_style_int_t top = lv_obj_get_style_pad_top(gauge, LV_GAUGE_PART_MAIN);
|
||||
lv_style_int_t txt_pad = lv_obj_get_style_pad_inner(gauge, LV_GAUGE_PART_MAIN);
|
||||
lv_coord_t r = (lv_obj_get_width(gauge) - left - right) / 2 - scale_width - txt_pad;
|
||||
lv_coord_t x_ofs = gauge->coords.x1 + r + left + scale_width + txt_pad;
|
||||
lv_coord_t y_ofs = gauge->coords.y1 + r + top + scale_width + txt_pad;
|
||||
int16_t scale_angle = lv_lmeter_get_scale_angle(gauge);
|
||||
uint16_t label_num = ext->label_count;
|
||||
int16_t angle_ofs = 90 + (360 - scale_angle) / 2;
|
||||
@@ -493,10 +502,14 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * clip_area)
|
||||
{
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
|
||||
lv_style_int_t scale_width = lv_obj_get_style_scale_width(gauge, LV_GAUGE_PART_STRONG);
|
||||
lv_coord_t r = lv_obj_get_width(gauge) / 2 - scale_width;
|
||||
lv_coord_t x_ofs = lv_obj_get_width(gauge) / 2 + gauge->coords.x1;
|
||||
lv_coord_t y_ofs = lv_obj_get_height(gauge) / 2 + gauge->coords.y1;
|
||||
lv_style_int_t pad = lv_obj_get_style_pad_inner(gauge, LV_GAUGE_PART_NEEDLE);
|
||||
lv_style_int_t left = lv_obj_get_style_pad_left(gauge, LV_GAUGE_PART_MAIN);
|
||||
lv_style_int_t right = lv_obj_get_style_pad_right(gauge, LV_GAUGE_PART_MAIN);
|
||||
lv_style_int_t top = lv_obj_get_style_pad_top(gauge, LV_GAUGE_PART_MAIN);
|
||||
|
||||
lv_coord_t r = (lv_obj_get_width(gauge) - left - right) / 2 - pad;
|
||||
lv_coord_t x_ofs = gauge->coords.x1 + r + left + pad;
|
||||
lv_coord_t y_ofs = gauge->coords.y1 + r + top + pad;
|
||||
uint16_t angle = lv_lmeter_get_scale_angle(gauge);
|
||||
int16_t angle_ofs = 90 + (360 - angle) / 2;
|
||||
int16_t min = lv_gauge_get_min_value(gauge);
|
||||
@@ -507,7 +520,7 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * clip_area)
|
||||
|
||||
lv_draw_line_dsc_t line_dsc;
|
||||
lv_draw_line_dsc_init(&line_dsc);
|
||||
lv_obj_init_draw_line_dsc(gauge, LV_GAUGE_PART_MAIN, &line_dsc);
|
||||
lv_obj_init_draw_line_dsc(gauge, LV_GAUGE_PART_NEEDLE, &line_dsc);
|
||||
|
||||
lv_draw_img_dsc_t img_dsc;
|
||||
if(ext->needle_img == NULL) {
|
||||
@@ -558,8 +571,8 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * clip_area)
|
||||
|
||||
lv_draw_rect_dsc_t mid_dsc;
|
||||
lv_draw_rect_dsc_init(&mid_dsc);
|
||||
lv_obj_init_draw_rect_dsc(gauge, LV_GAUGE_PART_MAIN, &mid_dsc);
|
||||
lv_style_int_t size = lv_obj_get_style_size(gauge, LV_GAUGE_PART_MAIN) / 2;
|
||||
lv_obj_init_draw_rect_dsc(gauge, LV_GAUGE_PART_NEEDLE, &mid_dsc);
|
||||
lv_style_int_t size = lv_obj_get_style_size(gauge, LV_GAUGE_PART_NEEDLE) / 2;
|
||||
lv_area_t nm_cord;
|
||||
nm_cord.x1 = x_ofs - size;
|
||||
nm_cord.y1 = y_ofs - size;
|
||||
|
||||
@@ -44,6 +44,7 @@ typedef struct
|
||||
const lv_color_t * needle_colors; /*Color of the needles (lv_color_t my_colors[needle_num])*/
|
||||
const void * needle_img;
|
||||
lv_point_t needle_img_pivot;
|
||||
lv_style_list_t style_needle;
|
||||
lv_style_list_t style_strong;
|
||||
uint8_t needle_count; /*Number of needles*/
|
||||
uint8_t label_count; /*Number of labels on the scale*/
|
||||
@@ -51,8 +52,11 @@ typedef struct
|
||||
|
||||
/*Styles*/
|
||||
enum {
|
||||
LV_GAUGE_PART_MAIN,
|
||||
LV_GAUGE_PART_STRONG,
|
||||
LV_GAUGE_PART_MAIN = LV_LMETER_PART_MAIN,
|
||||
LV_GAUGE_PART_STRONG = _LV_LMETER_PART_VIRTUAL_LAST,
|
||||
LV_GAUGE_PART_NEEDLE,
|
||||
_LV_GAUGE_PART_VIRTUAL_LAST = _LV_LMETER_PART_VIRTUAL_LAST,
|
||||
_LV_GAUGE_PART_REAL_LAST = _LV_LMETER_PART_REAL_LAST,
|
||||
};
|
||||
typedef uint8_t lv_gauge_style_t;
|
||||
|
||||
|
||||
@@ -84,9 +84,7 @@ lv_obj_t * lv_lmeter_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
/*Init the new line meter line meter*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_size(new_lmeter, LV_DPI, LV_DPI);
|
||||
|
||||
lv_style_list_reset(lv_obj_get_style_list(new_lmeter, LV_LMETER_PART_MAIN));
|
||||
_ot(new_lmeter, LV_LMETER_PART_MAIN, LMETER);
|
||||
lv_theme_apply(new_lmeter, LV_THEME_LMETER);
|
||||
}
|
||||
/*Copy an existing line meter*/
|
||||
else {
|
||||
@@ -272,12 +270,16 @@ void lv_lmeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uint8_
|
||||
{
|
||||
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
|
||||
|
||||
lv_coord_t r_out = lv_obj_get_width(lmeter) / 2;
|
||||
lv_style_int_t left = lv_obj_get_style_pad_left(lmeter, LV_LMETER_PART_MAIN);
|
||||
lv_style_int_t right = lv_obj_get_style_pad_right(lmeter, LV_LMETER_PART_MAIN);
|
||||
lv_style_int_t top = lv_obj_get_style_pad_top(lmeter, LV_LMETER_PART_MAIN);
|
||||
|
||||
lv_coord_t r_out = (lv_obj_get_width(lmeter) - left - right) / 2 ;
|
||||
lv_coord_t r_in = r_out - lv_obj_get_style_scale_width(lmeter, part);
|
||||
if(r_in < 1) r_in = 1;
|
||||
|
||||
lv_coord_t x_ofs = lv_obj_get_width(lmeter) / 2 + lmeter->coords.x1;
|
||||
lv_coord_t y_ofs = lv_obj_get_height(lmeter) / 2 + lmeter->coords.y1;
|
||||
lv_coord_t x_ofs = lmeter->coords.x1 + r_out + left;
|
||||
lv_coord_t y_ofs = lmeter->coords.y1 + r_out + top;
|
||||
int16_t angle_ofs = ext->angle_ofs + 90 + (360 - ext->scale_angle) / 2;
|
||||
int16_t level =
|
||||
(int32_t)((int32_t)(ext->cur_value - ext->min_value) * ext->line_cnt) / (ext->max_value - ext->min_value);
|
||||
@@ -333,7 +335,6 @@ void lv_lmeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uint8_
|
||||
lv_style_int_t border_width = lv_obj_get_style_scale_border_width(lmeter, part);
|
||||
lv_style_int_t end_border_width = lv_obj_get_style_scale_end_border_width(lmeter, part);
|
||||
|
||||
|
||||
if(border_width || end_border_width)
|
||||
{
|
||||
int16_t end_angle = (level * ext->scale_angle) / (ext->line_cnt - 1) + angle_ofs - 1;
|
||||
@@ -383,6 +384,10 @@ static lv_design_res_t lv_lmeter_design(lv_obj_t * lmeter, const lv_area_t * cli
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
lv_draw_rect_dsc_t bg_dsc;
|
||||
lv_draw_rect_dsc_init(&bg_dsc);
|
||||
lv_obj_init_draw_rect_dsc(lmeter, LV_LMETER_PART_MAIN, &bg_dsc);
|
||||
lv_draw_rect(&lmeter->coords, clip_area, &bg_dsc);
|
||||
lv_lmeter_draw_scale(lmeter, clip_area, LV_LMETER_PART_MAIN);
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
|
||||
@@ -42,6 +42,8 @@ typedef struct
|
||||
/*Styles*/
|
||||
enum {
|
||||
LV_LMETER_PART_MAIN,
|
||||
_LV_LMETER_PART_VIRTUAL_LAST,
|
||||
_LV_LMETER_PART_REAL_LAST = _LV_OBJ_PART_REAL_LAST,
|
||||
};
|
||||
typedef uint8_t lv_lmeter_part_t;
|
||||
|
||||
|
||||
@@ -70,17 +70,17 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
LV_LOG_TRACE("mesasge box create started");
|
||||
|
||||
/*Create the ancestor message box*/
|
||||
lv_obj_t * new_mbox = lv_cont_create(par, copy);
|
||||
LV_ASSERT_MEM(new_mbox);
|
||||
if(new_mbox == NULL) return NULL;
|
||||
lv_obj_t * mbox = lv_cont_create(par, copy);
|
||||
LV_ASSERT_MEM(mbox);
|
||||
if(mbox == NULL) return NULL;
|
||||
|
||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_mbox);
|
||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(mbox);
|
||||
|
||||
/*Allocate the message box type specific extended data*/
|
||||
lv_mbox_ext_t * ext = lv_obj_allocate_ext_attr(new_mbox, sizeof(lv_mbox_ext_t));
|
||||
lv_mbox_ext_t * ext = lv_obj_allocate_ext_attr(mbox, sizeof(lv_mbox_ext_t));
|
||||
LV_ASSERT_MEM(ext);
|
||||
if(ext == NULL) {
|
||||
lv_obj_del(new_mbox);
|
||||
lv_obj_del(mbox);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -91,42 +91,41 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
#endif
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_cb(new_mbox, lv_mbox_signal);
|
||||
lv_obj_set_signal_cb(mbox, lv_mbox_signal);
|
||||
|
||||
/*Init the new message box message box*/
|
||||
if(copy == NULL) {
|
||||
ext->text = lv_label_create(new_mbox, NULL);
|
||||
ext->text = lv_label_create(mbox, NULL);
|
||||
lv_label_set_align(ext->text, LV_LABEL_ALIGN_CENTER);
|
||||
lv_label_set_long_mode(ext->text, LV_LABEL_LONG_BREAK);
|
||||
lv_label_set_text(ext->text, "Message");
|
||||
|
||||
lv_cont_set_layout(new_mbox, LV_LAYOUT_COL_M);
|
||||
lv_cont_set_fit2(new_mbox, LV_FIT_NONE, LV_FIT_TIGHT);
|
||||
lv_obj_set_width(new_mbox, LV_DPI * 2);
|
||||
lv_obj_align(new_mbox, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_set_event_cb(new_mbox, lv_mbox_default_event_cb);
|
||||
lv_cont_set_layout(mbox, LV_LAYOUT_COL_M);
|
||||
lv_cont_set_fit2(mbox, LV_FIT_NONE, LV_FIT_TIGHT);
|
||||
lv_obj_set_width(mbox, LV_DPI * 2);
|
||||
lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_set_event_cb(mbox, lv_mbox_default_event_cb);
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_style_list_reset(&new_mbox->style_list);
|
||||
lv_obj_add_theme(new_mbox, LV_MBOX_PART_BG, LV_THEME_MBOX_BG);
|
||||
lv_theme_alien_apply(mbox, LV_THEME_MBOX);
|
||||
|
||||
}
|
||||
/*Copy an existing message box*/
|
||||
else {
|
||||
lv_mbox_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
|
||||
ext->text = lv_label_create(new_mbox, copy_ext->text);
|
||||
ext->text = lv_label_create(mbox, copy_ext->text);
|
||||
|
||||
/*Copy the buttons and the label on them*/
|
||||
if(copy_ext->btnm) ext->btnm = lv_btnm_create(new_mbox, copy_ext->btnm);
|
||||
if(copy_ext->btnm) ext->btnm = lv_btnm_create(mbox, copy_ext->btnm);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(new_mbox);
|
||||
lv_obj_refresh_style(mbox);
|
||||
}
|
||||
|
||||
LV_LOG_INFO("mesasge box created");
|
||||
|
||||
return new_mbox;
|
||||
return mbox;
|
||||
}
|
||||
|
||||
/*======================
|
||||
@@ -150,12 +149,7 @@ void lv_mbox_add_btns(lv_obj_t * mbox, const char * btn_map[])
|
||||
if(ext->btnm == NULL) {
|
||||
ext->btnm = lv_btnm_create(mbox, NULL);
|
||||
|
||||
lv_style_list_reset(&ext->btnm->style_list);
|
||||
lv_obj_add_theme(ext->btnm, LV_BTNM_PART_BG, LV_THEME_MBOX_BTN_BG);
|
||||
|
||||
|
||||
lv_style_list_reset(lv_obj_get_style_list(ext->btnm, LV_BTNM_PART_BTN));
|
||||
lv_obj_add_theme(ext->btnm, LV_BTNM_PART_BTN, LV_THEME_MBOX_BTN);
|
||||
lv_theme_alien_apply(mbox, LV_MBOX_PART_BTN);
|
||||
}
|
||||
|
||||
lv_btnm_set_map(ext->btnm, btn_map);
|
||||
@@ -518,9 +512,7 @@ static void mbox_realign(lv_obj_t * mbox)
|
||||
const lv_font_t * font = lv_obj_get_style_font(mbox, LV_MBOX_PART_BTN);
|
||||
|
||||
lv_coord_t font_h = lv_font_get_line_height(font);
|
||||
lv_mem_test();
|
||||
lv_obj_set_size(ext->btnm, w, font_h + btn_top + btn_bottom + bg_top + bg_bottom);
|
||||
lv_mem_test();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -630,35 +630,17 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p
|
||||
lv_event_send(ext->btns, LV_EVENT_CLICKED, lv_event_get_data());
|
||||
}
|
||||
#endif
|
||||
} else if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_CONTROL) {
|
||||
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
|
||||
bool * editable = (bool *)param;
|
||||
*editable = true;
|
||||
}
|
||||
|
||||
if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_CONTROL || sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_RELEASED) {
|
||||
/* The button matrix is not in a group (the tab view is in it) but it should handle the
|
||||
* group signals. So propagate the related signals to the button matrix manually*/
|
||||
if(ext->btns) {
|
||||
ext->btns->signal_cb(ext->btns, sign, param);
|
||||
}
|
||||
|
||||
if(sign == LV_SIGNAL_FOCUS) {
|
||||
lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
/*If not focused by an input device assume the last input device*/
|
||||
if(indev_type == LV_INDEV_TYPE_NONE) {
|
||||
indev_type = lv_indev_get_type(lv_indev_get_next(NULL));
|
||||
}
|
||||
|
||||
/*With ENCODER select the first button only in edit mode*/
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER) {
|
||||
#if LV_USE_GROUP
|
||||
lv_group_t * g = lv_obj_get_group(tabview);
|
||||
if(lv_group_get_editing(g)) {
|
||||
lv_btnm_set_pressed(ext->btns, ext->tab_cur);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
lv_btnm_set_pressed(ext->btns, ext->tab_cur);
|
||||
}
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
|
||||
bool * editable = (bool *)param;
|
||||
*editable = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -78,7 +78,6 @@ typedef enum {
|
||||
LV_THEME_LMETER,
|
||||
|
||||
LV_THEME_GAUGE,
|
||||
LV_THEME_GAUGE_STRONG,
|
||||
|
||||
LV_THEME_TA,
|
||||
LV_THEME_TA_ONELINE,
|
||||
@@ -97,9 +96,8 @@ typedef enum {
|
||||
|
||||
LV_THEME_LED,
|
||||
|
||||
LV_THEME_MBOX_BG,
|
||||
LV_THEME_MBOX_BTN_BG,
|
||||
LV_THEME_MBOX_BTN,
|
||||
LV_THEME_MBOX,
|
||||
LV_THEME_MBOX_BTNS,
|
||||
|
||||
LV_THEME_TABLE,
|
||||
LV_THEME_TABLE_BG,
|
||||
@@ -146,8 +144,6 @@ lv_style_t * lv_theme_get_style_part(lv_theme_style_t name, uint8_t part);
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
#define _t(name) lv_theme_get_style(LV_THEME_ ## name)
|
||||
#define _ot(obj, part, name) lv_obj_add_style(obj, part, _t(name))
|
||||
|
||||
/**********************
|
||||
* POST INCLUDE
|
||||
|
||||
@@ -80,8 +80,7 @@ static lv_style_t lmeter;
|
||||
#endif
|
||||
|
||||
#if LV_USE_GAUGE
|
||||
static lv_style_t gauge;
|
||||
static lv_style_t gauge_strong;
|
||||
static lv_style_t gauge_main, gauge_strong, gauge_needle;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -131,48 +130,49 @@ static lv_style_t chart_series_bg, chart_series;
|
||||
static void basic_init(void)
|
||||
{
|
||||
lv_style_init(&scr);
|
||||
lv_style_set_opa(&scr, LV_STYLE_BG_OPA, LV_OPA_COVER);
|
||||
lv_style_set_color(&scr, LV_STYLE_BG_COLOR, COLOR_SCREEN);
|
||||
lv_style_set_color(&scr, LV_STYLE_TEXT_COLOR , lv_color_hex(0xb8b8b9));
|
||||
lv_style_set_bg_opa(&scr, LV_STYLE_STATE_NORMAL, LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&scr, LV_STYLE_STATE_NORMAL, COLOR_SCREEN);
|
||||
lv_style_set_text_color(&scr, LV_STYLE_STATE_NORMAL, lv_color_hex(0xb8b8b9));
|
||||
|
||||
lv_style_init(&panel);
|
||||
lv_style_set_int(&panel, LV_STYLE_RADIUS, LV_DPI / 25);
|
||||
lv_style_set_opa(&panel, LV_STYLE_BG_OPA, LV_OPA_COVER);
|
||||
lv_style_set_color(&panel, LV_STYLE_BG_COLOR, COLOR_CONTAINER);
|
||||
lv_style_set_radius(&panel, LV_STYLE_STATE_NORMAL, LV_DPI / 25);
|
||||
lv_style_set_bg_opa(&panel, LV_STYLE_STATE_NORMAL, LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&panel, LV_STYLE_STATE_NORMAL, COLOR_CONTAINER);
|
||||
// lv_style_set_color(&panel, LV_STYLE_BG_COLOR | LV_STYLE_STATE_FOCUS, LV_COLOR_RED);
|
||||
lv_style_set_color(&panel, LV_STYLE_BORDER_COLOR, lv_color_lighten(COLOR_CONTAINER, LV_OPA_10));
|
||||
lv_style_set_int(&panel, LV_STYLE_BORDER_WIDTH, LV_DPI / 50 > 0 ? LV_DPI / 50 : 1);
|
||||
lv_style_set_int(&panel, LV_STYLE_BORDER_SIDE , LV_BORDER_SIDE_TOP);
|
||||
lv_style_set_int(&panel, LV_STYLE_PAD_LEFT, LV_DPI / 5);
|
||||
lv_style_set_int(&panel, LV_STYLE_PAD_RIGHT, LV_DPI / 5);
|
||||
lv_style_set_int(&panel, LV_STYLE_PAD_TOP, LV_DPI / 5);
|
||||
lv_style_set_int(&panel, LV_STYLE_PAD_BOTTOM, LV_DPI / 5);
|
||||
lv_style_set_int(&panel, LV_STYLE_PAD_INNER, LV_DPI / 5);
|
||||
lv_style_set_color(&panel, LV_STYLE_TEXT_COLOR, lv_color_hex(0x979a9f));
|
||||
lv_style_set_ptr(&panel, LV_STYLE_FONT, &lv_font_roboto_16);
|
||||
lv_style_set_color(&panel, LV_STYLE_IMAGE_RECOLOR, lv_color_hex(0x979a9f));
|
||||
lv_style_set_color(&panel, LV_STYLE_LINE_COLOR, lv_color_hex(0x979a9f));
|
||||
lv_style_set_int(&panel, LV_STYLE_LINE_WIDTH, 1);
|
||||
lv_style_set_color(&panel, LV_STYLE_BORDER_COLOR | LV_STYLE_STATE_FOCUS, LV_COLOR_RED);
|
||||
lv_style_set_border_color(&panel, LV_STYLE_STATE_NORMAL, lv_color_lighten(COLOR_CONTAINER, LV_OPA_10));
|
||||
lv_style_set_border_width(&panel, LV_STYLE_STATE_NORMAL, LV_DPI / 50 > 0 ? LV_DPI / 50 : 1);
|
||||
lv_style_set_border_side(&panel, LV_STYLE_STATE_NORMAL , LV_BORDER_SIDE_TOP);
|
||||
lv_style_set_pad_left(&panel, LV_STYLE_STATE_NORMAL, LV_DPI / 5);
|
||||
lv_style_set_pad_right(&panel, LV_STYLE_STATE_NORMAL, LV_DPI / 5);
|
||||
lv_style_set_pad_top(&panel, LV_STYLE_STATE_NORMAL, LV_DPI / 5);
|
||||
lv_style_set_pad_bottom(&panel, LV_STYLE_STATE_NORMAL, LV_DPI / 5);
|
||||
lv_style_set_pad_inner(&panel, LV_STYLE_STATE_NORMAL, LV_DPI / 5);
|
||||
lv_style_set_text_color(&panel, LV_STYLE_STATE_NORMAL, lv_color_hex(0x979a9f));
|
||||
lv_style_set_font(&panel, LV_STYLE_STATE_NORMAL, &lv_font_roboto_16);
|
||||
lv_style_set_image_recolor(&panel, LV_STYLE_STATE_NORMAL, lv_color_hex(0x979a9f));
|
||||
lv_style_set_line_color(&panel, LV_STYLE_STATE_NORMAL, lv_color_hex(0x979a9f));
|
||||
lv_style_set_line_width(&panel, LV_STYLE_STATE_NORMAL, 1);
|
||||
lv_style_set_border_color(&panel, LV_STYLE_STATE_FOCUS, LV_COLOR_RED);
|
||||
lv_style_set_transition_time(&panel, LV_STYLE_STATE_NORMAL, 500);
|
||||
|
||||
lv_style_init(&btn);
|
||||
lv_style_set_int(&btn, LV_STYLE_RADIUS, LV_RADIUS_CIRCLE);
|
||||
lv_style_set_opa(&btn, LV_STYLE_BG_OPA, LV_OPA_COVER);
|
||||
lv_style_set_color(&btn, LV_STYLE_BG_COLOR, COLOR_ACCENT);
|
||||
lv_style_set_color(&btn, LV_STYLE_BG_COLOR | LV_STYLE_STATE_PRESSED, lv_color_darken(COLOR_ACCENT, LV_OPA_20));
|
||||
lv_style_set_color(&btn, LV_STYLE_BG_COLOR | LV_STYLE_STATE_DISABLED, COLOR_DISABLED);
|
||||
lv_style_set_color(&btn, LV_STYLE_TEXT_COLOR, lv_color_hex(0xffffff));
|
||||
lv_style_set_color(&btn, LV_STYLE_TEXT_COLOR| LV_STYLE_STATE_PRESSED, lv_color_darken(lv_color_hex(0xffffff), LV_OPA_20));
|
||||
lv_style_set_color(&btn, LV_STYLE_TEXT_COLOR| LV_STYLE_STATE_DISABLED, lv_color_hex(0x686b70));
|
||||
lv_style_set_color(&btn, LV_STYLE_IMAGE_RECOLOR, LV_COLOR_WHITE);
|
||||
lv_style_set_color(&btn, LV_STYLE_IMAGE_RECOLOR| LV_STYLE_STATE_PRESSED, lv_color_darken(lv_color_hex(0xffffff), LV_OPA_20));
|
||||
lv_style_set_int(&btn, LV_STYLE_PAD_LEFT, LV_DPI / 5);
|
||||
lv_style_set_int(&btn, LV_STYLE_PAD_RIGHT, LV_DPI / 5);
|
||||
lv_style_set_int(&btn, LV_STYLE_PAD_TOP, LV_DPI / 10);
|
||||
lv_style_set_int(&btn, LV_STYLE_PAD_BOTTOM, LV_DPI / 10);
|
||||
lv_style_set_int(&btn, LV_STYLE_PAD_INNER, LV_DPI / 10);
|
||||
lv_style_set_int(&btn, LV_STYLE_TRANSITION_TIME, 500);
|
||||
lv_style_set_color(&btn, LV_STYLE_BG_COLOR | LV_STYLE_STATE_FOCUS, lv_color_mix(LV_COLOR_RED, COLOR_ACCENT, LV_OPA_50));
|
||||
lv_style_set_radius(&btn, LV_STYLE_STATE_NORMAL, LV_RADIUS_CIRCLE);
|
||||
lv_style_set_bg_opa(&btn, LV_STYLE_STATE_NORMAL, LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&btn, LV_STYLE_STATE_NORMAL, COLOR_ACCENT);
|
||||
lv_style_set_bg_color(&btn, LV_STYLE_STATE_PRESSED, lv_color_darken(COLOR_ACCENT, LV_OPA_20));
|
||||
lv_style_set_bg_color(&btn, LV_STYLE_STATE_DISABLED, COLOR_DISABLED);
|
||||
lv_style_set_text_color(&btn, LV_STYLE_STATE_NORMAL, lv_color_hex(0xffffff));
|
||||
lv_style_set_text_color(&btn, LV_STYLE_STATE_PRESSED, lv_color_darken(lv_color_hex(0xffffff), LV_OPA_20));
|
||||
lv_style_set_text_color(&btn, LV_STYLE_STATE_DISABLED, lv_color_hex(0x686b70));
|
||||
lv_style_set_image_recolor(&btn, LV_STYLE_STATE_NORMAL, LV_COLOR_WHITE);
|
||||
lv_style_set_image_recolor(&btn, LV_STYLE_STATE_PRESSED, lv_color_darken(lv_color_hex(0xffffff), LV_OPA_20));
|
||||
lv_style_set_pad_left(&btn, LV_STYLE_STATE_NORMAL, LV_DPI / 5);
|
||||
lv_style_set_pad_right(&btn, LV_STYLE_STATE_NORMAL, LV_DPI / 5);
|
||||
lv_style_set_pad_top(&btn, LV_STYLE_STATE_NORMAL, LV_DPI / 10);
|
||||
lv_style_set_pad_bottom(&btn, LV_STYLE_STATE_NORMAL, LV_DPI / 10);
|
||||
lv_style_set_pad_inner(&btn, LV_STYLE_STATE_NORMAL, LV_DPI / 10);
|
||||
lv_style_set_transition_time(&btn, LV_STYLE_TRANSITION_TIME, 500);
|
||||
lv_style_set_bg_color(&btn, LV_STYLE_STATE_FOCUS, lv_color_mix(LV_COLOR_RED, COLOR_ACCENT, LV_OPA_50));
|
||||
}
|
||||
|
||||
static void cont_init(void)
|
||||
@@ -277,15 +277,20 @@ static void lmeter_init(void)
|
||||
static void gauge_init(void)
|
||||
{
|
||||
#if LV_USE_GAUGE != 0
|
||||
lv_style_init(&gauge);
|
||||
lv_style_set_color(&gauge, LV_STYLE_SCALE_COLOR, COLOR_DISABLED);
|
||||
lv_style_set_color(&gauge, LV_STYLE_SCALE_GRAD_COLOR, COLOR_DISABLED);
|
||||
lv_style_set_color(&gauge, LV_STYLE_SCALE_END_COLOR, COLOR_ACCENT);
|
||||
lv_style_set_int(&gauge, LV_STYLE_LINE_WIDTH, 2);
|
||||
lv_style_set_int(&gauge, LV_STYLE_SCALE_END_BORDER_WIDTH, 4);
|
||||
lv_style_set_opa(&gauge, LV_STYLE_BG_OPA, LV_OPA_COVER);
|
||||
lv_style_set_color(&gauge, LV_STYLE_BG_COLOR, LV_COLOR_LIME);
|
||||
lv_style_set_int(&gauge, LV_STYLE_SIZE, 4);
|
||||
lv_style_init(&gauge_main);
|
||||
lv_style_copy(&gauge_main, &panel);
|
||||
lv_style_set_radius(&gauge_main, LV_STYLE_STATE_NORMAL, LV_RADIUS_CIRCLE);
|
||||
lv_style_set_border_side(&gauge_main, LV_STYLE_STATE_NORMAL, LV_BORDER_SIDE_FULL);
|
||||
lv_style_set_scale_color(&gauge_main, LV_STYLE_STATE_NORMAL, COLOR_DISABLED);
|
||||
lv_style_set_scale_grad_color(&gauge_main, LV_STYLE_STATE_NORMAL, COLOR_DISABLED);
|
||||
lv_style_set_scale_end_color(&gauge_main, LV_STYLE_STATE_NORMAL, COLOR_ACCENT);
|
||||
lv_style_set_line_width(&gauge_main, LV_STYLE_STATE_NORMAL, 2);
|
||||
lv_style_set_scale_end_border_width(&gauge_main, LV_STYLE_STATE_NORMAL, 4);
|
||||
lv_style_set_bg_opa(&gauge_main, LV_STYLE_STATE_NORMAL, LV_OPA_COVER);
|
||||
lv_style_set_pad_left(&gauge_main, LV_STYLE_STATE_NORMAL, LV_DPI / 10);
|
||||
lv_style_set_pad_right(&gauge_main, LV_STYLE_STATE_NORMAL, LV_DPI / 10);
|
||||
lv_style_set_pad_top(&gauge_main, LV_STYLE_STATE_NORMAL, LV_DPI / 10);
|
||||
lv_style_set_pad_inner(&gauge_main, LV_STYLE_STATE_NORMAL, LV_DPI / 8);
|
||||
|
||||
|
||||
lv_style_init(&gauge_strong);
|
||||
@@ -295,6 +300,14 @@ static void gauge_init(void)
|
||||
lv_style_set_int(&gauge_strong, LV_STYLE_LINE_WIDTH, 4);
|
||||
lv_style_set_int(&gauge_strong, LV_STYLE_SCALE_WIDTH, LV_DPI/5);
|
||||
lv_style_set_int(&gauge_strong, LV_STYLE_PAD_INNER, LV_DPI/10);
|
||||
|
||||
lv_style_init(&gauge_needle);
|
||||
lv_style_set_color(&gauge_needle, LV_STYLE_LINE_COLOR, LV_COLOR_WHITE);
|
||||
lv_style_set_int(&gauge_needle, LV_STYLE_LINE_WIDTH, LV_DPI / 30);
|
||||
lv_style_set_bg_opa(&gauge_needle, LV_STYLE_STATE_NORMAL, LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&gauge_needle, LV_STYLE_STATE_NORMAL, LV_COLOR_WHITE);
|
||||
lv_style_set_size(&gauge_needle, LV_STYLE_STATE_NORMAL, 10);
|
||||
lv_style_set_pad_inner(&gauge_needle, LV_STYLE_STATE_NORMAL, LV_DPI / 5);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -428,6 +441,7 @@ static void btnm_init(void)
|
||||
lv_style_set_color(&btnm_btn, LV_STYLE_BG_COLOR | LV_STYLE_STATE_CHECKED | LV_STYLE_STATE_PRESSED, lv_color_darken(COLOR_ACCENT, LV_OPA_40));
|
||||
lv_style_set_color(&btnm_btn, LV_STYLE_TEXT_COLOR , LV_COLOR_WHITE);
|
||||
lv_style_set_color(&btnm_btn, LV_STYLE_TEXT_COLOR | LV_STYLE_STATE_DISABLED , LV_COLOR_GRAY);
|
||||
lv_style_set_color(&btnm_btn, LV_STYLE_TEXT_COLOR | LV_STYLE_STATE_FOCUS, LV_COLOR_RED);
|
||||
lv_style_set_opa(&btnm_btn, LV_STYLE_BG_OPA | LV_STYLE_STATE_CHECKED, LV_OPA_COVER);
|
||||
lv_style_set_opa(&btnm_btn, LV_STYLE_BG_OPA | LV_STYLE_STATE_PRESSED, LV_OPA_COVER);
|
||||
lv_style_set_opa(&btnm_btn, LV_STYLE_BG_OPA | LV_STYLE_STATE_DISABLED, LV_OPA_COVER);
|
||||
@@ -566,7 +580,7 @@ static void tabview_init(void)
|
||||
lv_style_set_opa(&tabview_btns, LV_STYLE_BG_OPA | LV_STYLE_STATE_PRESSED, LV_OPA_COVER);
|
||||
lv_style_set_color(&tabview_btns, LV_STYLE_BG_COLOR | LV_STYLE_STATE_PRESSED, lv_color_hex(0x444444));
|
||||
lv_style_set_color(&tabview_btns, LV_STYLE_TEXT_COLOR | LV_STYLE_STATE_CHECKED, COLOR_ACCENT);
|
||||
lv_style_set_color(&tabview_btns, LV_STYLE_TEXT_COLOR | LV_STYLE_STATE_FOCUS, LV_COLOR_GREEN);
|
||||
lv_style_set_color(&tabview_btns, LV_STYLE_TEXT_COLOR | LV_STYLE_STATE_FOCUS, LV_COLOR_RED);
|
||||
lv_style_set_int(&tabview_btns, LV_STYLE_PAD_TOP, LV_DPI / 5);
|
||||
lv_style_set_int(&tabview_btns, LV_STYLE_PAD_BOTTOM, LV_DPI / 5);
|
||||
|
||||
@@ -1050,6 +1064,21 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
lv_style_list_reset(list);
|
||||
lv_style_list_add_style(list, &calendar_daynames);
|
||||
break;
|
||||
#endif
|
||||
#if LV_USE_GAUGE
|
||||
case LV_THEME_GAUGE:
|
||||
list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAIN);
|
||||
lv_style_list_reset(list);
|
||||
lv_style_list_add_style(list, &gauge_main);
|
||||
|
||||
list = lv_obj_get_style_list(obj, LV_GAUGE_PART_STRONG);
|
||||
lv_style_list_reset(list);
|
||||
lv_style_list_add_style(list, &gauge_strong);
|
||||
|
||||
list = lv_obj_get_style_list(obj, LV_GAUGE_PART_NEEDLE);
|
||||
lv_style_list_reset(list);
|
||||
lv_style_list_add_style(list, &gauge_needle);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1066,28 +1095,10 @@ lv_style_t * lv_theme_alien_get_style(lv_theme_style_t name)
|
||||
case LV_THEME_LMETER:
|
||||
return &lmeter;
|
||||
#endif
|
||||
#if LV_USE_GAUGE
|
||||
case LV_THEME_GAUGE:
|
||||
return &gauge;
|
||||
case LV_THEME_GAUGE_STRONG:
|
||||
return &gauge_strong;
|
||||
#endif
|
||||
#if LV_USE_LIST
|
||||
case LV_THEME_LIST_BTN:
|
||||
return &btn;
|
||||
#endif
|
||||
|
||||
#if LV_USE_LED
|
||||
case LV_THEME_LED:
|
||||
return &btn;
|
||||
#endif
|
||||
#if LV_USE_MBOX
|
||||
case LV_THEME_MBOX_BG:
|
||||
return &panel;
|
||||
case LV_THEME_MBOX_BTN_BG:
|
||||
return NULL;
|
||||
case LV_THEME_MBOX_BTN:
|
||||
return &btn;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user