mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-24 16:37:18 +08:00
run astyle code formatter
This commit is contained in:
+6
-4
@@ -77,7 +77,8 @@ static inline void lv_bar_set_sym(lv_obj_t * bar, bool en)
|
||||
* @return true: symmetric is enabled; false: disable
|
||||
* @deprecated As of v7.0, you should use `lv_bar_get_type` instead.
|
||||
*/
|
||||
static inline bool lv_bar_get_sym(lv_obj_t * bar) {
|
||||
static inline bool lv_bar_get_sym(lv_obj_t * bar)
|
||||
{
|
||||
return lv_bar_get_type(bar) == LV_BAR_TYPE_SYM;
|
||||
}
|
||||
|
||||
@@ -94,7 +95,7 @@ static inline bool lv_bar_get_sym(lv_obj_t * bar) {
|
||||
*/
|
||||
static inline void lv_slider_set_sym(lv_obj_t * slider, bool en)
|
||||
{
|
||||
lv_bar_set_sym(slider, en);
|
||||
lv_bar_set_sym(slider, en);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,8 +104,9 @@ static inline void lv_slider_set_sym(lv_obj_t * slider, bool en)
|
||||
* @return true: symmetric is enabled; false: disable
|
||||
* @deprecated As of v7.0, you should use `lv_slider_get_type` instead.
|
||||
*/
|
||||
static inline bool lv_slider_get_sym(lv_obj_t * slider) {
|
||||
return lv_bar_get_sym(slider);
|
||||
static inline bool lv_slider_get_sym(lv_obj_t * slider)
|
||||
{
|
||||
return lv_bar_get_sym(slider);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
* DEFINES
|
||||
*********************/
|
||||
#ifndef LV_DEBUG_STR_MAX_LENGTH
|
||||
#define LV_DEBUG_STR_MAX_LENGTH (1024 * 8)
|
||||
#define LV_DEBUG_STR_MAX_LENGTH (1024 * 8)
|
||||
#endif
|
||||
|
||||
#ifndef LV_DEBUG_STR_MAX_REPEAT
|
||||
#define LV_DEBUG_STR_MAX_REPEAT 8
|
||||
#define LV_DEBUG_STR_MAX_REPEAT 8
|
||||
#endif
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
@@ -126,7 +126,8 @@ bool lv_debug_check_str(const void * str)
|
||||
if(s[i] != last_byte) {
|
||||
last_byte = s[i];
|
||||
rep = 1;
|
||||
} else if(s[i] > 0x7F){
|
||||
}
|
||||
else if(s[i] > 0x7F) {
|
||||
rep++;
|
||||
if(rep > LV_DEBUG_STR_MAX_REPEAT) {
|
||||
LV_LOG_WARN("lv_debug_check_str: a non-ASCII char has repeated more than LV_DEBUG_STR_MAX_REPEAT times)");
|
||||
@@ -184,7 +185,8 @@ void lv_debug_log_error(const char * msg, uint64_t value)
|
||||
|
||||
*bufp = '\0';
|
||||
LV_LOG_ERROR(buf);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
LV_LOG_ERROR(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,13 +50,13 @@ void lv_debug_log_error(const char * msg, uint64_t value);
|
||||
|
||||
#ifndef LV_DEBUG_ASSERT
|
||||
#define LV_DEBUG_ASSERT(expr, msg, value) \
|
||||
do { \
|
||||
if(!(expr)) { \
|
||||
LV_LOG_ERROR(__func__); \
|
||||
lv_debug_log_error(msg, (uint64_t)((uintptr_t)value)); \
|
||||
while(1); \
|
||||
} \
|
||||
} while(0)
|
||||
do { \
|
||||
if(!(expr)) { \
|
||||
LV_LOG_ERROR(__func__); \
|
||||
lv_debug_log_error(msg, (uint64_t)((uintptr_t)value)); \
|
||||
while(1); \
|
||||
} \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
/*----------------
|
||||
|
||||
+10
-13
@@ -14,7 +14,7 @@
|
||||
#include "../lv_misc/lv_gc.h"
|
||||
|
||||
#if defined(LV_GC_INCLUDE)
|
||||
#include LV_GC_INCLUDE
|
||||
#include LV_GC_INCLUDE
|
||||
#endif /* LV_ENABLE_GC */
|
||||
|
||||
/*********************
|
||||
@@ -93,8 +93,7 @@ void lv_group_del(lv_group_t * group)
|
||||
|
||||
/*Remove the objects from the group*/
|
||||
lv_obj_t ** obj;
|
||||
LV_LL_READ(group->obj_ll, obj)
|
||||
{
|
||||
LV_LL_READ(group->obj_ll, obj) {
|
||||
(*obj)->group_p = NULL;
|
||||
}
|
||||
|
||||
@@ -114,8 +113,7 @@ void lv_group_add_obj(lv_group_t * group, lv_obj_t * obj)
|
||||
|
||||
/*Do not add the object twice*/
|
||||
lv_obj_t ** obj_i;
|
||||
LV_LL_READ(group->obj_ll, obj_i)
|
||||
{
|
||||
LV_LL_READ(group->obj_ll, obj_i) {
|
||||
if((*obj_i) == obj) {
|
||||
LV_LOG_INFO("lv_group_add_obj: the object is already added to this group");
|
||||
return;
|
||||
@@ -175,8 +173,7 @@ void lv_group_remove_obj(lv_obj_t * obj)
|
||||
|
||||
/*Search the object and remove it from its group */
|
||||
lv_obj_t ** i;
|
||||
LV_LL_READ(g->obj_ll, i)
|
||||
{
|
||||
LV_LL_READ(g->obj_ll, i) {
|
||||
if(*i == obj) {
|
||||
lv_ll_remove(&g->obj_ll, i);
|
||||
lv_mem_free(i);
|
||||
@@ -201,8 +198,7 @@ void lv_group_remove_all_objs(lv_group_t * group)
|
||||
|
||||
/*Remove the objects from the group*/
|
||||
lv_obj_t ** obj;
|
||||
LV_LL_READ(group->obj_ll, obj)
|
||||
{
|
||||
LV_LL_READ(group->obj_ll, obj) {
|
||||
(*obj)->group_p = NULL;
|
||||
}
|
||||
|
||||
@@ -227,8 +223,7 @@ void lv_group_focus_obj(lv_obj_t * obj)
|
||||
lv_group_set_editing(g, false);
|
||||
|
||||
lv_obj_t ** i;
|
||||
LV_LL_READ(g->obj_ll, i)
|
||||
{
|
||||
LV_LL_READ(g->obj_ll, i) {
|
||||
if(*i == obj) {
|
||||
if(g->obj_focus != NULL) {
|
||||
(*g->obj_focus)->signal_cb(*g->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
|
||||
@@ -400,7 +395,8 @@ lv_style_t * lv_group_mod_style(lv_group_t * group, const lv_style_t * style)
|
||||
|
||||
if(group->editing) {
|
||||
if(group->style_mod_edit_cb) group->style_mod_edit_cb(group, &group->style_tmp);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if(group->style_mod_cb) group->style_mod_cb(group, &group->style_tmp);
|
||||
}
|
||||
return &group->style_tmp;
|
||||
@@ -532,7 +528,8 @@ static void focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *)
|
||||
obj_next = begin(&group->obj_ll);
|
||||
can_move = false;
|
||||
can_begin = false;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/*Currently focused object is the last/first in the group, keep it that way*/
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -51,8 +51,7 @@ typedef void (*lv_group_focus_cb_t)(struct _lv_group_t *);
|
||||
* Groups can be used to logically hold objects so that they can be individually focused.
|
||||
* They are NOT for laying out objects on a screen (try `lv_cont` for that).
|
||||
*/
|
||||
typedef struct _lv_group_t
|
||||
{
|
||||
typedef struct _lv_group_t {
|
||||
lv_ll_t obj_ll; /**< Linked list to store the objects in the group */
|
||||
lv_obj_t ** obj_focus; /**< The object in focus*/
|
||||
|
||||
|
||||
+84
-63
@@ -21,7 +21,7 @@
|
||||
*********************/
|
||||
|
||||
#if LV_INDEV_DEF_DRAG_THROW <= 0
|
||||
#warning "LV_INDEV_DRAG_THROW must be greater than 0"
|
||||
#warning "LV_INDEV_DRAG_THROW must be greater than 0"
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
@@ -101,17 +101,21 @@ void lv_indev_read_task(lv_task_t * task)
|
||||
/*Save the last activity time*/
|
||||
if(indev_act->proc.state == LV_INDEV_STATE_PR) {
|
||||
indev_act->driver.disp->last_activity_time = lv_tick_get();
|
||||
} else if(indev_act->driver.type == LV_INDEV_TYPE_ENCODER && data.enc_diff) {
|
||||
}
|
||||
else if(indev_act->driver.type == LV_INDEV_TYPE_ENCODER && data.enc_diff) {
|
||||
indev_act->driver.disp->last_activity_time = lv_tick_get();
|
||||
}
|
||||
|
||||
if(indev_act->driver.type == LV_INDEV_TYPE_POINTER) {
|
||||
indev_pointer_proc(indev_act, &data);
|
||||
} else if(indev_act->driver.type == LV_INDEV_TYPE_KEYPAD) {
|
||||
}
|
||||
else if(indev_act->driver.type == LV_INDEV_TYPE_KEYPAD) {
|
||||
indev_keypad_proc(indev_act, &data);
|
||||
} else if(indev_act->driver.type == LV_INDEV_TYPE_ENCODER) {
|
||||
}
|
||||
else if(indev_act->driver.type == LV_INDEV_TYPE_ENCODER) {
|
||||
indev_encoder_proc(indev_act, &data);
|
||||
} else if(indev_act->driver.type == LV_INDEV_TYPE_BUTTON) {
|
||||
}
|
||||
else if(indev_act->driver.type == LV_INDEV_TYPE_BUTTON) {
|
||||
indev_button_proc(indev_act, &data);
|
||||
}
|
||||
/*Handle reset query if it happened in during processing*/
|
||||
@@ -159,7 +163,8 @@ void lv_indev_reset(lv_indev_t * indev, lv_obj_t * obj)
|
||||
if(obj == NULL || indev->proc.types.pointer.last_pressed == obj) {
|
||||
indev->proc.types.pointer.last_pressed = NULL;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
lv_indev_t * i = lv_indev_get_next(NULL);
|
||||
while(i) {
|
||||
i->proc.reset_query = 1;
|
||||
@@ -245,7 +250,8 @@ void lv_indev_get_point(const lv_indev_t * indev, lv_point_t * point)
|
||||
if(indev->driver.type != LV_INDEV_TYPE_POINTER && indev->driver.type != LV_INDEV_TYPE_BUTTON) {
|
||||
point->x = -1;
|
||||
point->y = -1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
point->x = indev->proc.types.pointer.act_point.x;
|
||||
point->y = indev->proc.types.pointer.act_point.y;
|
||||
}
|
||||
@@ -304,7 +310,8 @@ void lv_indev_get_vect(const lv_indev_t * indev, lv_point_t * point)
|
||||
if(indev->driver.type != LV_INDEV_TYPE_POINTER && indev->driver.type != LV_INDEV_TYPE_BUTTON) {
|
||||
point->x = 0;
|
||||
point->y = 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
point->x = indev->proc.types.pointer.vect.x;
|
||||
point->y = indev->proc.types.pointer.vect.y;
|
||||
}
|
||||
@@ -396,7 +403,8 @@ static void indev_pointer_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
|
||||
if(i->proc.state == LV_INDEV_STATE_PR) {
|
||||
indev_proc_press(&i->proc);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
indev_proc_release(&i->proc);
|
||||
}
|
||||
|
||||
@@ -453,7 +461,8 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
if(indev_reset_check(&i->proc)) return;
|
||||
lv_event_send(indev_obj_act, LV_EVENT_PRESSED, NULL);
|
||||
if(indev_reset_check(&i->proc)) return;
|
||||
} else if(data->key == LV_KEY_ESC) {
|
||||
}
|
||||
else if(data->key == LV_KEY_ESC) {
|
||||
/*Send the ESC as a normal KEY*/
|
||||
lv_group_send_data(g, LV_KEY_ESC);
|
||||
|
||||
@@ -589,7 +598,8 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
int32_t s;
|
||||
if(data->enc_diff < 0) {
|
||||
for(s = 0; s < -data->enc_diff; s++) lv_group_send_data(g, LV_KEY_LEFT);
|
||||
} else if(data->enc_diff > 0) {
|
||||
}
|
||||
else if(data->enc_diff > 0) {
|
||||
for(s = 0; s < data->enc_diff; s++) lv_group_send_data(g, LV_KEY_RIGHT);
|
||||
}
|
||||
}
|
||||
@@ -598,7 +608,8 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
int32_t s;
|
||||
if(data->enc_diff < 0) {
|
||||
for(s = 0; s < -data->enc_diff; s++) lv_group_focus_prev(g);
|
||||
} else if(data->enc_diff > 0) {
|
||||
}
|
||||
else if(data->enc_diff > 0) {
|
||||
for(s = 0; s < data->enc_diff; s++) lv_group_focus_next(g);
|
||||
}
|
||||
}
|
||||
@@ -715,7 +726,8 @@ static void indev_button_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
if(i->proc.types.pointer.last_point.x == i->proc.types.pointer.act_point.x &&
|
||||
i->proc.types.pointer.last_point.y == i->proc.types.pointer.act_point.y && data->state == LV_INDEV_STATE_PR) {
|
||||
indev_proc_press(&i->proc);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/*If a new point comes always make a release*/
|
||||
indev_proc_release(&i->proc);
|
||||
}
|
||||
@@ -741,16 +753,20 @@ static void indev_proc_press(lv_indev_proc_t * proc)
|
||||
/*If there is no last object then search*/
|
||||
if(indev_obj_act == NULL) {
|
||||
indev_obj_act = lv_indev_search_obj(lv_disp_get_layer_sys(disp), &proc->types.pointer.act_point);
|
||||
if(indev_obj_act == NULL) indev_obj_act = lv_indev_search_obj(lv_disp_get_layer_top(disp), &proc->types.pointer.act_point);
|
||||
if(indev_obj_act == NULL) indev_obj_act = lv_indev_search_obj(lv_disp_get_scr_act(disp), &proc->types.pointer.act_point);
|
||||
if(indev_obj_act == NULL) indev_obj_act = lv_indev_search_obj(lv_disp_get_layer_top(disp),
|
||||
&proc->types.pointer.act_point);
|
||||
if(indev_obj_act == NULL) indev_obj_act = lv_indev_search_obj(lv_disp_get_scr_act(disp),
|
||||
&proc->types.pointer.act_point);
|
||||
new_obj_searched = true;
|
||||
}
|
||||
/*If there is last object but it is not dragged and not protected also search*/
|
||||
else if(proc->types.pointer.drag_in_prog == 0 &&
|
||||
lv_obj_is_protected(indev_obj_act, LV_PROTECT_PRESS_LOST) == false) {
|
||||
indev_obj_act = lv_indev_search_obj(lv_disp_get_layer_sys(disp), &proc->types.pointer.act_point);
|
||||
if(indev_obj_act == NULL) indev_obj_act = lv_indev_search_obj(lv_disp_get_layer_top(disp), &proc->types.pointer.act_point);
|
||||
if(indev_obj_act == NULL) indev_obj_act = lv_indev_search_obj(lv_disp_get_scr_act(disp), &proc->types.pointer.act_point);
|
||||
if(indev_obj_act == NULL) indev_obj_act = lv_indev_search_obj(lv_disp_get_layer_top(disp),
|
||||
&proc->types.pointer.act_point);
|
||||
if(indev_obj_act == NULL) indev_obj_act = lv_indev_search_obj(lv_disp_get_scr_act(disp),
|
||||
&proc->types.pointer.act_point);
|
||||
new_obj_searched = true;
|
||||
}
|
||||
/*If a dragable or a protected object was the last then keep it*/
|
||||
@@ -1009,7 +1025,7 @@ static void indev_proc_reset_query_handler(lv_indev_t * indev)
|
||||
* @param point pointer to a point for searhing the most top child
|
||||
* @return pointer to the found object or NULL if there was no suitable object
|
||||
*/
|
||||
lv_obj_t * lv_indev_search_obj(lv_obj_t * obj, lv_point_t *point)
|
||||
lv_obj_t * lv_indev_search_obj(lv_obj_t * obj, lv_point_t * point)
|
||||
{
|
||||
lv_obj_t * found_p = NULL;
|
||||
|
||||
@@ -1017,8 +1033,7 @@ lv_obj_t * lv_indev_search_obj(lv_obj_t * obj, lv_point_t *point)
|
||||
if(lv_obj_hittest(obj, point)) {
|
||||
lv_obj_t * i;
|
||||
|
||||
LV_LL_READ(obj->child_ll, i)
|
||||
{
|
||||
LV_LL_READ(obj->child_ll, i) {
|
||||
found_p = lv_indev_search_obj(i, point);
|
||||
|
||||
/*If a child was found then break*/
|
||||
@@ -1029,7 +1044,8 @@ lv_obj_t * lv_indev_search_obj(lv_obj_t * obj, lv_point_t *point)
|
||||
|
||||
/*If then the children was not ok, and this obj is clickable
|
||||
* and it or its parent is not hidden then save this object*/
|
||||
if(found_p == NULL && lv_obj_get_click(obj) != false && (lv_obj_get_state(obj, LV_OBJ_PART_MAIN) & LV_STATE_DISABLED) == 0) {
|
||||
if(found_p == NULL && lv_obj_get_click(obj) != false &&
|
||||
(lv_obj_get_state(obj, LV_OBJ_PART_MAIN) & LV_STATE_DISABLED) == 0) {
|
||||
lv_obj_t * hidden_i = obj;
|
||||
while(hidden_i != NULL) {
|
||||
if(lv_obj_get_hidden(hidden_i) == true) break;
|
||||
@@ -1051,7 +1067,7 @@ static void indev_click_focus(lv_indev_proc_t * proc)
|
||||
{
|
||||
/*Handle click focus*/
|
||||
if(lv_obj_is_protected(indev_obj_act, LV_PROTECT_CLICK_FOCUS) == false &&
|
||||
proc->types.pointer.last_pressed != indev_obj_act) {
|
||||
proc->types.pointer.last_pressed != indev_obj_act) {
|
||||
#if LV_USE_GROUP
|
||||
lv_group_t * g_act = lv_obj_get_group(indev_obj_act);
|
||||
lv_group_t * g_prev = proc->types.pointer.last_pressed ? lv_obj_get_group(proc->types.pointer.last_pressed) : NULL;
|
||||
@@ -1170,7 +1186,8 @@ static void indev_drag(lv_indev_proc_t * proc)
|
||||
if(allowed_dirs == LV_DRAG_DIR_ONE) {
|
||||
if(LV_MATH_ABS(proc->types.pointer.drag_sum.x) > LV_MATH_ABS(proc->types.pointer.drag_sum.y)) {
|
||||
hor_en = true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ver_en = true;
|
||||
}
|
||||
}
|
||||
@@ -1203,25 +1220,29 @@ static void indev_drag(lv_indev_proc_t * proc)
|
||||
act_x += proc->types.pointer.drag_sum.x;
|
||||
act_y += proc->types.pointer.drag_sum.y;
|
||||
}
|
||||
} else if(allowed_dirs == LV_DRAG_DIR_HOR) {
|
||||
}
|
||||
else if(allowed_dirs == LV_DRAG_DIR_HOR) {
|
||||
if(drag_just_started) {
|
||||
proc->types.pointer.drag_dir = LV_DRAG_DIR_HOR;
|
||||
proc->types.pointer.drag_sum.y = 0;
|
||||
act_x += proc->types.pointer.drag_sum.x;
|
||||
}
|
||||
} else if(allowed_dirs == LV_DRAG_DIR_VER) {
|
||||
}
|
||||
else if(allowed_dirs == LV_DRAG_DIR_VER) {
|
||||
if(drag_just_started) {
|
||||
proc->types.pointer.drag_dir = LV_DRAG_DIR_VER;
|
||||
proc->types.pointer.drag_sum.x = 0;
|
||||
act_y += proc->types.pointer.drag_sum.y;
|
||||
}
|
||||
} else if(allowed_dirs == LV_DRAG_DIR_ONE) {
|
||||
}
|
||||
else if(allowed_dirs == LV_DRAG_DIR_ONE) {
|
||||
if(drag_just_started) {
|
||||
if(LV_MATH_ABS(proc->types.pointer.drag_sum.x) > LV_MATH_ABS(proc->types.pointer.drag_sum.y)) {
|
||||
proc->types.pointer.drag_dir = LV_DRAG_DIR_HOR;
|
||||
proc->types.pointer.drag_sum.y = 0;
|
||||
act_x += proc->types.pointer.drag_sum.x;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
proc->types.pointer.drag_dir = LV_DRAG_DIR_VER;
|
||||
proc->types.pointer.drag_sum.x = 0;
|
||||
act_y += proc->types.pointer.drag_sum.y;
|
||||
@@ -1374,51 +1395,51 @@ static lv_obj_t * get_dragged_obj(lv_obj_t * obj)
|
||||
static void indev_gesture(lv_indev_proc_t * proc)
|
||||
{
|
||||
|
||||
if (proc->types.pointer.drag_in_prog) return;
|
||||
if (proc->types.pointer.gesture_sent) return;
|
||||
if(proc->types.pointer.drag_in_prog) return;
|
||||
if(proc->types.pointer.gesture_sent) return;
|
||||
|
||||
lv_obj_t * gesture_obj = proc->types.pointer.act_obj;
|
||||
lv_obj_t * gesture_obj = proc->types.pointer.act_obj;
|
||||
|
||||
/*If gesture parent is active check recursively the drag_parent attribute*/
|
||||
while (gesture_obj && lv_obj_get_gesture_parent(gesture_obj)) {
|
||||
gesture_obj = lv_obj_get_parent(gesture_obj);
|
||||
}
|
||||
/*If gesture parent is active check recursively the drag_parent attribute*/
|
||||
while(gesture_obj && lv_obj_get_gesture_parent(gesture_obj)) {
|
||||
gesture_obj = lv_obj_get_parent(gesture_obj);
|
||||
}
|
||||
|
||||
if (gesture_obj == NULL) return;
|
||||
if(gesture_obj == NULL) return;
|
||||
|
||||
if ((LV_MATH_ABS(proc->types.pointer.vect.x) < indev_act->driver.gesture_min_velocity) &&
|
||||
(LV_MATH_ABS(proc->types.pointer.vect.y) < indev_act->driver.gesture_min_velocity)) {
|
||||
proc->types.pointer.gesture_sum.x = 0;
|
||||
proc->types.pointer.gesture_sum.y = 0;
|
||||
}
|
||||
if((LV_MATH_ABS(proc->types.pointer.vect.x) < indev_act->driver.gesture_min_velocity) &&
|
||||
(LV_MATH_ABS(proc->types.pointer.vect.y) < indev_act->driver.gesture_min_velocity)) {
|
||||
proc->types.pointer.gesture_sum.x = 0;
|
||||
proc->types.pointer.gesture_sum.y = 0;
|
||||
}
|
||||
|
||||
/*Count the movement by gesture*/
|
||||
proc->types.pointer.gesture_sum.x += proc->types.pointer.vect.x;
|
||||
proc->types.pointer.gesture_sum.y += proc->types.pointer.vect.y;
|
||||
/*Count the movement by gesture*/
|
||||
proc->types.pointer.gesture_sum.x += proc->types.pointer.vect.x;
|
||||
proc->types.pointer.gesture_sum.y += proc->types.pointer.vect.y;
|
||||
|
||||
if ((LV_MATH_ABS(proc->types.pointer.gesture_sum.x) > indev_act->driver.gesture_limit) ||
|
||||
(LV_MATH_ABS(proc->types.pointer.gesture_sum.y) > indev_act->driver.gesture_limit)){
|
||||
if((LV_MATH_ABS(proc->types.pointer.gesture_sum.x) > indev_act->driver.gesture_limit) ||
|
||||
(LV_MATH_ABS(proc->types.pointer.gesture_sum.y) > indev_act->driver.gesture_limit)) {
|
||||
|
||||
proc->types.pointer.gesture_sent = 1;
|
||||
proc->types.pointer.gesture_sent = 1;
|
||||
|
||||
if (LV_MATH_ABS(proc->types.pointer.gesture_sum.x) > LV_MATH_ABS(proc->types.pointer.gesture_sum.y)){
|
||||
if (proc->types.pointer.gesture_sum.x > 0)
|
||||
proc->types.pointer.gesture_dir = LV_GESTURE_DIR_RIGHT;
|
||||
else
|
||||
proc->types.pointer.gesture_dir = LV_GESTURE_DIR_LEFT;
|
||||
}
|
||||
else{
|
||||
if (proc->types.pointer.gesture_sum.y > 0)
|
||||
proc->types.pointer.gesture_dir = LV_GESTURE_DIR_BOTTOM;
|
||||
else
|
||||
proc->types.pointer.gesture_dir = LV_GESTURE_DIR_TOP;
|
||||
}
|
||||
if(LV_MATH_ABS(proc->types.pointer.gesture_sum.x) > LV_MATH_ABS(proc->types.pointer.gesture_sum.y)) {
|
||||
if(proc->types.pointer.gesture_sum.x > 0)
|
||||
proc->types.pointer.gesture_dir = LV_GESTURE_DIR_RIGHT;
|
||||
else
|
||||
proc->types.pointer.gesture_dir = LV_GESTURE_DIR_LEFT;
|
||||
}
|
||||
else {
|
||||
if(proc->types.pointer.gesture_sum.y > 0)
|
||||
proc->types.pointer.gesture_dir = LV_GESTURE_DIR_BOTTOM;
|
||||
else
|
||||
proc->types.pointer.gesture_dir = LV_GESTURE_DIR_TOP;
|
||||
}
|
||||
|
||||
gesture_obj->signal_cb(gesture_obj, LV_SIGNAL_GESTURE, indev_act);
|
||||
if (indev_reset_check(proc)) return;
|
||||
lv_event_send(gesture_obj, LV_EVENT_GESTURE, NULL);
|
||||
if (indev_reset_check(proc)) return;
|
||||
}
|
||||
gesture_obj->signal_cb(gesture_obj, LV_SIGNAL_GESTURE, indev_act);
|
||||
if(indev_reset_check(proc)) return;
|
||||
lv_event_send(gesture_obj, LV_EVENT_GESTURE, NULL);
|
||||
if(indev_reset_check(proc)) return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ lv_obj_t * lv_indev_get_obj_act(void);
|
||||
* @param point pointer to a point for searhing the most top child
|
||||
* @return pointer to the found object or NULL if there was no suitable object
|
||||
*/
|
||||
lv_obj_t * lv_indev_search_obj(lv_obj_t * obj, lv_point_t *point);
|
||||
lv_obj_t * lv_indev_search_obj(lv_obj_t * obj, lv_point_t * point);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
||||
+141
-123
File diff suppressed because it is too large
Load Diff
+26
-32
@@ -89,16 +89,16 @@ enum {
|
||||
LV_EVENT_LONG_PRESSED_REPEAT, /**< Called after `LV_INDEV_LONG_PRESS_TIME` in every
|
||||
`LV_INDEV_LONG_PRESS_REP_TIME` ms. Not called if dragged.*/
|
||||
LV_EVENT_CLICKED, /**< Called on release if not dragged (regardless to long press)*/
|
||||
LV_EVENT_RELEASED, /**< Called in every cases when the object has been released*/
|
||||
LV_EVENT_DRAG_BEGIN,
|
||||
LV_EVENT_RELEASED, /**< Called in every cases when the object has been released*/
|
||||
LV_EVENT_DRAG_BEGIN,
|
||||
LV_EVENT_DRAG_END,
|
||||
LV_EVENT_DRAG_THROW_BEGIN,
|
||||
LV_EVENT_GESTURE, /**< The object has been getture*/
|
||||
LV_EVENT_GESTURE, /**< The object has been getture*/
|
||||
LV_EVENT_KEY,
|
||||
LV_EVENT_FOCUSED,
|
||||
LV_EVENT_DEFOCUSED,
|
||||
LV_EVENT_LEAVE,
|
||||
LV_EVENT_VALUE_CHANGED, /**< The object's value has changed (i.e. slider moved) */
|
||||
LV_EVENT_VALUE_CHANGED, /**< The object's value has changed (i.e. slider moved) */
|
||||
LV_EVENT_INSERT,
|
||||
LV_EVENT_REFRESH,
|
||||
LV_EVENT_APPLY, /**< "Ok", "Apply" or similar specific button has clicked*/
|
||||
@@ -138,10 +138,10 @@ enum {
|
||||
LV_SIGNAL_RELEASED, /**< User pressed object for a short period of time, then released it. Not called if dragged. */
|
||||
LV_SIGNAL_LONG_PRESS, /**< Object has been pressed for at least `LV_INDEV_LONG_PRESS_TIME`. Not called if dragged.*/
|
||||
LV_SIGNAL_LONG_PRESS_REP, /**< Called after `LV_INDEV_LONG_PRESS_TIME` in every `LV_INDEV_LONG_PRESS_REP_TIME` ms. Not called if dragged.*/
|
||||
LV_SIGNAL_DRAG_BEGIN,
|
||||
LV_SIGNAL_DRAG_BEGIN,
|
||||
LV_SIGNAL_DRAG_THROW_BEGIN,
|
||||
LV_SIGNAL_DRAG_END,
|
||||
LV_SIGNAL_GESTURE, /**< The object has been gesture*/
|
||||
LV_SIGNAL_DRAG_END,
|
||||
LV_SIGNAL_GESTURE, /**< The object has been gesture*/
|
||||
LV_SIGNAL_LEAVE, /**< Another object is clicked or chosen via an input device */
|
||||
|
||||
/*Group related*/
|
||||
@@ -155,8 +155,7 @@ typedef uint8_t lv_signal_t;
|
||||
typedef lv_res_t (*lv_signal_cb_t)(struct _lv_obj_t * obj, lv_signal_t sign, void * param);
|
||||
|
||||
#if LV_USE_OBJ_REALIGN
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
const struct _lv_obj_t * base;
|
||||
lv_coord_t xofs;
|
||||
lv_coord_t yofs;
|
||||
@@ -193,8 +192,7 @@ enum {
|
||||
|
||||
typedef uint8_t lv_state_t;
|
||||
|
||||
typedef struct _lv_obj_t
|
||||
{
|
||||
typedef struct _lv_obj_t {
|
||||
struct _lv_obj_t * parent; /**< Pointer to the parent object*/
|
||||
lv_ll_t child_ll; /**< Linked list to store the children objects*/
|
||||
|
||||
@@ -217,18 +215,18 @@ typedef struct _lv_obj_t
|
||||
lv_coord_t ext_draw_pad; /**< EXTtend the size in every direction for drawing. */
|
||||
|
||||
/*Attributes and states*/
|
||||
uint8_t click :1; /**< 1: Can be pressed by an input device*/
|
||||
uint8_t drag :1; /**< 1: Enable the dragging*/
|
||||
uint8_t drag_throw :1; /**< 1: Enable throwing with drag*/
|
||||
uint8_t drag_parent :1; /**< 1: Parent will be dragged instead*/
|
||||
uint8_t hidden :1; /**< 1: Object is hidden*/
|
||||
uint8_t top :1; /**< 1: If the object or its children is clicked it goes to the foreground*/
|
||||
uint8_t parent_event :1; /**< 1: Send the object's events to the parent too. */
|
||||
uint8_t adv_hittest :1; /**< 1: Use advanced hit-testing (slower) */
|
||||
uint8_t click : 1; /**< 1: Can be pressed by an input device*/
|
||||
uint8_t drag : 1; /**< 1: Enable the dragging*/
|
||||
uint8_t drag_throw : 1; /**< 1: Enable throwing with drag*/
|
||||
uint8_t drag_parent : 1; /**< 1: Parent will be dragged instead*/
|
||||
uint8_t hidden : 1; /**< 1: Object is hidden*/
|
||||
uint8_t top : 1; /**< 1: If the object or its children is clicked it goes to the foreground*/
|
||||
uint8_t parent_event : 1; /**< 1: Send the object's events to the parent too. */
|
||||
uint8_t adv_hittest : 1; /**< 1: Use advanced hit-testing (slower) */
|
||||
uint8_t gesture_parent : 1; /**< 1: Parent will be gesture instead*/
|
||||
|
||||
lv_drag_dir_t drag_dir :3; /**< Which directions the object can be dragged in */
|
||||
lv_bidi_dir_t base_dir :2; /**< Base direction of texts related to this object */
|
||||
lv_drag_dir_t drag_dir : 3; /**< Which directions the object can be dragged in */
|
||||
lv_bidi_dir_t base_dir : 2; /**< Base direction of texts related to this object */
|
||||
|
||||
#if LV_USE_GROUP != 0
|
||||
void * group_p;
|
||||
@@ -258,26 +256,22 @@ enum {
|
||||
typedef uint8_t lv_obj_part_t;
|
||||
|
||||
/** Used by `lv_obj_get_type()`. The object's and its ancestor types are stored here*/
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
const char * type[LV_MAX_ANCESTOR_NUM]; /**< [0]: the actual type, [1]: ancestor, [2] #1's ancestor
|
||||
... [x]: "lv_obj" */
|
||||
} lv_obj_type_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
lv_point_t *point;
|
||||
typedef struct {
|
||||
lv_point_t * point;
|
||||
bool result;
|
||||
} lv_hit_test_info_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
uint8_t part;
|
||||
lv_style_list_t * result;
|
||||
} lv_get_style_info_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
uint8_t part;
|
||||
lv_state_t result;
|
||||
} lv_get_state_info_t;
|
||||
@@ -334,7 +328,7 @@ void lv_obj_del_anim_ready_cb(lv_anim_t * a);
|
||||
* @param obj object to delete
|
||||
* @see lv_async_call
|
||||
*/
|
||||
void lv_obj_del_async(struct _lv_obj_t *obj);
|
||||
void lv_obj_del_async(struct _lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Delete all children of an object
|
||||
@@ -1190,7 +1184,7 @@ lv_event_cb_t lv_obj_get_event_cb(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Check if a given screen-space point is on an object's coordinates.
|
||||
*
|
||||
*
|
||||
* This method is intended to be used mainly by advanced hit testing algorithms to check
|
||||
* whether the point is even within the object (as an optimization).
|
||||
* @param obj object to check
|
||||
|
||||
@@ -60,41 +60,41 @@ extern "C" {
|
||||
|
||||
|
||||
#define _LV_OBJ_STYLE_DECLARE_GET_scalar(prop_name, func_name, value_type, style_type) \
|
||||
static inline value_type lv_obj_get_style_##func_name (const lv_obj_t * obj, uint8_t part) \
|
||||
{ \
|
||||
return (value_type) _lv_obj_get_style##style_type (obj, part, LV_STYLE_##prop_name); \
|
||||
}
|
||||
static inline value_type lv_obj_get_style_##func_name (const lv_obj_t * obj, uint8_t part) \
|
||||
{ \
|
||||
return (value_type) _lv_obj_get_style##style_type (obj, part, LV_STYLE_##prop_name); \
|
||||
}
|
||||
|
||||
#define _LV_OBJ_STYLE_DECLARE_GET_nonscalar(prop_name, func_name, value_type, style_type) \
|
||||
static inline value_type lv_obj_get_style_##func_name (const lv_obj_t * obj, uint8_t part) \
|
||||
{ \
|
||||
return _lv_obj_get_style##style_type (obj, part, LV_STYLE_##prop_name); \
|
||||
}
|
||||
static inline value_type lv_obj_get_style_##func_name (const lv_obj_t * obj, uint8_t part) \
|
||||
{ \
|
||||
return _lv_obj_get_style##style_type (obj, part, LV_STYLE_##prop_name); \
|
||||
}
|
||||
|
||||
#define _LV_OBJ_STYLE_SET_GET_DECLARE(prop_name, func_name, value_type, style_type, scalar) \
|
||||
_LV_OBJ_STYLE_DECLARE_GET_##scalar(prop_name, func_name, value_type, style_type) \
|
||||
static inline void lv_obj_set_style_local_##func_name (lv_obj_t * obj, uint8_t part, lv_state_t state, value_type value) \
|
||||
{ \
|
||||
_lv_obj_set_style_local##style_type (obj, part, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \
|
||||
} \
|
||||
static inline void lv_obj_get_style_local_##func_name (lv_obj_t * obj, uint8_t part, lv_state_t state, void * res) \
|
||||
{ \
|
||||
_lv_style_get##style_type (lv_obj_get_local_style(obj, part), LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), res); \
|
||||
} \
|
||||
static inline void lv_obj_remove_style_local_##func_name (lv_obj_t * obj, uint8_t part, lv_state_t state) \
|
||||
{ \
|
||||
_lv_obj_remove_style_local_prop(obj, part, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS)); \
|
||||
} \
|
||||
static inline int16_t lv_style_get_##func_name (lv_style_t * style, lv_state_t state, void * res) \
|
||||
{ \
|
||||
return _lv_style_get##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), res); \
|
||||
} \
|
||||
static inline void lv_style_set_##func_name (lv_style_t * style, lv_state_t state, value_type value) \
|
||||
{ \
|
||||
_lv_style_set##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \
|
||||
}
|
||||
_LV_OBJ_STYLE_DECLARE_GET_##scalar(prop_name, func_name, value_type, style_type) \
|
||||
static inline void lv_obj_set_style_local_##func_name (lv_obj_t * obj, uint8_t part, lv_state_t state, value_type value) \
|
||||
{ \
|
||||
_lv_obj_set_style_local##style_type (obj, part, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \
|
||||
} \
|
||||
static inline void lv_obj_get_style_local_##func_name (lv_obj_t * obj, uint8_t part, lv_state_t state, void * res) \
|
||||
{ \
|
||||
_lv_style_get##style_type (lv_obj_get_local_style(obj, part), LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), res); \
|
||||
} \
|
||||
static inline void lv_obj_remove_style_local_##func_name (lv_obj_t * obj, uint8_t part, lv_state_t state) \
|
||||
{ \
|
||||
_lv_obj_remove_style_local_prop(obj, part, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS)); \
|
||||
} \
|
||||
static inline int16_t lv_style_get_##func_name (lv_style_t * style, lv_state_t state, void * res) \
|
||||
{ \
|
||||
return _lv_style_get##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), res); \
|
||||
} \
|
||||
static inline void lv_style_set_##func_name (lv_style_t * style, lv_state_t state, value_type value) \
|
||||
{ \
|
||||
_lv_style_set##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \
|
||||
}
|
||||
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(RADIUS, radius, lv_style_int_t,_int, scalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(RADIUS, radius, lv_style_int_t, _int, scalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(CLIP_CORNER, clip_corner, bool, _int, scalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(SIZE, size, lv_style_int_t, _int, scalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSFORM_WIDTH, transform_width, lv_style_int_t, _int, scalar)
|
||||
@@ -111,7 +111,7 @@ _LV_OBJ_STYLE_SET_GET_DECLARE(BG_GRAD_STOP, bg_grad_stop, lv_style_int_t, _int,
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(BG_GRAD_DIR, bg_grad_dir, lv_grad_dir_t, _int, scalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(BG_COLOR, bg_color, lv_color_t, _color, nonscalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(BG_GRAD_COLOR, bg_grad_color, lv_color_t, _color, nonscalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(BG_OPA, bg_opa, lv_opa_t , _opa, scalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(BG_OPA, bg_opa, lv_opa_t, _opa, scalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(BORDER_WIDTH, border_width, lv_style_int_t, _int, scalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(BORDER_SIDE, border_side, lv_border_side_t, _int, scalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(BORDER_BLEND_MODE, border_blend_mode, lv_blend_mode_t, _int, scalar)
|
||||
@@ -144,8 +144,8 @@ _LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_OFS_Y, value_ofs_y, lv_style_int_t, _int, sc
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_ALIGN, value_align, lv_align_t, _int, scalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_COLOR, value_color, lv_color_t, _color, nonscalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_OPA, value_opa, lv_opa_t, _opa, scalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_FONT, value_font, const lv_font_t * , _ptr, scalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_STR, value_str, const char * , _ptr, scalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_FONT, value_font, const lv_font_t *, _ptr, scalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_STR, value_str, const char *, _ptr, scalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_LETTER_SPACE, text_letter_space, lv_style_int_t, _int, scalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_LINE_SPACE, text_line_space, lv_style_int_t, _int, scalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_DECOR, text_decor, lv_text_decor_t, _int, scalar)
|
||||
@@ -153,7 +153,7 @@ _LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_BLEND_MODE, text_blend_mode, lv_blend_mode_t,
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_COLOR, text_color, lv_color_t, _color, nonscalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_SEL_COLOR, text_sel_color, lv_color_t, _color, nonscalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_OPA, text_opa, lv_opa_t, _opa, scalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_FONT, text_font, const lv_font_t * , _ptr, scalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_FONT, text_font, const lv_font_t *, _ptr, scalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_WIDTH, line_width, lv_style_int_t, _int, scalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_BLEND_MODE, line_blend_mode, lv_blend_mode_t, _int, scalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_DASH_WIDTH, line_dash_width, lv_style_int_t, _int, scalar)
|
||||
@@ -174,9 +174,9 @@ _LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_4, transition_prop_4, lv_style_int
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_5, transition_prop_5, lv_style_int_t, _int, scalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_6, transition_prop_6, lv_style_int_t, _int, scalar)
|
||||
#if LV_USE_ANIMATION
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PATH, transition_path, lv_anim_path_cb_t , _ptr, scalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PATH, transition_path, lv_anim_path_cb_t, _ptr, scalar)
|
||||
#else
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PATH, transition_path, void * , _ptr, scalar) /*For compatibility*/
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PATH, transition_path, void *, _ptr, scalar) /*For compatibility*/
|
||||
#endif
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_WIDTH, scale_width, lv_style_int_t, _int, scalar)
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_BORDER_WIDTH, scale_border_width, lv_style_int_t, _int, scalar)
|
||||
|
||||
+17
-15
@@ -17,7 +17,7 @@
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
|
||||
#if defined(LV_GC_INCLUDE)
|
||||
#include LV_GC_INCLUDE
|
||||
#include LV_GC_INCLUDE
|
||||
#endif /* LV_ENABLE_GC */
|
||||
|
||||
/*********************
|
||||
@@ -74,12 +74,13 @@ void lv_refr_init(void)
|
||||
void lv_refr_now(lv_disp_t * disp)
|
||||
{
|
||||
#if LV_USE_ANIMATION
|
||||
lv_anim_refr_now();
|
||||
lv_anim_refr_now();
|
||||
#endif
|
||||
|
||||
if(disp) {
|
||||
lv_disp_refr_task(disp->refr_task);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
lv_disp_t * d;
|
||||
d = lv_disp_get_next(NULL);
|
||||
while(d) {
|
||||
@@ -130,12 +131,13 @@ void lv_inv_area(lv_disp_t * disp, const lv_area_t * area_p)
|
||||
/*Save the area*/
|
||||
if(disp->inv_p < LV_INV_BUF_SIZE) {
|
||||
lv_area_copy(&disp->inv_areas[disp->inv_p], &com_area);
|
||||
} else { /*If no place for the area add the screen*/
|
||||
}
|
||||
else { /*If no place for the area add the screen*/
|
||||
disp->inv_p = 0;
|
||||
lv_area_copy(&disp->inv_areas[disp->inv_p], &scr_area);
|
||||
}
|
||||
disp->inv_p++;
|
||||
lv_task_set_prio(disp->refr_task, LV_REFR_TASK_PRIO);
|
||||
lv_task_set_prio(disp->refr_task, LV_REFR_TASK_PRIO);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,16 +171,16 @@ void lv_disp_refr_task(lv_task_t * task)
|
||||
|
||||
uint32_t start = lv_tick_get();
|
||||
|
||||
/* Ensure the task does not run again automatically.
|
||||
/* Ensure the task does not run again automatically.
|
||||
* This is done before refreshing in case refreshing invalidates something else.
|
||||
*/
|
||||
lv_task_set_prio(task, LV_TASK_PRIO_OFF);
|
||||
lv_task_set_prio(task, LV_TASK_PRIO_OFF);
|
||||
|
||||
disp_refr = task->user_data;
|
||||
|
||||
|
||||
// extern rect_cache_t cache[];
|
||||
// extern uint32_t cp;
|
||||
// extern rect_cache_t cache[];
|
||||
// extern uint32_t cp;
|
||||
|
||||
lv_refr_join_area();
|
||||
|
||||
@@ -348,7 +350,8 @@ static void lv_refr_area(const lv_area_t * area_p)
|
||||
LV_LOG_WARN("Can't set VDB height using the round function. (Wrong round_cb or to "
|
||||
"small VDB)");
|
||||
return;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
max_row = tmp.y2 + 1;
|
||||
}
|
||||
}
|
||||
@@ -433,12 +436,12 @@ static lv_obj_t * lv_refr_get_top_obj(const lv_area_t * area_p, lv_obj_t * obj)
|
||||
|
||||
/*If this object is fully cover the draw area check the children too */
|
||||
if(lv_area_is_in(area_p, &obj->coords, 0) && obj->hidden == 0) {
|
||||
lv_design_res_t design_res = obj->design_cb ? obj->design_cb(obj, area_p, LV_DESIGN_COVER_CHK) : LV_DESIGN_RES_NOT_COVER;
|
||||
lv_design_res_t design_res = obj->design_cb ? obj->design_cb(obj, area_p,
|
||||
LV_DESIGN_COVER_CHK) : LV_DESIGN_RES_NOT_COVER;
|
||||
if(design_res == LV_DESIGN_RES_MASKED) return NULL;
|
||||
|
||||
lv_obj_t * i;
|
||||
LV_LL_READ(obj->child_ll, i)
|
||||
{
|
||||
LV_LL_READ(obj->child_ll, i) {
|
||||
found_p = lv_refr_get_top_obj(area_p, i);
|
||||
|
||||
/*If a children is ok then break*/
|
||||
@@ -555,8 +558,7 @@ static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p)
|
||||
lv_area_t mask_child; /*Mask from obj and its child*/
|
||||
lv_obj_t * child_p;
|
||||
lv_area_t child_area;
|
||||
LV_LL_READ_BACK(obj->child_ll, child_p)
|
||||
{
|
||||
LV_LL_READ_BACK(obj->child_ll, child_p) {
|
||||
lv_obj_get_coords(child_p, &child_area);
|
||||
ext_size = child_p->ext_draw_pad;
|
||||
child_area.x1 -= ext_size;
|
||||
|
||||
+30
-24
@@ -106,8 +106,7 @@ bool lv_style_remove_prop(lv_style_t * style, lv_style_property_t prop)
|
||||
attr_found.full = *(style->map + id + 1);
|
||||
attr_goal.full = (prop >> 8) & 0xFFU;
|
||||
|
||||
if(attr_found.bits.state == attr_goal.bits.state)
|
||||
{
|
||||
if(attr_found.bits.state == attr_goal.bits.state) {
|
||||
uint32_t map_size = lv_style_get_mem_size(style);
|
||||
uint8_t prop_size = sizeof(lv_style_property_t);
|
||||
if((prop & 0xF) < LV_STYLE_ID_COLOR) prop_size += sizeof(lv_style_int_t);
|
||||
@@ -162,17 +161,20 @@ void lv_style_list_copy(lv_style_list_t * list_dest, const lv_style_list_t * lis
|
||||
list_dest->style_list = lv_mem_alloc((list_src->style_cnt - 1) * sizeof(lv_style_t *));
|
||||
memcpy(list_dest->style_list, list_src->style_list + 1, (list_src->style_cnt - 1) * sizeof(lv_style_t *));
|
||||
list_dest->style_cnt = list_src->style_cnt - 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
list_dest->style_list = lv_mem_alloc(list_src->style_cnt * sizeof(lv_style_t *));
|
||||
memcpy(list_dest->style_list, list_src->style_list, list_src->style_cnt * sizeof(lv_style_t *));
|
||||
list_dest->style_cnt = list_src->style_cnt;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if(list_src->has_trans) {
|
||||
list_dest->style_list = lv_mem_alloc((list_src->style_cnt - 2) * sizeof(lv_style_t *));
|
||||
memcpy(list_dest->style_list, list_src->style_list + 2, (list_src->style_cnt - 2) * sizeof(lv_style_t *));
|
||||
list_dest->style_cnt = list_src->style_cnt - 2;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
list_dest->style_list = lv_mem_alloc((list_src->style_cnt - 1) * sizeof(lv_style_t *));
|
||||
memcpy(list_dest->style_list, list_src->style_list + 1, (list_src->style_cnt - 1) * sizeof(lv_style_t *));
|
||||
list_dest->style_cnt = list_src->style_cnt - 1;
|
||||
@@ -336,10 +338,10 @@ uint16_t lv_style_get_mem_size(const lv_style_t * style)
|
||||
size_t i = 0;
|
||||
while(style->map[i] != _LV_STYLE_CLOSEING_PROP) {
|
||||
/*Go to the next property*/
|
||||
if((style->map[i] & 0xF) < LV_STYLE_ID_COLOR) i+= sizeof(lv_style_int_t);
|
||||
else if((style->map[i] & 0xF) < LV_STYLE_ID_OPA) i+= sizeof(lv_color_t);
|
||||
else if((style->map[i] & 0xF) < LV_STYLE_ID_PTR) i+= sizeof(lv_opa_t);
|
||||
else i+= sizeof(void*);
|
||||
if((style->map[i] & 0xF) < LV_STYLE_ID_COLOR) i += sizeof(lv_style_int_t);
|
||||
else if((style->map[i] & 0xF) < LV_STYLE_ID_OPA) i += sizeof(lv_color_t);
|
||||
else if((style->map[i] & 0xF) < LV_STYLE_ID_PTR) i += sizeof(lv_opa_t);
|
||||
else i += sizeof(void *);
|
||||
|
||||
i += sizeof(lv_style_property_t);
|
||||
}
|
||||
@@ -388,7 +390,7 @@ void _lv_style_set_int(lv_style_t * style, lv_style_property_t prop, lv_style_in
|
||||
LV_ASSERT_MEM(style->map);
|
||||
if(style == NULL) return;
|
||||
|
||||
memcpy(style->map + size - new_prop_size - end_mark_size , &prop, sizeof(lv_style_property_t));
|
||||
memcpy(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t));
|
||||
memcpy(style->map + size - sizeof(lv_style_int_t) - end_mark_size, &value, sizeof(lv_style_int_t));
|
||||
memcpy(style->map + size - end_mark_size, &end_mark, sizeof(end_mark));
|
||||
}
|
||||
@@ -529,8 +531,8 @@ void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, const void
|
||||
LV_ASSERT_MEM(style->map);
|
||||
if(style == NULL) return;
|
||||
|
||||
memcpy(style->map + size - new_prop_size - end_mark_size , &prop, sizeof(lv_style_property_t));
|
||||
memcpy(style->map + size - sizeof(void *) - end_mark_size , &p, sizeof(void *));
|
||||
memcpy(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t));
|
||||
memcpy(style->map + size - sizeof(void *) - end_mark_size, &p, sizeof(void *));
|
||||
memcpy(style->map + size - end_mark_size, &end_mark, sizeof(end_mark));
|
||||
}
|
||||
|
||||
@@ -554,7 +556,8 @@ int16_t _lv_style_get_int(const lv_style_t * style, lv_style_property_t prop, vo
|
||||
int32_t id = get_property_index(style, prop);
|
||||
if(id < 0) {
|
||||
return -1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
memcpy(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_style_int_t));
|
||||
lv_style_attr_t attr_act;
|
||||
attr_act.full = style->map[id + 1];
|
||||
@@ -589,7 +592,8 @@ int16_t _lv_style_get_opa(const lv_style_t * style, lv_style_property_t prop, vo
|
||||
int32_t id = get_property_index(style, prop);
|
||||
if(id < 0) {
|
||||
return -1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
memcpy(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_opa_t));
|
||||
lv_style_attr_t attr_act;
|
||||
attr_act.full = style->map[id + 1];
|
||||
@@ -622,7 +626,8 @@ int16_t _lv_style_get_color(const lv_style_t * style, lv_style_property_t prop,
|
||||
int32_t id = get_property_index(style, prop);
|
||||
if(id < 0) {
|
||||
return -1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
memcpy(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_color_t));
|
||||
lv_style_attr_t attr_act;
|
||||
attr_act.full = style->map[id + 1];
|
||||
@@ -649,14 +654,15 @@ int16_t _lv_style_get_color(const lv_style_t * style, lv_style_property_t prop,
|
||||
*/
|
||||
int16_t _lv_style_get_ptr(const lv_style_t * style, lv_style_property_t prop, void * v_res)
|
||||
{
|
||||
void **res = (void *)v_res;
|
||||
void ** res = (void *)v_res;
|
||||
if(style == NULL) return -1;
|
||||
if(style->map == NULL) return -1;
|
||||
int32_t id = get_property_index(style, prop);
|
||||
if(id < 0) {
|
||||
return -1;
|
||||
} else {
|
||||
memcpy(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(void*));
|
||||
}
|
||||
else {
|
||||
memcpy(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(void *));
|
||||
lv_style_attr_t attr_act;
|
||||
attr_act.full = style->map[id + 1];
|
||||
|
||||
@@ -1021,8 +1027,8 @@ static inline int32_t get_property_index(const lv_style_t * style, lv_style_prop
|
||||
size_t i = 0;
|
||||
while(style->map[i] != _LV_STYLE_CLOSEING_PROP) {
|
||||
if(style->map[i] == id_to_find) {
|
||||
lv_style_attr_t attr_i;
|
||||
attr_i.full = style->map[i + 1];
|
||||
lv_style_attr_t attr_i;
|
||||
attr_i.full = style->map[i + 1];
|
||||
|
||||
/*If the state perfectly matches return this property*/
|
||||
if(attr_i.bits.state == attr.bits.state) {
|
||||
@@ -1041,10 +1047,10 @@ static inline int32_t get_property_index(const lv_style_t * style, lv_style_prop
|
||||
}
|
||||
|
||||
/*Go to the next property*/
|
||||
if((style->map[i] & 0xF) < LV_STYLE_ID_COLOR) i+= sizeof(lv_style_int_t);
|
||||
else if((style->map[i] & 0xF) < LV_STYLE_ID_OPA) i+= sizeof(lv_color_t);
|
||||
else if((style->map[i] & 0xF) < LV_STYLE_ID_PTR) i+= sizeof(lv_opa_t);
|
||||
else i+= sizeof(void*);
|
||||
if((style->map[i] & 0xF) < LV_STYLE_ID_COLOR) i += sizeof(lv_style_int_t);
|
||||
else if((style->map[i] & 0xF) < LV_STYLE_ID_OPA) i += sizeof(lv_color_t);
|
||||
else if((style->map[i] & 0xF) < LV_STYLE_ID_PTR) i += sizeof(lv_opa_t);
|
||||
else i += sizeof(void *);
|
||||
|
||||
i += sizeof(lv_style_property_t);
|
||||
}
|
||||
|
||||
+10
-10
@@ -79,11 +79,11 @@ typedef uint8_t lv_text_decor_t;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
uint8_t state :7; /* To which state the property refers to*/
|
||||
uint8_t inherit :1; /*1: The property can be inherited*/
|
||||
}bits;
|
||||
uint8_t state : 7; /* To which state the property refers to*/
|
||||
uint8_t inherit : 1; /*1: The property can be inherited*/
|
||||
} bits;
|
||||
uint8_t full;
|
||||
}lv_style_attr_t;
|
||||
} lv_style_attr_t;
|
||||
|
||||
|
||||
#define LV_STYLE_ID_VALUE 0x0 /*max 8 pcs*/
|
||||
@@ -205,7 +205,7 @@ typedef struct {
|
||||
#if LV_USE_ASSERT_STYLE
|
||||
uint32_t sentinel;
|
||||
#endif
|
||||
}lv_style_t;
|
||||
} lv_style_t;
|
||||
|
||||
typedef int16_t lv_style_int_t;
|
||||
|
||||
@@ -216,11 +216,11 @@ typedef struct {
|
||||
uint32_t sentinel;
|
||||
#endif
|
||||
uint8_t style_cnt;
|
||||
uint8_t has_local :1;
|
||||
uint8_t has_trans :1;
|
||||
uint8_t skip_trans :1; /*1: Temporally skip the transition style if any*/
|
||||
uint8_t ignore_trans :1; /*1: Mark that this style list shouldn't receive transitions at all*/
|
||||
}lv_style_list_t;
|
||||
uint8_t has_local : 1;
|
||||
uint8_t has_trans : 1;
|
||||
uint8_t skip_trans : 1; /*1: Temporally skip the transition style if any*/
|
||||
uint8_t ignore_trans : 1; /*1: Mark that this style list shouldn't receive transitions at all*/
|
||||
} lv_style_list_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
|
||||
+20
-17
@@ -32,16 +32,16 @@ typedef struct {
|
||||
lv_draw_rect_dsc_t * draw_dsc;
|
||||
const lv_area_t * draw_area;
|
||||
const lv_area_t * clip_area;
|
||||
}quarter_draw_dsc_t;
|
||||
} quarter_draw_dsc_t;
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void draw_quarter_0(quarter_draw_dsc_t* q);
|
||||
static void draw_quarter_1(quarter_draw_dsc_t* q);
|
||||
static void draw_quarter_2(quarter_draw_dsc_t* q);
|
||||
static void draw_quarter_3(quarter_draw_dsc_t* q);
|
||||
static void draw_quarter_0(quarter_draw_dsc_t * q);
|
||||
static void draw_quarter_1(quarter_draw_dsc_t * q);
|
||||
static void draw_quarter_2(quarter_draw_dsc_t * q);
|
||||
static void draw_quarter_3(quarter_draw_dsc_t * q);
|
||||
static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t tickness, lv_area_t * res_area);
|
||||
|
||||
|
||||
@@ -68,7 +68,8 @@ static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t tickness,
|
||||
* @param style style of the arc (`body.thickness`, `body.main_color`, `body.opa` is used)
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
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)
|
||||
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;
|
||||
@@ -104,7 +105,8 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin
|
||||
int32_t angle_gap;
|
||||
if(end_angle > start_angle) {
|
||||
angle_gap = 360 - (end_angle - start_angle);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
angle_gap = start_angle - end_angle;
|
||||
}
|
||||
if(angle_gap > SPLIT_ANGLE_GAP_LIMIT && radius > SPLIT_RADIUS_LIMIT) {
|
||||
@@ -115,7 +117,7 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin
|
||||
q_dsc.radius = radius;
|
||||
q_dsc.start_angle = start_angle;
|
||||
q_dsc.end_angle = end_angle;
|
||||
q_dsc.start_quarter= (start_angle / 90) & 0x3;
|
||||
q_dsc.start_quarter = (start_angle / 90) & 0x3;
|
||||
q_dsc.end_quarter = (end_angle / 90) & 0x3;
|
||||
q_dsc.width = dsc->width;
|
||||
q_dsc.draw_dsc = &cir_dsc;
|
||||
@@ -126,7 +128,8 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin
|
||||
draw_quarter_1(&q_dsc);
|
||||
draw_quarter_2(&q_dsc);
|
||||
draw_quarter_3(&q_dsc);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
lv_draw_rect(&area, clip_area, &cir_dsc);
|
||||
}
|
||||
lv_draw_mask_remove_id(mask_angle_id);
|
||||
@@ -191,7 +194,7 @@ static void draw_quarter_0(quarter_draw_dsc_t * q)
|
||||
bool ok = lv_area_intersect(&quarter_area, &quarter_area, q->clip_area);
|
||||
if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc);
|
||||
}
|
||||
if(q->end_quarter == 0) {
|
||||
if(q->end_quarter == 0) {
|
||||
quarter_area.x2 = q->center_x + q->radius;
|
||||
quarter_area.y1 = q->center_y;
|
||||
|
||||
@@ -244,12 +247,12 @@ static void draw_quarter_1(quarter_draw_dsc_t * q)
|
||||
bool ok = lv_area_intersect(&quarter_area, &quarter_area, q->clip_area);
|
||||
if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc);
|
||||
}
|
||||
if(q->end_quarter == 1) {
|
||||
if(q->end_quarter == 1) {
|
||||
quarter_area.x2 = q->center_x - 1;
|
||||
quarter_area.y2 = q->center_y + q->radius;
|
||||
|
||||
quarter_area.y1 = q->center_y + ((lv_trigo_sin(q->end_angle) * (q->radius- q->width)) >> LV_TRIGO_SHIFT);
|
||||
quarter_area.x1 = q->center_x + ((lv_trigo_sin(q->end_angle + 90) * (q->radius )) >> LV_TRIGO_SHIFT);
|
||||
quarter_area.y1 = q->center_y + ((lv_trigo_sin(q->end_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT);
|
||||
quarter_area.x1 = q->center_x + ((lv_trigo_sin(q->end_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT);
|
||||
|
||||
bool ok = lv_area_intersect(&quarter_area, &quarter_area, q->clip_area);
|
||||
if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc);
|
||||
@@ -291,13 +294,13 @@ static void draw_quarter_2(quarter_draw_dsc_t * q)
|
||||
quarter_area.x2 = q->center_x - 1;
|
||||
quarter_area.y1 = q->center_y - q->radius;
|
||||
|
||||
quarter_area.x1 = q->center_x + ((lv_trigo_sin(q->start_angle + 90) * (q->radius )) >> LV_TRIGO_SHIFT);
|
||||
quarter_area.y2 = q->center_y + ((lv_trigo_sin(q->start_angle) * (q->radius- q->width)) >> LV_TRIGO_SHIFT);
|
||||
quarter_area.x1 = q->center_x + ((lv_trigo_sin(q->start_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT);
|
||||
quarter_area.y2 = q->center_y + ((lv_trigo_sin(q->start_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT);
|
||||
|
||||
bool ok = lv_area_intersect(&quarter_area, &quarter_area, q->clip_area);
|
||||
if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc);
|
||||
}
|
||||
if(q->end_quarter == 2) {
|
||||
if(q->end_quarter == 2) {
|
||||
quarter_area.x1 = q->center_x - q->radius;
|
||||
quarter_area.y2 = q->center_y - 1;
|
||||
|
||||
@@ -351,7 +354,7 @@ static void draw_quarter_3(quarter_draw_dsc_t * q)
|
||||
bool ok = lv_area_intersect(&quarter_area, &quarter_area, q->clip_area);
|
||||
if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc);
|
||||
}
|
||||
if(q->end_quarter == 3) {
|
||||
if(q->end_quarter == 3) {
|
||||
quarter_area.x1 = q->center_x;
|
||||
quarter_area.y1 = q->center_y - q->radius;
|
||||
|
||||
|
||||
@@ -38,7 +38,8 @@ extern "C" {
|
||||
* @param style style of the arc (`body.thickness`, `body.main_color`, `body.opa` is used)
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
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);
|
||||
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);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
||||
+100
-83
@@ -28,28 +28,28 @@
|
||||
**********************/
|
||||
|
||||
static void fill_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
|
||||
lv_color_t color, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res);
|
||||
lv_color_t color, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res);
|
||||
|
||||
static void fill_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
|
||||
lv_color_t color, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res);
|
||||
lv_color_t color, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res);
|
||||
|
||||
static void fill_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
|
||||
lv_color_t color, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode);
|
||||
lv_color_t color, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode);
|
||||
|
||||
static void map_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
|
||||
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res);
|
||||
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res);
|
||||
|
||||
static void map_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
|
||||
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res);
|
||||
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res);
|
||||
|
||||
static void map_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
|
||||
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode);
|
||||
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode);
|
||||
|
||||
static inline lv_color_t color_blend_true_color_additive(lv_color_t fg, lv_color_t bg, lv_opa_t opa);
|
||||
static inline lv_color_t color_blend_true_color_subtractive(lv_color_t fg, lv_color_t bg, lv_opa_t opa);
|
||||
@@ -81,8 +81,8 @@ static inline lv_color_t color_blend_true_color_subtractive(lv_color_t fg, lv_co
|
||||
* @param mode
|
||||
*/
|
||||
void lv_blend_fill(const lv_area_t * clip_area, const lv_area_t * fill_area,
|
||||
lv_color_t color, lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_opa_t opa,
|
||||
lv_blend_mode_t mode)
|
||||
lv_color_t color, lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_opa_t opa,
|
||||
lv_blend_mode_t mode)
|
||||
{
|
||||
/*Do not draw transparent things*/
|
||||
if(opa < LV_OPA_MIN) return;
|
||||
@@ -112,7 +112,7 @@ void lv_blend_fill(const lv_area_t * clip_area, const lv_area_t * fill_area,
|
||||
if(mask && disp->driver.antialiasing == 0) {
|
||||
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;
|
||||
for(i = 0; i < mask_w; i++) mask[i] = mask[i] > 128 ? LV_OPA_COVER : LV_OPA_TRANSP;
|
||||
}
|
||||
|
||||
if(disp->driver.set_px_cb) {
|
||||
@@ -128,8 +128,8 @@ void lv_blend_fill(const lv_area_t * clip_area, const lv_area_t * fill_area,
|
||||
|
||||
|
||||
void lv_blend_map(const lv_area_t * clip_area, const lv_area_t * map_area, const lv_color_t * map_buf,
|
||||
lv_opa_t * mask, lv_draw_mask_res_t mask_res,
|
||||
lv_opa_t opa, lv_blend_mode_t mode)
|
||||
lv_opa_t * mask, lv_draw_mask_res_t mask_res,
|
||||
lv_opa_t opa, lv_blend_mode_t mode)
|
||||
{
|
||||
/*Do not draw transparent things*/
|
||||
if(opa < LV_OPA_MIN) return;
|
||||
@@ -158,14 +158,15 @@ void lv_blend_map(const lv_area_t * clip_area, const lv_area_t * map_area, const
|
||||
if(mask && disp->driver.antialiasing == 0) {
|
||||
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;
|
||||
for(i = 0; i < mask_w; i++) mask[i] = mask[i] > 128 ? LV_OPA_COVER : LV_OPA_TRANSP;
|
||||
}
|
||||
if(disp->driver.set_px_cb) {
|
||||
map_set_px(disp_area, disp_buf, &draw_area, map_area, map_buf, opa, mask, mask_res);
|
||||
}
|
||||
else if(mode == LV_BLEND_MODE_NORMAL) {
|
||||
map_normal(disp_area, disp_buf, &draw_area, map_area, map_buf, opa, mask, mask_res);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
map_blended(disp_area, disp_buf, &draw_area, map_area, map_buf, opa, mask, mask_res, mode);
|
||||
}
|
||||
}
|
||||
@@ -176,8 +177,8 @@ void lv_blend_map(const lv_area_t * clip_area, const lv_area_t * map_area, const
|
||||
**********************/
|
||||
|
||||
static void fill_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
|
||||
lv_color_t color, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res)
|
||||
lv_color_t color, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res)
|
||||
{
|
||||
|
||||
lv_disp_t * disp = lv_refr_get_disp_refreshing();
|
||||
@@ -191,10 +192,11 @@ static void fill_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, con
|
||||
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) {
|
||||
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, opa);
|
||||
disp->driver.set_px_cb(&disp->driver, (void *)disp_buf, disp_w, x, y, color, opa);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* The mask is relative to the clipped area.
|
||||
* In the cycles below mask will be indexed from `draw_area.x1`
|
||||
* but it corresponds to zero index. So prepare `mask_tmp` accordingly. */
|
||||
@@ -205,7 +207,8 @@ static void fill_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, con
|
||||
|
||||
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, (uint32_t)((uint32_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;
|
||||
}
|
||||
@@ -213,8 +216,8 @@ static void fill_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, con
|
||||
}
|
||||
|
||||
static void fill_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
|
||||
lv_color_t color, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res)
|
||||
lv_color_t color, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res)
|
||||
{
|
||||
|
||||
#if LV_USE_GPU
|
||||
@@ -247,7 +250,8 @@ 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*/
|
||||
int32_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;
|
||||
}
|
||||
@@ -286,8 +290,10 @@ static void fill_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, con
|
||||
|
||||
#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, &last_res_color, &last_res_color.ch.alpha);
|
||||
} else
|
||||
lv_color_mix_with_alpha(disp_buf_tmp[x], disp_buf_tmp[x].ch.alpha, color, opa, &last_res_color,
|
||||
&last_res_color.ch.alpha);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
last_res_color = lv_color_mix(color, disp_buf_tmp[x], opa);
|
||||
@@ -318,12 +324,13 @@ static void fill_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, con
|
||||
for(y = draw_area->y1; y <= draw_area->y2; y++) {
|
||||
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)
|
||||
{
|
||||
if(mask_tmp[x] != last_mask || last_dest_color.full != disp_buf_tmp[x].full) {
|
||||
#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, mask_tmp[x], &last_res_color, &last_res_color.ch.alpha);
|
||||
} else
|
||||
lv_color_mix_with_alpha(disp_buf_tmp[x], disp_buf_tmp[x].ch.alpha, color, mask_tmp[x], &last_res_color,
|
||||
&last_res_color.ch.alpha);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if(mask_tmp[x] == LV_OPA_COVER) last_res_color = color;
|
||||
@@ -349,13 +356,15 @@ static void fill_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, con
|
||||
lv_opa_t opa_tmp = mask_tmp[x] == LV_OPA_COVER ? opa : (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);
|
||||
} else
|
||||
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);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if(opa_tmp == LV_OPA_COVER) last_res_color = lv_color_mix(color, disp_buf_tmp[x], mask_tmp[x]);
|
||||
else if(opa_tmp == LV_OPA_TRANSP) last_res_color = disp_buf_tmp[x];
|
||||
else last_res_color = lv_color_mix(color, disp_buf_tmp[x],opa_tmp);
|
||||
else last_res_color = lv_color_mix(color, disp_buf_tmp[x], opa_tmp);
|
||||
}
|
||||
last_mask = mask_tmp[x];
|
||||
last_dest_color.full = disp_buf_tmp[x].full;
|
||||
@@ -371,8 +380,8 @@ static void fill_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, con
|
||||
|
||||
|
||||
static void fill_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
|
||||
lv_color_t color, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode)
|
||||
lv_color_t color, lv_opa_t opa,
|
||||
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*/
|
||||
int32_t disp_w = lv_area_get_width(disp_area);
|
||||
@@ -382,17 +391,17 @@ static void fill_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, co
|
||||
|
||||
|
||||
lv_color_t (*blend_fp)(lv_color_t, lv_color_t, lv_opa_t);
|
||||
switch (mode) {
|
||||
case LV_BLEND_MODE_ADDITIVE:
|
||||
blend_fp = color_blend_true_color_additive;
|
||||
break;
|
||||
case LV_BLEND_MODE_SUBTRACTIVE:
|
||||
blend_fp = color_blend_true_color_subtractive;
|
||||
break;
|
||||
default:
|
||||
LV_LOG_WARN("fill_blended: unsupported blend mode");
|
||||
return;
|
||||
break;
|
||||
switch(mode) {
|
||||
case LV_BLEND_MODE_ADDITIVE:
|
||||
blend_fp = color_blend_true_color_additive;
|
||||
break;
|
||||
case LV_BLEND_MODE_SUBTRACTIVE:
|
||||
blend_fp = color_blend_true_color_subtractive;
|
||||
break;
|
||||
default:
|
||||
LV_LOG_WARN("fill_blended: unsupported blend mode");
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
int32_t x;
|
||||
@@ -449,8 +458,8 @@ static void fill_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, co
|
||||
}
|
||||
|
||||
static void map_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
|
||||
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res)
|
||||
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res)
|
||||
|
||||
{
|
||||
lv_disp_t * disp = lv_refr_get_disp_refreshing();
|
||||
@@ -475,11 +484,12 @@ static void map_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, cons
|
||||
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) {
|
||||
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], opa);
|
||||
disp->driver.set_px_cb(&disp->driver, (void *)disp_buf, disp_w, x, y, map_buf_tmp[x], opa);
|
||||
}
|
||||
map_buf_tmp += map_w;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* The mask is relative to the clipped area.
|
||||
* In the cycles below mask will be indexed from `draw_area.x1`
|
||||
* but it corresponds to zero index. So prepare `mask_tmp` accordingly. */
|
||||
@@ -487,7 +497,8 @@ 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], (uint32_t)((uint32_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;
|
||||
@@ -497,8 +508,8 @@ static void map_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, cons
|
||||
|
||||
|
||||
static void map_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
|
||||
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res)
|
||||
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res)
|
||||
{
|
||||
|
||||
/*Get the width of the `disp_area` it will be used to go to the next line*/
|
||||
@@ -533,8 +544,8 @@ static void map_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, cons
|
||||
map_buf_tmp += (draw_area->x1 - (map_area->x1 - disp_area->x1));
|
||||
#if LV_USE_GPU
|
||||
if(disp->driver.gpu_blend_cb &&
|
||||
((draw_area_w > GPU_WIDTH_LIMIT * 4 && opa == LV_OPA_COVER) ||
|
||||
(draw_area_w > GPU_WIDTH_LIMIT && opa != LV_OPA_COVER))) {
|
||||
((draw_area_w > GPU_WIDTH_LIMIT * 4 && opa == LV_OPA_COVER) ||
|
||||
(draw_area_w > GPU_WIDTH_LIMIT && opa != LV_OPA_COVER))) {
|
||||
for(y = draw_area->y1; y <= draw_area->y2; y++) {
|
||||
disp->driver.gpu_blend_cb(&disp->driver, &disp_buf_tmp[draw_area->x1], map_buf_tmp, draw_area_w, opa);
|
||||
disp_buf_tmp += disp_w;
|
||||
@@ -558,8 +569,10 @@ static void map_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, cons
|
||||
for(x = draw_area->x1; x <= draw_area->x2; x++) {
|
||||
#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, map_buf_tmp[x], opa, &disp_buf_tmp[x], &disp_buf_tmp[x].ch.alpha);
|
||||
} else
|
||||
lv_color_mix_with_alpha(disp_buf_tmp[x], disp_buf_tmp[x].ch.alpha, map_buf_tmp[x], opa, &disp_buf_tmp[x],
|
||||
&disp_buf_tmp[x].ch.alpha);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
disp_buf_tmp[x] = lv_color_mix(map_buf_tmp[x], disp_buf_tmp[x], opa);
|
||||
@@ -591,15 +604,17 @@ static void map_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, cons
|
||||
for(x = draw_area->x1; x <= draw_area->x2; x++) {
|
||||
if(mask_tmp[x] < LV_OPA_MIN) continue;
|
||||
#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, map_buf_tmp[x], mask_tmp[x], &res_color, &opa_composed);
|
||||
res_color.ch.alpha = opa_composed;
|
||||
} else
|
||||
if(disp->driver.screen_transp) {
|
||||
lv_color_mix_with_alpha(disp_buf_tmp[x], disp_buf_tmp[x].ch.alpha, map_buf_tmp[x], mask_tmp[x], &res_color,
|
||||
&opa_composed);
|
||||
res_color.ch.alpha = opa_composed;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if(mask_tmp[x] > LV_OPA_MAX) res_color = map_buf_tmp[x];
|
||||
else res_color = lv_color_mix(map_buf_tmp[x], disp_buf_tmp[x], mask_tmp[x]);
|
||||
}
|
||||
{
|
||||
if(mask_tmp[x] > LV_OPA_MAX) res_color = map_buf_tmp[x];
|
||||
else res_color = lv_color_mix(map_buf_tmp[x], disp_buf_tmp[x], mask_tmp[x]);
|
||||
}
|
||||
disp_buf_tmp[x] = res_color;//lv_color_mix(map_buf_tmp[x], disp_buf_tmp[x], mask_tmp[x]);
|
||||
}
|
||||
disp_buf_tmp += disp_w;
|
||||
@@ -616,8 +631,10 @@ static void map_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, cons
|
||||
lv_opa_t opa_tmp = mask_tmp[x] >= LV_OPA_MAX ? opa : ((opa * mask_tmp[x]) >> 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, map_buf_tmp[x], opa_tmp, &disp_buf_tmp[x], &disp_buf_tmp[x].ch.alpha);
|
||||
} else
|
||||
lv_color_mix_with_alpha(disp_buf_tmp[x], disp_buf_tmp[x].ch.alpha, map_buf_tmp[x], opa_tmp, &disp_buf_tmp[x],
|
||||
&disp_buf_tmp[x].ch.alpha);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
disp_buf_tmp[x] = lv_color_mix(map_buf_tmp[x], disp_buf_tmp[x], opa_tmp);
|
||||
@@ -632,8 +649,8 @@ static void map_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, cons
|
||||
}
|
||||
|
||||
static void map_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
|
||||
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode)
|
||||
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
|
||||
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*/
|
||||
@@ -652,17 +669,17 @@ static void map_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, con
|
||||
const lv_color_t * map_buf_tmp = map_buf + map_w * (draw_area->y1 - (map_area->y1 - disp_area->y1));
|
||||
|
||||
lv_color_t (*blend_fp)(lv_color_t, lv_color_t, lv_opa_t);
|
||||
switch (mode) {
|
||||
case LV_BLEND_MODE_ADDITIVE:
|
||||
blend_fp = color_blend_true_color_additive;
|
||||
break;
|
||||
case LV_BLEND_MODE_SUBTRACTIVE:
|
||||
blend_fp = color_blend_true_color_subtractive;
|
||||
break;
|
||||
default:
|
||||
LV_LOG_WARN("fill_blended: unsupported blend mode");
|
||||
return;
|
||||
break;
|
||||
switch(mode) {
|
||||
case LV_BLEND_MODE_ADDITIVE:
|
||||
blend_fp = color_blend_true_color_additive;
|
||||
break;
|
||||
case LV_BLEND_MODE_SUBTRACTIVE:
|
||||
blend_fp = color_blend_true_color_subtractive;
|
||||
break;
|
||||
default:
|
||||
LV_LOG_WARN("fill_blended: unsupported blend mode");
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
int32_t x;
|
||||
|
||||
@@ -37,7 +37,7 @@ typedef uint8_t lv_blend_mode_t;
|
||||
**********************/
|
||||
|
||||
void lv_blend_fill(const lv_area_t * clip_area, const lv_area_t * fill_area, lv_color_t color,
|
||||
lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_opa_t opa, lv_blend_mode_t mode);
|
||||
lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_opa_t opa, lv_blend_mode_t mode);
|
||||
|
||||
|
||||
void lv_blend_map(const lv_area_t * clip_area, const lv_area_t * map_area, const lv_color_t * map_buf,
|
||||
|
||||
+87
-50
@@ -25,10 +25,12 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mask, const void * src, lv_draw_img_dsc_t * draw_dsc);
|
||||
static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mask, const void * src,
|
||||
lv_draw_img_dsc_t * draw_dsc);
|
||||
|
||||
static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area, const uint8_t * map_p, lv_draw_img_dsc_t * draw_dsc,
|
||||
bool chroma_key, bool alpha_byte);
|
||||
static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area, const uint8_t * map_p,
|
||||
lv_draw_img_dsc_t * draw_dsc,
|
||||
bool chroma_key, bool alpha_byte);
|
||||
|
||||
void show_error(const lv_area_t * coords, const lv_area_t * clip_area, const char * msg);
|
||||
/**********************
|
||||
@@ -94,20 +96,36 @@ uint8_t lv_img_cf_get_px_size(lv_img_cf_t cf)
|
||||
uint8_t px_size = 0;
|
||||
|
||||
switch(cf) {
|
||||
case LV_IMG_CF_UNKNOWN:
|
||||
case LV_IMG_CF_RAW: px_size = 0; break;
|
||||
case LV_IMG_CF_TRUE_COLOR:
|
||||
case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED: px_size = LV_COLOR_SIZE; break;
|
||||
case LV_IMG_CF_TRUE_COLOR_ALPHA: px_size = LV_IMG_PX_SIZE_ALPHA_BYTE << 3; break;
|
||||
case LV_IMG_CF_INDEXED_1BIT:
|
||||
case LV_IMG_CF_ALPHA_1BIT: px_size = 1; break;
|
||||
case LV_IMG_CF_INDEXED_2BIT:
|
||||
case LV_IMG_CF_ALPHA_2BIT: px_size = 2; break;
|
||||
case LV_IMG_CF_INDEXED_4BIT:
|
||||
case LV_IMG_CF_ALPHA_4BIT: px_size = 4; break;
|
||||
case LV_IMG_CF_INDEXED_8BIT:
|
||||
case LV_IMG_CF_ALPHA_8BIT: px_size = 8; break;
|
||||
default: px_size = 0; break;
|
||||
case LV_IMG_CF_UNKNOWN:
|
||||
case LV_IMG_CF_RAW:
|
||||
px_size = 0;
|
||||
break;
|
||||
case LV_IMG_CF_TRUE_COLOR:
|
||||
case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED:
|
||||
px_size = LV_COLOR_SIZE;
|
||||
break;
|
||||
case LV_IMG_CF_TRUE_COLOR_ALPHA:
|
||||
px_size = LV_IMG_PX_SIZE_ALPHA_BYTE << 3;
|
||||
break;
|
||||
case LV_IMG_CF_INDEXED_1BIT:
|
||||
case LV_IMG_CF_ALPHA_1BIT:
|
||||
px_size = 1;
|
||||
break;
|
||||
case LV_IMG_CF_INDEXED_2BIT:
|
||||
case LV_IMG_CF_ALPHA_2BIT:
|
||||
px_size = 2;
|
||||
break;
|
||||
case LV_IMG_CF_INDEXED_4BIT:
|
||||
case LV_IMG_CF_ALPHA_4BIT:
|
||||
px_size = 4;
|
||||
break;
|
||||
case LV_IMG_CF_INDEXED_8BIT:
|
||||
case LV_IMG_CF_ALPHA_8BIT:
|
||||
px_size = 8;
|
||||
break;
|
||||
default:
|
||||
px_size = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return px_size;
|
||||
@@ -123,17 +141,20 @@ bool lv_img_cf_is_chroma_keyed(lv_img_cf_t cf)
|
||||
bool is_chroma_keyed = false;
|
||||
|
||||
switch(cf) {
|
||||
case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED:
|
||||
case LV_IMG_CF_RAW_CHROMA_KEYED:
|
||||
case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED:
|
||||
case LV_IMG_CF_RAW_CHROMA_KEYED:
|
||||
#if LV_INDEXED_CHROMA
|
||||
case LV_IMG_CF_INDEXED_1BIT:
|
||||
case LV_IMG_CF_INDEXED_2BIT:
|
||||
case LV_IMG_CF_INDEXED_4BIT:
|
||||
case LV_IMG_CF_INDEXED_8BIT:
|
||||
case LV_IMG_CF_INDEXED_1BIT:
|
||||
case LV_IMG_CF_INDEXED_2BIT:
|
||||
case LV_IMG_CF_INDEXED_4BIT:
|
||||
case LV_IMG_CF_INDEXED_8BIT:
|
||||
#endif
|
||||
is_chroma_keyed = true; break;
|
||||
is_chroma_keyed = true;
|
||||
break;
|
||||
|
||||
default: is_chroma_keyed = false; break;
|
||||
default:
|
||||
is_chroma_keyed = false;
|
||||
break;
|
||||
}
|
||||
|
||||
return is_chroma_keyed;
|
||||
@@ -149,17 +170,21 @@ bool lv_img_cf_has_alpha(lv_img_cf_t cf)
|
||||
bool has_alpha = false;
|
||||
|
||||
switch(cf) {
|
||||
case LV_IMG_CF_TRUE_COLOR_ALPHA:
|
||||
case LV_IMG_CF_RAW_ALPHA:
|
||||
case LV_IMG_CF_INDEXED_1BIT:
|
||||
case LV_IMG_CF_INDEXED_2BIT:
|
||||
case LV_IMG_CF_INDEXED_4BIT:
|
||||
case LV_IMG_CF_INDEXED_8BIT:
|
||||
case LV_IMG_CF_ALPHA_1BIT:
|
||||
case LV_IMG_CF_ALPHA_2BIT:
|
||||
case LV_IMG_CF_ALPHA_4BIT:
|
||||
case LV_IMG_CF_ALPHA_8BIT: has_alpha = true; break;
|
||||
default: has_alpha = false; break;
|
||||
case LV_IMG_CF_TRUE_COLOR_ALPHA:
|
||||
case LV_IMG_CF_RAW_ALPHA:
|
||||
case LV_IMG_CF_INDEXED_1BIT:
|
||||
case LV_IMG_CF_INDEXED_2BIT:
|
||||
case LV_IMG_CF_INDEXED_4BIT:
|
||||
case LV_IMG_CF_INDEXED_8BIT:
|
||||
case LV_IMG_CF_ALPHA_1BIT:
|
||||
case LV_IMG_CF_ALPHA_2BIT:
|
||||
case LV_IMG_CF_ALPHA_4BIT:
|
||||
case LV_IMG_CF_ALPHA_8BIT:
|
||||
has_alpha = true;
|
||||
break;
|
||||
default:
|
||||
has_alpha = false;
|
||||
break;
|
||||
}
|
||||
|
||||
return has_alpha;
|
||||
@@ -183,9 +208,11 @@ lv_img_src_t lv_img_src_get_type(const void * src)
|
||||
/*The first byte shows the type of the image source*/
|
||||
if(u8_p[0] >= 0x20 && u8_p[0] <= 0x7F) {
|
||||
img_src_type = LV_IMG_SRC_FILE; /*If it's an ASCII character then it's file name*/
|
||||
} else if(u8_p[0] >= 0x80) {
|
||||
}
|
||||
else if(u8_p[0] >= 0x80) {
|
||||
img_src_type = LV_IMG_SRC_SYMBOL; /*Symbols begins after 0x7F*/
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
img_src_type = LV_IMG_SRC_VARIABLE; /*`lv_img_dsc_t` is design to the first byte < 0x20*/
|
||||
}
|
||||
|
||||
@@ -200,7 +227,8 @@ lv_img_src_t lv_img_src_get_type(const void * src)
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mask, const void * src, lv_draw_img_dsc_t * draw_dsc)
|
||||
static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mask, const void * src,
|
||||
lv_draw_img_dsc_t * draw_dsc)
|
||||
{
|
||||
if(draw_dsc->opa <= LV_OPA_MIN) return LV_RES_OK;
|
||||
|
||||
@@ -255,7 +283,8 @@ static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mas
|
||||
|
||||
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*/
|
||||
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);
|
||||
@@ -303,7 +332,8 @@ static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mas
|
||||
* @param zoom zoom factor
|
||||
* @param antialias anti-alias transformations (rotate, zoom) or not
|
||||
*/
|
||||
static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area, const uint8_t * map_p, lv_draw_img_dsc_t * draw_dsc, bool chroma_key, bool alpha_byte)
|
||||
static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area, const uint8_t * map_p,
|
||||
lv_draw_img_dsc_t * draw_dsc, bool chroma_key, bool alpha_byte)
|
||||
{
|
||||
/* Use the clip area as draw area*/
|
||||
lv_area_t draw_area;
|
||||
@@ -326,7 +356,8 @@ static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area,
|
||||
if(other_mask_cnt == 0 && draw_dsc->angle == 0 && draw_dsc->zoom == LV_IMG_ZOOM_NONE &&
|
||||
chroma_key == false && alpha_byte == false &&
|
||||
draw_dsc->opa == LV_OPA_COVER && draw_dsc->recolor_opa == LV_OPA_TRANSP) {
|
||||
lv_blend_map(clip_area, map_area, (lv_color_t *)map_p, NULL, LV_DRAW_MASK_RES_FULL_COVER, LV_OPA_COVER, draw_dsc->blend_mode);
|
||||
lv_blend_map(clip_area, map_area, (lv_color_t *)map_p, NULL, LV_DRAW_MASK_RES_FULL_COVER, LV_OPA_COVER,
|
||||
draw_dsc->blend_mode);
|
||||
}
|
||||
/*In the other cases every pixel need to be checked one-by-one*/
|
||||
else {
|
||||
@@ -406,7 +437,8 @@ static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area,
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
mask_buf[px_i] = LV_OPA_COVER;
|
||||
}
|
||||
|
||||
@@ -415,15 +447,16 @@ static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area,
|
||||
#elif LV_COLOR_DEPTH == 16
|
||||
c.full = map_px[0] + (map_px[1] << 8);
|
||||
#elif LV_COLOR_DEPTH == 32
|
||||
c.full = *((uint32_t*)map_px);
|
||||
c.full = *((uint32_t *)map_px);
|
||||
#endif
|
||||
if (chroma_key) {
|
||||
if(chroma_key) {
|
||||
if(c.full == chroma_keyed_color.full) {
|
||||
mask_buf[px_i] = LV_OPA_TRANSP;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/*Rotate*/
|
||||
bool ret;
|
||||
int32_t rot_x = x + (disp_area->x1 + draw_area.x1) - map_area->x1;
|
||||
@@ -432,7 +465,8 @@ static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area,
|
||||
if(ret == false) {
|
||||
mask_buf[px_i] = LV_OPA_TRANSP;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
mask_buf[px_i] = trans_dsc.res.opa;
|
||||
c.full = trans_dsc.res.color.full;
|
||||
}
|
||||
@@ -448,11 +482,13 @@ static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area,
|
||||
/*Apply the masks if any*/
|
||||
if(other_mask_cnt) {
|
||||
lv_draw_mask_res_t mask_res_sub;
|
||||
mask_res_sub = lv_draw_mask_apply(mask_buf + px_i_start, draw_area.x1 + vdb->area.x1, y + draw_area.y1 + vdb->area.y1, lv_area_get_width(&draw_area));
|
||||
mask_res_sub = lv_draw_mask_apply(mask_buf + px_i_start, draw_area.x1 + vdb->area.x1, y + draw_area.y1 + vdb->area.y1,
|
||||
lv_area_get_width(&draw_area));
|
||||
if(mask_res_sub == LV_DRAW_MASK_RES_FULL_TRANSP) {
|
||||
memset(mask_buf + px_i_start, 0x00, lv_area_get_width(&draw_area));
|
||||
mask_res = LV_DRAW_MASK_RES_CHANGED;
|
||||
} else if(mask_res_sub == LV_DRAW_MASK_RES_CHANGED) {
|
||||
}
|
||||
else if(mask_res_sub == LV_DRAW_MASK_RES_CHANGED) {
|
||||
mask_res = LV_DRAW_MASK_RES_CHANGED;
|
||||
}
|
||||
}
|
||||
@@ -460,7 +496,8 @@ static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area,
|
||||
map_buf_tmp += map_w * px_size_byte;
|
||||
if(px_i + lv_area_get_width(&draw_area) < mask_buf_size) {
|
||||
blend_area.y2 ++;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
lv_blend_map(clip_area, &blend_area, map2, mask_buf, mask_res, draw_dsc->opa, draw_dsc->blend_mode);
|
||||
|
||||
blend_area.y1 = blend_area.y2 + 1;
|
||||
|
||||
@@ -40,7 +40,7 @@ typedef struct {
|
||||
|
||||
lv_blend_mode_t blend_mode;
|
||||
|
||||
uint8_t antialias :1;
|
||||
uint8_t antialias : 1;
|
||||
} lv_draw_img_dsc_t;
|
||||
|
||||
/**********************
|
||||
|
||||
+133
-95
@@ -32,10 +32,13 @@ typedef uint8_t cmd_state_t;
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * clip_area, const lv_font_t * font_p, uint32_t letter,
|
||||
lv_color_t color, lv_opa_t opa);
|
||||
static void draw_letter_normal(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);
|
||||
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);
|
||||
static void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * clip_area, const lv_font_t * font_p,
|
||||
uint32_t letter,
|
||||
lv_color_t color, lv_opa_t opa);
|
||||
static void draw_letter_normal(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);
|
||||
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);
|
||||
|
||||
|
||||
static uint8_t hex_char_to_num(char hex);
|
||||
@@ -49,8 +52,9 @@ static const uint8_t bpp2_opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping w
|
||||
static const uint8_t bpp4_opa_table[16] = {0, 17, 34, 51, /*Opacity mapping with bpp = 4*/
|
||||
68, 85, 102, 119,
|
||||
136, 153, 170, 187,
|
||||
204, 221, 238, 255};
|
||||
/*clang-format on*/
|
||||
204, 221, 238, 255
|
||||
};
|
||||
/*clang-format on*/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@@ -87,7 +91,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab
|
||||
int32_t w;
|
||||
|
||||
/*No need to waste processor time if string is empty*/
|
||||
if (txt[0] == '\0') return;
|
||||
if(txt[0] == '\0') return;
|
||||
|
||||
lv_area_t clipped_area;
|
||||
bool clip_ok = lv_area_intersect(&clipped_area, coords, mask);
|
||||
@@ -97,11 +101,12 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab
|
||||
if((dsc->flag & LV_TXT_FLAG_EXPAND) == 0) {
|
||||
/*Normally use the label's width as width*/
|
||||
w = lv_area_get_width(coords);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/*If EXAPND is enabled then not limit the text's width to the object's width*/
|
||||
lv_point_t p;
|
||||
lv_txt_get_size(&p, txt, dsc->font, dsc->letter_space, dsc->line_space, LV_COORD_MAX,
|
||||
dsc->flag);
|
||||
dsc->flag);
|
||||
w = p.x;
|
||||
}
|
||||
|
||||
@@ -209,10 +214,10 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab
|
||||
cmd_state = CMD_STATE_WAIT;
|
||||
i = 0;
|
||||
#if LV_USE_BIDI
|
||||
char *bidi_txt = lv_mem_buf_get(line_end - line_start + 1);
|
||||
char * bidi_txt = lv_mem_buf_get(line_end - line_start + 1);
|
||||
lv_bidi_process_paragraph(txt + line_start, bidi_txt, line_end - line_start, dsc->bidi_dir, NULL, 0);
|
||||
#else
|
||||
const char *bidi_txt = txt + line_start;
|
||||
const char * bidi_txt = txt + line_start;
|
||||
#endif
|
||||
|
||||
while(i < line_end - line_start) {
|
||||
@@ -237,9 +242,11 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab
|
||||
par_start = i;
|
||||
cmd_state = CMD_STATE_PAR;
|
||||
continue;
|
||||
} else if(cmd_state == CMD_STATE_PAR) { /*Other start char in parameter escaped cmd. char */
|
||||
}
|
||||
else if(cmd_state == CMD_STATE_PAR) { /*Other start char in parameter escaped cmd. char */
|
||||
cmd_state = CMD_STATE_WAIT;
|
||||
} else if(cmd_state == CMD_STATE_IN) { /*Command end */
|
||||
}
|
||||
else if(cmd_state == CMD_STATE_IN) { /*Command end */
|
||||
cmd_state = CMD_STATE_WAIT;
|
||||
continue;
|
||||
}
|
||||
@@ -258,7 +265,8 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab
|
||||
g = (hex_char_to_num(buf[2]) << 4) + hex_char_to_num(buf[3]);
|
||||
b = (hex_char_to_num(buf[4]) << 4) + hex_char_to_num(buf[5]);
|
||||
recolor = lv_color_make(r, g, b);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
recolor.full = dsc->color.full;
|
||||
}
|
||||
cmd_state = CMD_STATE_IN; /*After the parameter the text is in the command*/
|
||||
@@ -323,7 +331,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab
|
||||
/*Align to middle*/
|
||||
if(dsc->flag & LV_TXT_FLAG_CENTER) {
|
||||
line_width =
|
||||
lv_txt_get_width(&txt[line_start], line_end - line_start, font, dsc->letter_space, dsc->flag);
|
||||
lv_txt_get_width(&txt[line_start], line_end - line_start, font, dsc->letter_space, dsc->flag);
|
||||
|
||||
pos.x += (lv_area_get_width(coords) - line_width) / 2;
|
||||
|
||||
@@ -331,7 +339,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab
|
||||
/*Align to the right*/
|
||||
else if(dsc->flag & LV_TXT_FLAG_RIGHT) {
|
||||
line_width =
|
||||
lv_txt_get_width(&txt[line_start], line_end - line_start, font, dsc->letter_space, dsc->flag);
|
||||
lv_txt_get_width(&txt[line_start], line_end - line_start, font, dsc->letter_space, dsc->flag);
|
||||
pos.x += lv_area_get_width(coords) - line_width;
|
||||
}
|
||||
|
||||
@@ -358,8 +366,9 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab
|
||||
* @param color color of letter
|
||||
* @param opa opacity of letter (0..255)
|
||||
*/
|
||||
static void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * clip_area, const lv_font_t * font_p, uint32_t letter,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
static void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * clip_area, const lv_font_t * font_p,
|
||||
uint32_t letter,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
if(opa < LV_OPA_MIN) return;
|
||||
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
|
||||
@@ -385,9 +394,9 @@ static void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * clip_area
|
||||
|
||||
/*If the letter is completely out of mask don't draw it */
|
||||
if(pos_x + g.box_w < clip_area->x1 ||
|
||||
pos_x > clip_area->x2 ||
|
||||
pos_y + g.box_h < clip_area->y1 ||
|
||||
pos_y > clip_area->y2) return;
|
||||
pos_x > clip_area->x2 ||
|
||||
pos_y + g.box_h < clip_area->y1 ||
|
||||
pos_y > clip_area->y2) return;
|
||||
|
||||
|
||||
const uint8_t * map_p = lv_font_get_glyph_bitmap(font_p, letter);
|
||||
@@ -398,13 +407,15 @@ static void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * clip_area
|
||||
|
||||
if(font_p->subpx) {
|
||||
draw_letter_subpx(pos_x, pos_y, &g, clip_area, map_p, color, opa);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
draw_letter_normal(pos_x, pos_y, &g, clip_area, map_p, color, opa);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void draw_letter_normal(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)
|
||||
static void draw_letter_normal(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;
|
||||
@@ -414,25 +425,25 @@ static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph
|
||||
if(bpp == 3) bpp = 4;
|
||||
|
||||
switch(bpp) {
|
||||
case 1:
|
||||
bpp_opa_table = bpp1_opa_table;
|
||||
bitmask_init = 0x80;
|
||||
break;
|
||||
case 2:
|
||||
bpp_opa_table = bpp2_opa_table;
|
||||
bitmask_init = 0xC0;
|
||||
break;
|
||||
case 4:
|
||||
bpp_opa_table = bpp4_opa_table;
|
||||
bitmask_init = 0xF0;
|
||||
break;
|
||||
case 8:
|
||||
bpp_opa_table = NULL;
|
||||
bitmask_init = 0xFF;
|
||||
break; /*No opa table, pixel value will be used directly*/
|
||||
default:
|
||||
LV_LOG_WARN("lv_draw_letter: invalid bpp not found");
|
||||
return; /*Invalid bpp. Can't render the letter*/
|
||||
case 1:
|
||||
bpp_opa_table = bpp1_opa_table;
|
||||
bitmask_init = 0x80;
|
||||
break;
|
||||
case 2:
|
||||
bpp_opa_table = bpp2_opa_table;
|
||||
bitmask_init = 0xC0;
|
||||
break;
|
||||
case 4:
|
||||
bpp_opa_table = bpp4_opa_table;
|
||||
bitmask_init = 0xF0;
|
||||
break;
|
||||
case 8:
|
||||
bpp_opa_table = NULL;
|
||||
bitmask_init = 0xFF;
|
||||
break; /*No opa table, pixel value will be used directly*/
|
||||
default:
|
||||
LV_LOG_WARN("lv_draw_letter: invalid bpp not found");
|
||||
return; /*Invalid bpp. Can't render the letter*/
|
||||
}
|
||||
|
||||
|
||||
@@ -482,14 +493,16 @@ static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph
|
||||
if(letter_px != 0) {
|
||||
if(opa == LV_OPA_COVER) {
|
||||
px_opa = bpp == 8 ? letter_px : bpp_opa_table[letter_px];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
px_opa = bpp == 8 ? (uint32_t)((uint32_t)letter_px * opa) >> 8
|
||||
: (uint32_t)((uint32_t)bpp_opa_table[letter_px] * opa) >> 8;
|
||||
: (uint32_t)((uint32_t)bpp_opa_table[letter_px] * opa) >> 8;
|
||||
}
|
||||
|
||||
mask_buf[mask_p] = px_opa;
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
mask_buf[mask_p] = 0;
|
||||
}
|
||||
|
||||
@@ -497,7 +510,8 @@ static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph
|
||||
if(col_bit < 8 - bpp) {
|
||||
col_bit += bpp;
|
||||
bitmask = bitmask >> bpp;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
col_bit = 0;
|
||||
bitmask = bitmask_init;
|
||||
map_p++;
|
||||
@@ -509,7 +523,8 @@ static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph
|
||||
|
||||
/*Apply masks if any*/
|
||||
if(other_mask_cnt) {
|
||||
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf + mask_p_start, fill_area.x1, fill_area.y2, lv_area_get_width(&fill_area));
|
||||
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf + mask_p_start, fill_area.x1, fill_area.y2,
|
||||
lv_area_get_width(&fill_area));
|
||||
if(mask_res == LV_DRAW_MASK_RES_FULL_TRANSP) {
|
||||
memset(mask_buf + mask_p_start, 0x00, lv_area_get_width(&fill_area));
|
||||
}
|
||||
@@ -517,10 +532,11 @@ static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph
|
||||
|
||||
if((uint32_t) mask_p + (row_end - row_start) < mask_buf_size) {
|
||||
fill_area.y2 ++;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
lv_blend_fill(clip_area, &fill_area,
|
||||
color, mask_buf, LV_DRAW_MASK_RES_CHANGED, opa,
|
||||
LV_BLEND_MODE_NORMAL);
|
||||
color, mask_buf, LV_DRAW_MASK_RES_CHANGED, opa,
|
||||
LV_BLEND_MODE_NORMAL);
|
||||
|
||||
fill_area.y1 = fill_area.y2 + 1;
|
||||
fill_area.y2 = fill_area.y1;
|
||||
@@ -537,15 +553,16 @@ static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph
|
||||
if(fill_area.y1 != fill_area.y2) {
|
||||
fill_area.y2--;
|
||||
lv_blend_fill(clip_area, &fill_area,
|
||||
color, mask_buf, LV_DRAW_MASK_RES_CHANGED, opa,
|
||||
LV_BLEND_MODE_NORMAL);
|
||||
color, mask_buf, LV_DRAW_MASK_RES_CHANGED, opa,
|
||||
LV_BLEND_MODE_NORMAL);
|
||||
mask_p = 0;
|
||||
}
|
||||
|
||||
lv_mem_buf_release(mask_buf);
|
||||
}
|
||||
|
||||
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)
|
||||
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;
|
||||
uint32_t bitmask_init;
|
||||
@@ -554,25 +571,25 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
|
||||
if(bpp == 3) bpp = 4;
|
||||
|
||||
switch(bpp) {
|
||||
case 1:
|
||||
bpp_opa_table = bpp1_opa_table;
|
||||
bitmask_init = 0x80;
|
||||
break;
|
||||
case 2:
|
||||
bpp_opa_table = bpp2_opa_table;
|
||||
bitmask_init = 0xC0;
|
||||
break;
|
||||
case 4:
|
||||
bpp_opa_table = bpp4_opa_table;
|
||||
bitmask_init = 0xF0;
|
||||
break;
|
||||
case 8:
|
||||
bpp_opa_table = NULL;
|
||||
bitmask_init = 0xFF;
|
||||
break; /*No opa table, pixel value will be used directly*/
|
||||
default:
|
||||
LV_LOG_WARN("lv_draw_letter: invalid bpp not found");
|
||||
return; /*Invalid bpp. Can't render the letter*/
|
||||
case 1:
|
||||
bpp_opa_table = bpp1_opa_table;
|
||||
bitmask_init = 0x80;
|
||||
break;
|
||||
case 2:
|
||||
bpp_opa_table = bpp2_opa_table;
|
||||
bitmask_init = 0xC0;
|
||||
break;
|
||||
case 4:
|
||||
bpp_opa_table = bpp4_opa_table;
|
||||
bitmask_init = 0xF0;
|
||||
break;
|
||||
case 8:
|
||||
bpp_opa_table = NULL;
|
||||
bitmask_init = 0xFF;
|
||||
break; /*No opa table, pixel value will be used directly*/
|
||||
default:
|
||||
LV_LOG_WARN("lv_draw_letter: invalid bpp not found");
|
||||
return; /*Invalid bpp. Can't render the letter*/
|
||||
}
|
||||
|
||||
int32_t col, row;
|
||||
@@ -644,11 +661,13 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
|
||||
if(letter_px != 0) {
|
||||
if(opa == LV_OPA_COVER) {
|
||||
px_opa = bpp == 8 ? letter_px : bpp_opa_table[letter_px];
|
||||
} else {
|
||||
px_opa = bpp == 8 ? (uint32_t)((uint32_t)letter_px * opa) >> 8
|
||||
: (uint32_t)((uint32_t)bpp_opa_table[letter_px] * opa) >> 8;
|
||||
}
|
||||
} else {
|
||||
else {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -660,11 +679,12 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
|
||||
|
||||
lv_color_t res_color;
|
||||
#if LV_COLOR_16_SWAP == 0
|
||||
uint8_t bg_rgb[3] = {vdb_buf_tmp->ch.red, vdb_buf_tmp->ch.green, vdb_buf_tmp->ch.blue};
|
||||
uint8_t bg_rgb[3] = {vdb_buf_tmp->ch.red, vdb_buf_tmp->ch.green, vdb_buf_tmp->ch.blue};
|
||||
#else
|
||||
uint8_t bg_rgb[3] = {vdb_buf_tmp->ch.red,
|
||||
(vdb_buf_tmp->ch.green_h << 3) + vdb_buf_tmp->ch.green_l,
|
||||
vdb_buf_tmp->ch.blue};
|
||||
uint8_t bg_rgb[3] = {vdb_buf_tmp->ch.red,
|
||||
(vdb_buf_tmp->ch.green_h << 3) + vdb_buf_tmp->ch.green_l,
|
||||
vdb_buf_tmp->ch.blue
|
||||
};
|
||||
#endif
|
||||
|
||||
#if LV_FONT_SUBPX_BGR
|
||||
@@ -676,11 +696,11 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
|
||||
#endif
|
||||
|
||||
#if LV_COLOR_16_SWAP == 0
|
||||
res_color.ch.green = (uint32_t)((uint32_t)txt_rgb[1] * font_rgb[1] + (bg_rgb[1] * (255 - font_rgb[1]))) >> 8;
|
||||
res_color.ch.green = (uint32_t)((uint32_t)txt_rgb[1] * font_rgb[1] + (bg_rgb[1] * (255 - font_rgb[1]))) >> 8;
|
||||
#else
|
||||
uint8_t green = (uint32_t)((uint32_t)txt_rgb[1] * font_rgb[1] + (bg_rgb[1] * (255 - font_rgb[1]))) >> 8;
|
||||
res_color.ch.green_h = green >> 3;
|
||||
res_color.ch.green_l = green & 0x7;
|
||||
uint8_t green = (uint32_t)((uint32_t)txt_rgb[1] * font_rgb[1] + (bg_rgb[1] * (255 - font_rgb[1]))) >> 8;
|
||||
res_color.ch.green_h = green >> 3;
|
||||
res_color.ch.green_l = green & 0x7;
|
||||
#endif
|
||||
|
||||
if(font_rgb[0] == 0 && font_rgb[1] == 0 && font_rgb[2] == 0) mask_buf[mask_p] = LV_OPA_TRANSP;
|
||||
@@ -696,7 +716,8 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
|
||||
if(col_bit < 8 - bpp) {
|
||||
col_bit += bpp;
|
||||
bitmask = bitmask >> bpp;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
col_bit = 0;
|
||||
bitmask = bitmask_init;
|
||||
map_p++;
|
||||
@@ -705,7 +726,8 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
|
||||
|
||||
/*Apply masks if any*/
|
||||
if(other_mask_cnt) {
|
||||
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf + mask_p_start, map_area.x1, map_area.y2, lv_area_get_width(&map_area));
|
||||
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf + mask_p_start, map_area.x1, map_area.y2,
|
||||
lv_area_get_width(&map_area));
|
||||
if(mask_res == LV_DRAW_MASK_RES_FULL_TRANSP) {
|
||||
memset(mask_buf + mask_p_start, 0x00, lv_area_get_width(&map_area));
|
||||
}
|
||||
@@ -713,7 +735,8 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
|
||||
|
||||
if((uint32_t) mask_p + (row_end - row_start) < mask_buf_size) {
|
||||
map_area.y2 ++;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
lv_blend_map(clip_area, &map_area, color_buf, mask_buf, LV_DRAW_MASK_RES_CHANGED, opa, LV_BLEND_MODE_NORMAL);
|
||||
|
||||
map_area.y1 = map_area.y2 + 1;
|
||||
@@ -752,17 +775,32 @@ static uint8_t hex_char_to_num(char hex)
|
||||
|
||||
if(hex >= '0' && hex <= '9') {
|
||||
result = hex - '0';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if(hex >= 'a') hex -= 'a' - 'A'; /*Convert to upper case*/
|
||||
|
||||
switch(hex) {
|
||||
case 'A': result = 10; break;
|
||||
case 'B': result = 11; break;
|
||||
case 'C': result = 12; break;
|
||||
case 'D': result = 13; break;
|
||||
case 'E': result = 14; break;
|
||||
case 'F': result = 15; break;
|
||||
default: result = 0; break;
|
||||
case 'A':
|
||||
result = 10;
|
||||
break;
|
||||
case 'B':
|
||||
result = 11;
|
||||
break;
|
||||
case 'C':
|
||||
result = 12;
|
||||
break;
|
||||
case 'D':
|
||||
result = 13;
|
||||
break;
|
||||
case 'E':
|
||||
result = 14;
|
||||
break;
|
||||
case 'F':
|
||||
result = 15;
|
||||
break;
|
||||
default:
|
||||
result = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ typedef struct {
|
||||
lv_txt_flag_t flag;
|
||||
lv_text_decor_t decor;
|
||||
lv_blend_mode_t blend_mode;
|
||||
}lv_draw_label_dsc_t;
|
||||
} lv_draw_label_dsc_t;
|
||||
|
||||
/** Store some info to speed up drawing of very large texts
|
||||
* It takes a lot of time to get the first visible character because
|
||||
@@ -58,7 +58,7 @@ typedef struct {
|
||||
/** The 'y1' coordinate of the label when the hint was saved.
|
||||
* Used to invalidate the hint if the label has moved too much. */
|
||||
int32_t coord_y;
|
||||
}lv_draw_label_hint_t;
|
||||
} lv_draw_label_hint_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
|
||||
+89
-71
@@ -24,9 +24,12 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void draw_line_skew(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_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 void draw_line_skew(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_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
|
||||
@@ -56,7 +59,8 @@ void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc)
|
||||
* @param style pointer to a line's style
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
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)
|
||||
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;
|
||||
@@ -64,10 +68,10 @@ void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv
|
||||
if(point1->x == point2->x && point1->y == point2->y) return;
|
||||
|
||||
lv_area_t clip_line;
|
||||
clip_line.x1 = LV_MATH_MIN(point1->x, point2->x) - dsc->width/2;
|
||||
clip_line.x2 = LV_MATH_MAX(point1->x, point2->x) + dsc->width/2;
|
||||
clip_line.y1 = LV_MATH_MIN(point1->y, point2->y) - dsc->width/2;
|
||||
clip_line.y2 = LV_MATH_MAX(point1->y, point2->y) + dsc->width/2;
|
||||
clip_line.x1 = LV_MATH_MIN(point1->x, point2->x) - dsc->width / 2;
|
||||
clip_line.x2 = LV_MATH_MAX(point1->x, point2->x) + dsc->width / 2;
|
||||
clip_line.y1 = LV_MATH_MIN(point1->y, point2->y) - dsc->width / 2;
|
||||
clip_line.y2 = LV_MATH_MAX(point1->y, point2->y) + dsc->width / 2;
|
||||
|
||||
bool is_common;
|
||||
is_common = lv_area_intersect(&clip_line, &clip_line, clip);
|
||||
@@ -111,7 +115,8 @@ void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
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_hor(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip,
|
||||
lv_draw_line_dsc_t * dsc)
|
||||
{
|
||||
lv_opa_t opa = dsc->opa;
|
||||
|
||||
@@ -139,8 +144,8 @@ static void draw_line_hor(const lv_point_t * point1, const lv_point_t * point2,
|
||||
/*If there is no mask then simply draw a rectangle*/
|
||||
if(simple_mode) {
|
||||
lv_blend_fill(clip, &draw_area,
|
||||
dsc->color, NULL, LV_DRAW_MASK_RES_FULL_COVER,opa,
|
||||
LV_BLEND_MODE_NORMAL);
|
||||
dsc->color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa,
|
||||
LV_BLEND_MODE_NORMAL);
|
||||
}
|
||||
/*If there other mask apply it*/
|
||||
else {
|
||||
@@ -170,42 +175,45 @@ static void draw_line_hor(const lv_point_t * point1, const lv_point_t * point2,
|
||||
lv_opa_t * mask_buf = lv_mem_buf_get(draw_area_w);
|
||||
int32_t h;
|
||||
for(h = draw_area.y1; h <= draw_area.y2; h++) {
|
||||
memset(mask_buf, LV_OPA_COVER, draw_area_w);
|
||||
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
|
||||
memset(mask_buf, LV_OPA_COVER, draw_area_w);
|
||||
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
|
||||
|
||||
if(dashed) {
|
||||
if(mask_res != LV_DRAW_MASK_RES_FULL_TRANSP) {
|
||||
if(dashed) {
|
||||
if(mask_res != LV_DRAW_MASK_RES_FULL_TRANSP) {
|
||||
lv_style_int_t dash_cnt = dash_start;
|
||||
uint32_t i;
|
||||
for(i = 0; i < draw_area_w; i++, dash_cnt++) {
|
||||
if(dash_cnt <= dsc->dash_width) {
|
||||
int16_t diff = dsc->dash_width - dash_cnt;
|
||||
i += diff;
|
||||
dash_cnt += diff;
|
||||
} else if(dash_cnt >= dsc->dash_gap + dsc->dash_width) {
|
||||
dash_cnt = 0;
|
||||
} else {
|
||||
mask_buf[i] = 0x00;
|
||||
}
|
||||
}
|
||||
uint32_t i;
|
||||
for(i = 0; i < draw_area_w; i++, dash_cnt++) {
|
||||
if(dash_cnt <= dsc->dash_width) {
|
||||
int16_t diff = dsc->dash_width - dash_cnt;
|
||||
i += diff;
|
||||
dash_cnt += diff;
|
||||
}
|
||||
else if(dash_cnt >= dsc->dash_gap + dsc->dash_width) {
|
||||
dash_cnt = 0;
|
||||
}
|
||||
else {
|
||||
mask_buf[i] = 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
mask_res = LV_DRAW_MASK_RES_CHANGED;
|
||||
}
|
||||
}
|
||||
mask_res = LV_DRAW_MASK_RES_CHANGED;
|
||||
}
|
||||
}
|
||||
|
||||
lv_blend_fill(clip, &fill_area,
|
||||
dsc->color, mask_buf, mask_res, dsc->opa,
|
||||
dsc->blend_mode);
|
||||
lv_blend_fill(clip, &fill_area,
|
||||
dsc->color, mask_buf, mask_res, dsc->opa,
|
||||
dsc->blend_mode);
|
||||
|
||||
fill_area.y1++;
|
||||
fill_area.y2++;
|
||||
}
|
||||
fill_area.y1++;
|
||||
fill_area.y2++;
|
||||
}
|
||||
lv_mem_buf_release(mask_buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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 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)
|
||||
{
|
||||
lv_opa_t opa = dsc->opa;
|
||||
|
||||
@@ -233,8 +241,8 @@ static void draw_line_ver(const lv_point_t * point1, const lv_point_t * point2,
|
||||
/*If there is no mask then simply draw a rectangle*/
|
||||
if(simple_mode) {
|
||||
lv_blend_fill(clip, &draw_area,
|
||||
dsc->color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa,
|
||||
dsc->blend_mode);
|
||||
dsc->color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa,
|
||||
dsc->blend_mode);
|
||||
}
|
||||
/*If there other mask apply it*/
|
||||
else {
|
||||
@@ -266,35 +274,36 @@ static void draw_line_ver(const lv_point_t * point1, const lv_point_t * point2,
|
||||
|
||||
int32_t h;
|
||||
for(h = draw_area.y1; h <= draw_area.y2; h++) {
|
||||
memset(mask_buf, LV_OPA_COVER, draw_area_w);
|
||||
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
|
||||
memset(mask_buf, LV_OPA_COVER, draw_area_w);
|
||||
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
|
||||
|
||||
if(dashed) {
|
||||
if(mask_res != LV_DRAW_MASK_RES_FULL_TRANSP) {
|
||||
if(dash_cnt > dsc->dash_width) {
|
||||
mask_res = LV_DRAW_MASK_RES_FULL_TRANSP;
|
||||
}
|
||||
if(dashed) {
|
||||
if(mask_res != LV_DRAW_MASK_RES_FULL_TRANSP) {
|
||||
if(dash_cnt > dsc->dash_width) {
|
||||
mask_res = LV_DRAW_MASK_RES_FULL_TRANSP;
|
||||
}
|
||||
|
||||
if(dash_cnt >= dsc->dash_gap + dsc->dash_width) {
|
||||
dash_cnt = 0;
|
||||
}
|
||||
}
|
||||
dash_cnt ++;
|
||||
}
|
||||
if(dash_cnt >= dsc->dash_gap + dsc->dash_width) {
|
||||
dash_cnt = 0;
|
||||
}
|
||||
}
|
||||
dash_cnt ++;
|
||||
}
|
||||
|
||||
lv_blend_fill(clip, &fill_area,
|
||||
dsc->color, mask_buf, mask_res, dsc->opa,
|
||||
LV_BLEND_MODE_NORMAL);
|
||||
lv_blend_fill(clip, &fill_area,
|
||||
dsc->color, mask_buf, mask_res, dsc->opa,
|
||||
LV_BLEND_MODE_NORMAL);
|
||||
|
||||
fill_area.y1++;
|
||||
fill_area.y2++;
|
||||
}
|
||||
fill_area.y1++;
|
||||
fill_area.y2++;
|
||||
}
|
||||
lv_mem_buf_release(mask_buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void draw_line_skew(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_skew(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip,
|
||||
lv_draw_line_dsc_t * dsc)
|
||||
{
|
||||
lv_opa_t opa = dsc->opa;
|
||||
|
||||
@@ -306,7 +315,8 @@ static void draw_line_skew(const lv_point_t * point1, const lv_point_t * point2,
|
||||
p2.y = point2->y;
|
||||
p1.x = point1->x;
|
||||
p2.x = point2->x;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
p1.y = point2->y;
|
||||
p2.y = point1->y;
|
||||
p1.x = point2->x;
|
||||
@@ -353,20 +363,28 @@ static void draw_line_skew(const lv_point_t * point1, const lv_point_t * point2,
|
||||
|
||||
if(flat) {
|
||||
if(xdiff > 0) {
|
||||
lv_draw_mask_line_points_init(&mask_left_param, p1.x, p1.y - w_half0, p2.x, p2.y - w_half0, LV_DRAW_MASK_LINE_SIDE_LEFT);
|
||||
lv_draw_mask_line_points_init(&mask_right_param, p1.x, p1.y + w_half1, p2.x, p2.y + w_half1, LV_DRAW_MASK_LINE_SIDE_RIGHT);
|
||||
} else {
|
||||
lv_draw_mask_line_points_init(&mask_left_param, p1.x, p1.y + w_half1, p2.x, p2.y + w_half1, LV_DRAW_MASK_LINE_SIDE_LEFT);
|
||||
lv_draw_mask_line_points_init(&mask_right_param, p1.x, p1.y - w_half0, p2.x, p2.y - w_half0, LV_DRAW_MASK_LINE_SIDE_RIGHT);
|
||||
lv_draw_mask_line_points_init(&mask_left_param, p1.x, p1.y - w_half0, p2.x, p2.y - w_half0,
|
||||
LV_DRAW_MASK_LINE_SIDE_LEFT);
|
||||
lv_draw_mask_line_points_init(&mask_right_param, p1.x, p1.y + w_half1, p2.x, p2.y + w_half1,
|
||||
LV_DRAW_MASK_LINE_SIDE_RIGHT);
|
||||
}
|
||||
} else {
|
||||
lv_draw_mask_line_points_init(&mask_left_param, p1.x + w_half1, p1.y, p2.x + w_half1, p2.y, LV_DRAW_MASK_LINE_SIDE_LEFT);
|
||||
lv_draw_mask_line_points_init(&mask_right_param, p1.x - w_half0, p1.y, p2.x - w_half0, p2.y, LV_DRAW_MASK_LINE_SIDE_RIGHT);
|
||||
else {
|
||||
lv_draw_mask_line_points_init(&mask_left_param, p1.x, p1.y + w_half1, p2.x, p2.y + w_half1,
|
||||
LV_DRAW_MASK_LINE_SIDE_LEFT);
|
||||
lv_draw_mask_line_points_init(&mask_right_param, p1.x, p1.y - w_half0, p2.x, p2.y - w_half0,
|
||||
LV_DRAW_MASK_LINE_SIDE_RIGHT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
lv_draw_mask_line_points_init(&mask_left_param, p1.x + w_half1, p1.y, p2.x + w_half1, p2.y,
|
||||
LV_DRAW_MASK_LINE_SIDE_LEFT);
|
||||
lv_draw_mask_line_points_init(&mask_right_param, p1.x - w_half0, p1.y, p2.x - w_half0, p2.y,
|
||||
LV_DRAW_MASK_LINE_SIDE_RIGHT);
|
||||
}
|
||||
|
||||
/*Use the normal vector for the endings*/
|
||||
lv_draw_mask_line_points_init(&mask_top_param, p1.x, p1.y, p1.x - ydiff, p1.y + xdiff, LV_DRAW_MASK_LINE_SIDE_BOTTOM);
|
||||
lv_draw_mask_line_points_init(&mask_bottom_param, p2.x, p2.y,p2.x - ydiff, p2.y + xdiff, LV_DRAW_MASK_LINE_SIDE_TOP);
|
||||
lv_draw_mask_line_points_init(&mask_bottom_param, p2.x, p2.y, p2.x - ydiff, p2.y + xdiff, LV_DRAW_MASK_LINE_SIDE_TOP);
|
||||
|
||||
int16_t mask_left_id = lv_draw_mask_add(&mask_left_param, NULL);
|
||||
int16_t mask_right_id = lv_draw_mask_add(&mask_right_param, NULL);
|
||||
@@ -401,8 +419,8 @@ static void draw_line_skew(const lv_point_t * point1, const lv_point_t * point2,
|
||||
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
|
||||
|
||||
lv_blend_fill(clip, &fill_area,
|
||||
dsc->color, mask_buf, mask_res, opa,
|
||||
dsc->blend_mode);
|
||||
dsc->color, mask_buf, mask_res, opa,
|
||||
dsc->blend_mode);
|
||||
|
||||
fill_area.y1++;
|
||||
fill_area.y2++;
|
||||
|
||||
@@ -28,10 +28,10 @@ typedef struct {
|
||||
lv_style_int_t dash_width;
|
||||
lv_style_int_t dash_gap;
|
||||
lv_opa_t opa;
|
||||
lv_blend_mode_t blend_mode :2;
|
||||
uint8_t round_start :1;
|
||||
uint8_t round_end :1;
|
||||
}lv_draw_line_dsc_t;
|
||||
lv_blend_mode_t blend_mode : 2;
|
||||
uint8_t round_start : 1;
|
||||
uint8_t round_end : 1;
|
||||
} lv_draw_line_dsc_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
@@ -45,7 +45,8 @@ typedef struct {
|
||||
* @param style pointer to a line's style
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * mask, lv_draw_line_dsc_t * dsc);
|
||||
void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * mask,
|
||||
lv_draw_line_dsc_t * dsc);
|
||||
|
||||
void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc);
|
||||
|
||||
|
||||
+133
-91
File diff suppressed because it is too large
Load Diff
+25
-20
@@ -53,14 +53,15 @@ enum {
|
||||
LV_DRAW_MASK_LINE_SIDE_BOTTOM,
|
||||
};
|
||||
|
||||
typedef lv_draw_mask_res_t (*lv_draw_mask_cb_t)(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len, void * p);
|
||||
typedef lv_draw_mask_res_t (*lv_draw_mask_cb_t)(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len,
|
||||
void * p);
|
||||
|
||||
typedef uint8_t lv_draw_mask_line_side_t;
|
||||
|
||||
typedef struct {
|
||||
lv_draw_mask_cb_t cb;
|
||||
lv_draw_mask_type_t type;
|
||||
}lv_draw_mask_common_dsc_t;
|
||||
} lv_draw_mask_common_dsc_t;
|
||||
|
||||
typedef struct {
|
||||
/*The first element must be the common descriptor*/
|
||||
@@ -74,8 +75,8 @@ typedef struct {
|
||||
lv_point_t p2;
|
||||
|
||||
/*Which side to keep?*/
|
||||
lv_draw_mask_line_side_t side :2;
|
||||
}cfg;
|
||||
lv_draw_mask_line_side_t side : 2;
|
||||
} cfg;
|
||||
|
||||
/*A point of the line*/
|
||||
lv_point_t origo;
|
||||
@@ -93,13 +94,13 @@ typedef struct {
|
||||
int32_t spx;
|
||||
|
||||
/*1: It's a flat line? (Near to horizontal)*/
|
||||
uint8_t flat :1;
|
||||
uint8_t flat : 1;
|
||||
|
||||
|
||||
/* Invert the mask. The default is: Keep the left part.
|
||||
* It is used to select left/right/top/bottom*/
|
||||
uint8_t inv:1;
|
||||
}lv_draw_mask_line_param_t;
|
||||
uint8_t inv: 1;
|
||||
} lv_draw_mask_line_param_t;
|
||||
|
||||
typedef struct {
|
||||
/*The first element must be the common descriptor*/
|
||||
@@ -109,12 +110,12 @@ typedef struct {
|
||||
lv_point_t vertex_p;
|
||||
lv_coord_t start_angle;
|
||||
lv_coord_t end_angle;
|
||||
}cfg;
|
||||
} cfg;
|
||||
|
||||
lv_draw_mask_line_param_t start_line;
|
||||
lv_draw_mask_line_param_t end_line;
|
||||
uint16_t delta_deg;
|
||||
}lv_draw_mask_angle_param_t;
|
||||
} lv_draw_mask_angle_param_t;
|
||||
|
||||
typedef struct {
|
||||
/*The first element must be the common descriptor*/
|
||||
@@ -124,10 +125,10 @@ typedef struct {
|
||||
lv_area_t rect;
|
||||
lv_coord_t radius;
|
||||
/* Invert the mask. 0: Keep the pixels inside.*/
|
||||
uint8_t outer:1;
|
||||
}cfg;
|
||||
uint8_t outer: 1;
|
||||
} cfg;
|
||||
|
||||
}lv_draw_mask_radius_param_t;
|
||||
} lv_draw_mask_radius_param_t;
|
||||
|
||||
typedef struct {
|
||||
/*The first element must be the common descriptor*/
|
||||
@@ -139,9 +140,9 @@ typedef struct {
|
||||
lv_coord_t y_bottom;
|
||||
lv_opa_t opa_top;
|
||||
lv_opa_t opa_bottom;
|
||||
}cfg;
|
||||
} cfg;
|
||||
|
||||
}lv_draw_mask_fade_param_t;
|
||||
} lv_draw_mask_fade_param_t;
|
||||
|
||||
typedef struct _lv_draw_mask_map_param_t {
|
||||
/*The first element must be the common descriptor*/
|
||||
@@ -150,8 +151,8 @@ typedef struct _lv_draw_mask_map_param_t {
|
||||
struct {
|
||||
lv_area_t coords;
|
||||
const lv_opa_t * map;
|
||||
}cfg;
|
||||
}lv_draw_mask_map_param_t;
|
||||
} cfg;
|
||||
} lv_draw_mask_map_param_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
@@ -211,7 +212,8 @@ uint8_t lv_draw_mask_get_cnt(void);
|
||||
* With `LV_DRAW_MASK_LINE_SIDE_LEFT/RIGHT` and horizontal line all pixels are kept
|
||||
* With `LV_DRAW_MASK_LINE_SIDE_TOP/BOTTOM` and vertical line all pixels are kept
|
||||
*/
|
||||
void lv_draw_mask_line_points_init(lv_draw_mask_line_param_t * param, lv_coord_t p1x, lv_coord_t p1y, lv_coord_t p2x, lv_coord_t p2y, lv_draw_mask_line_side_t side);
|
||||
void lv_draw_mask_line_points_init(lv_draw_mask_line_param_t * param, lv_coord_t p1x, lv_coord_t p1y, lv_coord_t p2x,
|
||||
lv_coord_t p2y, lv_draw_mask_line_side_t side);
|
||||
|
||||
/**
|
||||
*Initialize a line mask from a point and an angle.
|
||||
@@ -223,7 +225,8 @@ void lv_draw_mask_line_points_init(lv_draw_mask_line_param_t * param, lv_coord_t
|
||||
* With `LV_DRAW_MASK_LINE_SIDE_LEFT/RIGHT` and horizontal line all pixels are kept
|
||||
* With `LV_DRAW_MASK_LINE_SIDE_TOP/BOTTOM` and vertical line all pixels are kept
|
||||
*/
|
||||
void lv_draw_mask_line_angle_init(lv_draw_mask_line_param_t * param, lv_coord_t p1x, lv_coord_t py, int16_t angle, lv_draw_mask_line_side_t side);
|
||||
void lv_draw_mask_line_angle_init(lv_draw_mask_line_param_t * param, lv_coord_t p1x, lv_coord_t py, int16_t angle,
|
||||
lv_draw_mask_line_side_t side);
|
||||
|
||||
/**
|
||||
* Initialize an angle mask.
|
||||
@@ -233,7 +236,8 @@ void lv_draw_mask_line_angle_init(lv_draw_mask_line_param_t * param, lv_coord_t
|
||||
* @param start_angle start angle in degrees. 0 deg on the right, 90 deg, on the bottom
|
||||
* @param end_angle end angle
|
||||
*/
|
||||
void lv_draw_mask_angle_init(lv_draw_mask_angle_param_t * param, lv_coord_t vertex_x, lv_coord_t vertex_y, lv_coord_t start_angle, lv_coord_t end_angle);
|
||||
void lv_draw_mask_angle_init(lv_draw_mask_angle_param_t * param, lv_coord_t vertex_x, lv_coord_t vertex_y,
|
||||
lv_coord_t start_angle, lv_coord_t end_angle);
|
||||
|
||||
/**
|
||||
* Initialize a fade mask.
|
||||
@@ -253,7 +257,8 @@ void lv_draw_mask_radius_init(lv_draw_mask_radius_param_t * param, const lv_area
|
||||
* @param opa_bottom opacity at the bottom
|
||||
* @param y_bottom at which coordinate reach `opa_bottom`.
|
||||
*/
|
||||
void lv_draw_mask_fade_init(lv_draw_mask_fade_param_t * param, lv_area_t * coords, lv_opa_t opa_top, lv_coord_t y_top, lv_opa_t opa_bottom, lv_coord_t y_bottom);
|
||||
void lv_draw_mask_fade_init(lv_draw_mask_fade_param_t * param, lv_area_t * coords, lv_opa_t opa_top, lv_coord_t y_top,
|
||||
lv_opa_t opa_bottom, lv_coord_t y_bottom);
|
||||
|
||||
/**
|
||||
* Initialize a map mask.
|
||||
|
||||
+87
-76
@@ -100,27 +100,27 @@ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect
|
||||
*/
|
||||
void lv_draw_px(const lv_point_t * point, const lv_area_t * clip_area, const lv_style_t * style)
|
||||
{
|
||||
// lv_opa_t opa = style->body.opa;
|
||||
// if(opa_scale != LV_OPA_COVER) opa = (opa * opa_scale) >> 8;
|
||||
//
|
||||
// if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
|
||||
//
|
||||
// lv_area_t fill_area;
|
||||
// fill_area.x1 = point->x;
|
||||
// fill_area.y1 = point->y;
|
||||
// fill_area.x2 = point->x;
|
||||
// fill_area.y2 = point->y;
|
||||
//
|
||||
// uint8_t mask_cnt = lv_draw_mask_get_cnt();
|
||||
//
|
||||
// if(mask_cnt == 0) {
|
||||
// lv_blend_fill(clip_area, &fill_area, style->body.main_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, style->body.blend_mode);
|
||||
// } else {
|
||||
// uint8_t mask_buf;
|
||||
// lv_draw_mask_res_t mask_res;
|
||||
// mask_res = lv_draw_mask_apply(&mask_buf, point->x, point->y, 1);
|
||||
// lv_blend_fill(clip_area, &fill_area, style->body.main_color, &mask_buf, mask_res, opa, style->body.blend_mode);
|
||||
// }
|
||||
// lv_opa_t opa = style->body.opa;
|
||||
// if(opa_scale != LV_OPA_COVER) opa = (opa * opa_scale) >> 8;
|
||||
//
|
||||
// if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
|
||||
//
|
||||
// lv_area_t fill_area;
|
||||
// fill_area.x1 = point->x;
|
||||
// fill_area.y1 = point->y;
|
||||
// fill_area.x2 = point->x;
|
||||
// fill_area.y2 = point->y;
|
||||
//
|
||||
// uint8_t mask_cnt = lv_draw_mask_get_cnt();
|
||||
//
|
||||
// if(mask_cnt == 0) {
|
||||
// lv_blend_fill(clip_area, &fill_area, style->body.main_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, style->body.blend_mode);
|
||||
// } else {
|
||||
// uint8_t mask_buf;
|
||||
// lv_draw_mask_res_t mask_res;
|
||||
// mask_res = lv_draw_mask_apply(&mask_buf, point->x, point->y, 1);
|
||||
// lv_blend_fill(clip_area, &fill_area, style->body.main_color, &mask_buf, mask_res, opa, style->body.blend_mode);
|
||||
// }
|
||||
}
|
||||
|
||||
/**********************
|
||||
@@ -188,8 +188,8 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
|
||||
/*Most simple case: just a plain rectangle*/
|
||||
if(simple_mode && rout == 0 && (dsc->bg_grad_dir == LV_GRAD_DIR_NONE)) {
|
||||
lv_blend_fill(clip, &coords_bg,
|
||||
dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa,
|
||||
dsc->bg_blend_mode);
|
||||
dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa,
|
||||
dsc->bg_blend_mode);
|
||||
}
|
||||
/*More complex case: there is a radius, gradient or other mask.*/
|
||||
else {
|
||||
@@ -226,7 +226,7 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
|
||||
|
||||
/*In not corner areas apply the mask only if required*/
|
||||
if(y > coords_bg.y1 + rout + 1 &&
|
||||
y < coords_bg.y2 - rout - 1) {
|
||||
y < coords_bg.y2 - rout - 1) {
|
||||
mask_res = LV_DRAW_MASK_RES_FULL_COVER;
|
||||
if(simple_mode == false) {
|
||||
memset(mask_buf, LV_OPA_COVER, draw_area_w);
|
||||
@@ -247,8 +247,8 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
|
||||
/* If there is not other mask and drawing the corner area split the drawing to corner and middle areas
|
||||
* because it the middle mask shuldn't be taken into account (therefore its faster)*/
|
||||
if(simple_mode &&
|
||||
(y < coords_bg.y1 + rout + 1 ||
|
||||
y > coords_bg.y2 - rout - 1)) {
|
||||
(y < coords_bg.y1 + rout + 1 ||
|
||||
y > coords_bg.y2 - rout - 1)) {
|
||||
|
||||
/*Left part*/
|
||||
lv_area_t fill_area2;
|
||||
@@ -258,7 +258,7 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
|
||||
fill_area2.y2 = fill_area.y2;
|
||||
|
||||
lv_blend_fill(clip, &fill_area2,
|
||||
grad_color, mask_buf, mask_res, opa, dsc->bg_blend_mode);
|
||||
grad_color, mask_buf, mask_res, opa, dsc->bg_blend_mode);
|
||||
|
||||
/*Right part*/
|
||||
fill_area2.x1 = coords_bg.x2 - rout + 1;
|
||||
@@ -267,16 +267,19 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
|
||||
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);
|
||||
} else {
|
||||
grad_color, mask_buf + mask_ofs, mask_res, opa, dsc->bg_blend_mode);
|
||||
}
|
||||
else {
|
||||
if(dsc->bg_grad_dir == LV_GRAD_DIR_HOR) {
|
||||
lv_blend_map(clip, &fill_area, grad_map, mask_buf, mask_res, opa, dsc->bg_blend_mode);
|
||||
} else if(dsc->bg_grad_dir == LV_GRAD_DIR_VER) {
|
||||
}
|
||||
else if(dsc->bg_grad_dir == LV_GRAD_DIR_VER) {
|
||||
lv_blend_fill(clip, &fill_area,
|
||||
grad_color,mask_buf, mask_res, opa, dsc->bg_blend_mode);
|
||||
} else if(other_mask_cnt != 0) {
|
||||
grad_color, mask_buf, mask_res, opa, dsc->bg_blend_mode);
|
||||
}
|
||||
else if(other_mask_cnt != 0) {
|
||||
lv_blend_fill(clip, &fill_area,
|
||||
grad_color,mask_buf, mask_res, opa, dsc->bg_blend_mode);
|
||||
grad_color, mask_buf, mask_res, opa, dsc->bg_blend_mode);
|
||||
}
|
||||
}
|
||||
fill_area.y1++;
|
||||
@@ -292,13 +295,13 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
|
||||
fill_area.y2 = coords_bg.y1 + rout;
|
||||
|
||||
lv_blend_fill(clip, &fill_area,
|
||||
dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->bg_blend_mode);
|
||||
dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->bg_blend_mode);
|
||||
|
||||
fill_area.y1 = coords_bg.y2 - rout;
|
||||
fill_area.y2 = coords_bg.y2;
|
||||
|
||||
lv_blend_fill(clip, &fill_area,
|
||||
dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->bg_blend_mode);
|
||||
dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->bg_blend_mode);
|
||||
|
||||
fill_area.x1 = coords_bg.x1;
|
||||
fill_area.x2 = coords_bg.x2;
|
||||
@@ -306,7 +309,7 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
|
||||
fill_area.y2 = coords_bg.y2 - rout - 1;
|
||||
|
||||
lv_blend_fill(clip, &fill_area,
|
||||
dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->bg_blend_mode);
|
||||
dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->bg_blend_mode);
|
||||
|
||||
}
|
||||
|
||||
@@ -448,7 +451,7 @@ static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
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);
|
||||
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;
|
||||
@@ -460,7 +463,7 @@ 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);
|
||||
|
||||
/*Draw the bottom horizontal line*/
|
||||
if(fill_area2.y2 > coords->y2 - dsc->border_width ) {
|
||||
if(fill_area2.y2 > coords->y2 - dsc->border_width) {
|
||||
fill_area2.x1 = coords->x1 + rout;
|
||||
fill_area2.x2 = coords->x2 - rout;
|
||||
|
||||
@@ -499,8 +502,8 @@ static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
fill_area.y1 = disp_area->y1 + draw_area.y1;
|
||||
fill_area.y2 = fill_area.y1;
|
||||
|
||||
if(dsc->border_side == LV_BORDER_SIDE_LEFT) fill_area.x2 = coords->x1 + corner_size;
|
||||
else if(dsc->border_side == LV_BORDER_SIDE_RIGHT) fill_area.x1 = coords->x2 - corner_size;
|
||||
if(dsc->border_side == LV_BORDER_SIDE_LEFT) fill_area.x2 = coords->x1 + corner_size;
|
||||
else if(dsc->border_side == LV_BORDER_SIDE_RIGHT) fill_area.x1 = coords->x2 - corner_size;
|
||||
|
||||
for(h = draw_area.y1; h <= draw_area.y2; h++) {
|
||||
if((dsc->border_side == LV_BORDER_SIDE_BOTTOM && fill_area.y1 < coords->y2 - corner_size - 1) ||
|
||||
@@ -513,7 +516,7 @@ static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
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_blend_fill( clip, &fill_area, color, mask_buf, mask_res, opa, blend_mode);
|
||||
lv_blend_fill(clip, &fill_area, color, mask_buf, mask_res, opa, blend_mode);
|
||||
fill_area.y1++;
|
||||
fill_area.y2++;
|
||||
|
||||
@@ -546,7 +549,7 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
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) {
|
||||
dsc->shadow_ofs_y == 0 && dsc->shadow_spread <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -659,7 +662,7 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED;
|
||||
|
||||
lv_blend_fill(clip, &a,
|
||||
dsc->shadow_color, mask_buf + first_px, mask_res, opa, dsc->shadow_blend_mode);
|
||||
dsc->shadow_color, mask_buf + first_px, mask_res, opa, dsc->shadow_blend_mode);
|
||||
a.y1++;
|
||||
a.y2++;
|
||||
sh_buf_tmp += corner_size;
|
||||
@@ -677,7 +680,7 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED;
|
||||
|
||||
lv_blend_fill(clip, &a,
|
||||
dsc->shadow_color, mask_buf + first_px, mask_res, opa, dsc->shadow_blend_mode);
|
||||
dsc->shadow_color, mask_buf + first_px, mask_res, opa, dsc->shadow_blend_mode);
|
||||
a.y1--;
|
||||
a.y2--;
|
||||
sh_buf_tmp += corner_size;
|
||||
@@ -704,7 +707,7 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
lv_opa_t opa_tmp = sh_buf_tmp[x - a.x1 + first_px];
|
||||
if(opa_tmp != LV_OPA_COVER || opa != LV_OPA_COVER) opa_tmp = (opa * opa_tmp) >> 8;
|
||||
lv_blend_fill(clip, &va,
|
||||
dsc->shadow_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa_tmp, dsc->shadow_blend_mode);
|
||||
dsc->shadow_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa_tmp, dsc->shadow_blend_mode);
|
||||
}
|
||||
va.x1++;
|
||||
va.x2++;
|
||||
@@ -718,7 +721,7 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED;
|
||||
|
||||
lv_blend_fill(clip, &a,
|
||||
dsc->shadow_color, mask_buf+first_px, mask_res, opa, dsc->shadow_blend_mode);
|
||||
dsc->shadow_color, mask_buf + first_px, mask_res, opa, dsc->shadow_blend_mode);
|
||||
a.y1++;
|
||||
a.y2++;
|
||||
}
|
||||
@@ -741,8 +744,8 @@ 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;
|
||||
|
||||
if(a.x2 > sh_area.x1 + lv_area_get_width(&sh_area)/2 - 1) {
|
||||
a.x2 = sh_area.x1 + lv_area_get_width(&sh_area)/2 -1 ;
|
||||
if(a.x2 > sh_area.x1 + lv_area_get_width(&sh_area) / 2 - 1) {
|
||||
a.x2 = sh_area.x1 + lv_area_get_width(&sh_area) / 2 - 1 ;
|
||||
}
|
||||
|
||||
first_px = 0;
|
||||
@@ -758,7 +761,7 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED;
|
||||
|
||||
lv_blend_fill(clip, &a,
|
||||
dsc->shadow_color, mask_buf + first_px, mask_res, opa, dsc->shadow_blend_mode);
|
||||
dsc->shadow_color, mask_buf + first_px, mask_res, opa, dsc->shadow_blend_mode);
|
||||
a.y1++;
|
||||
a.y2++;
|
||||
sh_buf_tmp += corner_size;
|
||||
@@ -776,14 +779,14 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED;
|
||||
|
||||
lv_blend_fill(clip, &a,
|
||||
dsc->shadow_color, mask_buf + first_px, mask_res, opa, dsc->shadow_blend_mode);
|
||||
dsc->shadow_color, mask_buf + first_px, mask_res, opa, dsc->shadow_blend_mode);
|
||||
a.y1--;
|
||||
a.y2--;
|
||||
sh_buf_tmp += corner_size;
|
||||
}
|
||||
|
||||
/*Fill the left side*/
|
||||
a.y1 = sh_area.y1+corner_size;
|
||||
a.y1 = sh_area.y1 + corner_size;
|
||||
a.y2 = a.y1;
|
||||
|
||||
sh_buf_tmp = sh_buf + corner_size * (corner_size - 1);
|
||||
@@ -801,7 +804,7 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
lv_opa_t opa_tmp = sh_buf_tmp[x - a.x1 + first_px];
|
||||
if(opa_tmp != LV_OPA_COVER || opa != LV_OPA_COVER) opa_tmp = (opa * opa_tmp) >> 8;
|
||||
lv_blend_fill(clip, &va,
|
||||
dsc->shadow_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa_tmp, dsc->shadow_blend_mode);
|
||||
dsc->shadow_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa_tmp, dsc->shadow_blend_mode);
|
||||
va.x1++;
|
||||
va.x2++;
|
||||
}
|
||||
@@ -814,7 +817,7 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED;
|
||||
|
||||
lv_blend_fill(clip, &a,
|
||||
dsc->shadow_color, mask_buf + first_px, mask_res, opa, dsc->shadow_blend_mode);
|
||||
dsc->shadow_color, mask_buf + first_px, mask_res, opa, dsc->shadow_blend_mode);
|
||||
a.y1++;
|
||||
a.y2++;
|
||||
}
|
||||
@@ -850,13 +853,14 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED;
|
||||
|
||||
lv_blend_fill(clip, &a,
|
||||
dsc->shadow_color, mask_buf, mask_res, opa, dsc->shadow_blend_mode);
|
||||
} else {
|
||||
dsc->shadow_color, mask_buf, mask_res, opa, dsc->shadow_blend_mode);
|
||||
}
|
||||
else {
|
||||
|
||||
lv_opa_t opa_tmp = sh_buf_tmp[0];
|
||||
if(opa_tmp != LV_OPA_COVER || opa != LV_OPA_COVER) opa_tmp = (opa * opa_tmp) >> 8;
|
||||
lv_blend_fill(clip, &a,
|
||||
dsc->shadow_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa_tmp, dsc->shadow_blend_mode);
|
||||
dsc->shadow_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa_tmp, dsc->shadow_blend_mode);
|
||||
}
|
||||
|
||||
a.y1++;
|
||||
@@ -867,7 +871,7 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
/*Fill the bottom side*/
|
||||
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;
|
||||
sh_buf_tmp = sh_buf + corner_size * (corner_size - y_min - 1) + corner_size - 1;
|
||||
|
||||
a.y1 = sh_area.y2 - corner_size + 1 + y_min;
|
||||
a.y2 = a.y1;
|
||||
@@ -878,12 +882,13 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
mask_res = lv_draw_mask_apply(mask_buf, a.x1, a.y1, lv_area_get_width(&a));
|
||||
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED;
|
||||
lv_blend_fill(clip, &a,
|
||||
dsc->shadow_color, mask_buf, mask_res, opa, dsc->shadow_blend_mode);
|
||||
} else {
|
||||
dsc->shadow_color, mask_buf, mask_res, opa, dsc->shadow_blend_mode);
|
||||
}
|
||||
else {
|
||||
lv_opa_t opa_tmp = sh_buf_tmp[0];
|
||||
if(opa_tmp != LV_OPA_COVER || opa != LV_OPA_COVER) opa_tmp = (opa * opa_tmp) >> 8;
|
||||
lv_blend_fill(clip, &a,
|
||||
dsc->shadow_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa_tmp, dsc->shadow_blend_mode);
|
||||
dsc->shadow_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa_tmp, dsc->shadow_blend_mode);
|
||||
}
|
||||
|
||||
a.y1++;
|
||||
@@ -901,7 +906,7 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
memset(mask_buf, 0xFF, lv_area_get_width(&a));
|
||||
mask_res = lv_draw_mask_apply(mask_buf, a.x1, a.y1, lv_area_get_width(&a));
|
||||
lv_blend_fill(clip, &a,
|
||||
dsc->shadow_color, mask_buf, mask_res, opa, dsc->shadow_blend_mode);
|
||||
dsc->shadow_color, mask_buf, mask_res, opa, dsc->shadow_blend_mode);
|
||||
|
||||
a.y1++;
|
||||
a.y2++;
|
||||
@@ -921,7 +926,7 @@ static void shadow_draw_corner_buf(const lv_area_t * coords, uint16_t * sh_buf,
|
||||
|
||||
lv_area_t sh_area;
|
||||
lv_area_copy(&sh_area, coords);
|
||||
sh_area.x2 = sw / 2 + r -1 - ((sw & 1) ? 0 : 1);
|
||||
sh_area.x2 = sw / 2 + r - 1 - ((sw & 1) ? 0 : 1);
|
||||
sh_area.y1 = sw / 2 + 1;
|
||||
|
||||
sh_area.x1 = sh_area.x2 - lv_area_get_width(coords);
|
||||
@@ -944,11 +949,12 @@ static void shadow_draw_corner_buf(const lv_area_t * coords, uint16_t * sh_buf,
|
||||
lv_draw_mask_res_t mask_res = mask_param.dsc.cb(mask_line, 0, y, size, &mask_param);
|
||||
if(mask_res == LV_DRAW_MASK_RES_FULL_TRANSP) {
|
||||
memset(sh_ups_tmp_buf, 0x00, size * sizeof(sh_ups_tmp_buf[0]));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
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];
|
||||
if(mask_line[i] == mask_line[i - 1]) sh_ups_tmp_buf[i] = sh_ups_tmp_buf[i - 1];
|
||||
else sh_ups_tmp_buf[i] = (mask_line[i] << SHADOW_UPSACALE_SHIFT) / sw;
|
||||
}
|
||||
}
|
||||
@@ -981,7 +987,7 @@ static void shadow_draw_corner_buf(const lv_area_t * coords, uint16_t * sh_buf,
|
||||
uint32_t i;
|
||||
sh_buf[0] = (sh_buf[0] << SHADOW_UPSACALE_SHIFT) / sw;
|
||||
for(i = 1; i < (uint32_t) size * size; i++) {
|
||||
if(sh_buf[i] == sh_buf[i-1]) sh_buf[i] = sh_buf[i-1];
|
||||
if(sh_buf[i] == sh_buf[i - 1]) sh_buf[i] = sh_buf[i - 1];
|
||||
else sh_buf[i] = (sh_buf[i] << SHADOW_UPSACALE_SHIFT) / sw;
|
||||
}
|
||||
|
||||
@@ -1011,8 +1017,8 @@ static void shadow_blur_corner(lv_coord_t size, lv_coord_t sw, uint16_t * sh_ups
|
||||
uint16_t * sh_ups_tmp_buf = sh_ups_buf;
|
||||
|
||||
for(y = 0; y < size; y++) {
|
||||
int32_t v = sh_ups_tmp_buf[size-1] * sw;
|
||||
for(x = size - 1; x >=0; x--) {
|
||||
int32_t v = sh_ups_tmp_buf[size - 1] * sw;
|
||||
for(x = size - 1; x >= 0; x--) {
|
||||
sh_ups_blur_buf[x] = v;
|
||||
|
||||
/*Forget the right pixel*/
|
||||
@@ -1034,7 +1040,7 @@ static void shadow_blur_corner(lv_coord_t size, lv_coord_t sw, uint16_t * sh_ups
|
||||
uint32_t i;
|
||||
sh_ups_buf[0] = sh_ups_buf[0] / sw;
|
||||
for(i = 1; i < (uint32_t)size * size; i++) {
|
||||
if(sh_ups_buf[i] == sh_ups_buf[i-1]) sh_ups_buf[i] = sh_ups_buf[i-1];
|
||||
if(sh_ups_buf[i] == sh_ups_buf[i - 1]) sh_ups_buf[i] = sh_ups_buf[i - 1];
|
||||
else sh_ups_buf[i] = sh_ups_buf[i] / sw;
|
||||
}
|
||||
|
||||
@@ -1213,7 +1219,7 @@ static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_dr
|
||||
lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode);
|
||||
|
||||
/*Draw the bottom horizontal line*/
|
||||
if(fill_area2.y2 > area_outer.y2 - dsc->outline_width ) {
|
||||
if(fill_area2.y2 > area_outer.y2 - dsc->outline_width) {
|
||||
fill_area2.x1 = area_outer.x1 + rout;
|
||||
fill_area2.x2 = area_outer.x2 - rout;
|
||||
|
||||
@@ -1256,7 +1262,7 @@ static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_dr
|
||||
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_blend_fill( clip, &fill_area, color, mask_buf, mask_res, opa, blend_mode);
|
||||
lv_blend_fill(clip, &fill_area, color, mask_buf, mask_res, opa, blend_mode);
|
||||
fill_area.y1++;
|
||||
fill_area.y2++;
|
||||
|
||||
@@ -1282,7 +1288,7 @@ static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_dr
|
||||
if(src_type == LV_IMG_SRC_FILE || src_type == LV_IMG_SRC_VARIABLE) {
|
||||
lv_img_header_t header;
|
||||
lv_res_t res = lv_img_decoder_get_info(dsc->pattern_image, &header);
|
||||
if(res!= LV_RES_OK) {
|
||||
if(res != LV_RES_OK) {
|
||||
LV_LOG_WARN("draw_img: can't get image info");
|
||||
return;
|
||||
}
|
||||
@@ -1294,17 +1300,20 @@ static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_dr
|
||||
img_dsc.opa = dsc->pattern_opa;
|
||||
img_dsc.recolor_opa = dsc->pattern_recolor_opa;
|
||||
img_dsc.recolor = dsc->pattern_recolor;
|
||||
} else if(src_type == LV_IMG_SRC_SYMBOL) {
|
||||
}
|
||||
else if(src_type == LV_IMG_SRC_SYMBOL) {
|
||||
lv_draw_label_dsc_init(&label_dsc);
|
||||
label_dsc.color = dsc->pattern_recolor;
|
||||
label_dsc.font = dsc->pattern_font;
|
||||
label_dsc.opa = dsc->pattern_opa;
|
||||
lv_point_t s;
|
||||
lv_txt_get_size(&s, dsc->pattern_image, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX, LV_TXT_FLAG_NONE);
|
||||
lv_txt_get_size(&s, dsc->pattern_image, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX,
|
||||
LV_TXT_FLAG_NONE);
|
||||
img_w = s.x;
|
||||
img_h = s.y;
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/*Trigger the error handler of image drawer*/
|
||||
LV_LOG_WARN("lv_img_design: image source type is unknown");
|
||||
lv_draw_img(coords, clip, NULL, NULL);
|
||||
@@ -1333,7 +1342,8 @@ static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_dr
|
||||
}
|
||||
}
|
||||
lv_draw_mask_remove_id(radius_mask_id);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
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;
|
||||
@@ -1371,7 +1381,8 @@ static void draw_value(const lv_area_t * coords, const lv_area_t * clip, lv_draw
|
||||
if(dsc->value_opa <= LV_OPA_MIN) return;
|
||||
|
||||
lv_point_t s;
|
||||
lv_txt_get_size(&s, dsc->value_str, dsc->value_font, dsc->value_letter_space, dsc->value_line_space, LV_COORD_MAX, LV_TXT_FLAG_NONE);
|
||||
lv_txt_get_size(&s, dsc->value_str, dsc->value_font, dsc->value_letter_space, dsc->value_line_space, LV_COORD_MAX,
|
||||
LV_TXT_FLAG_NONE);
|
||||
|
||||
lv_area_t value_area;
|
||||
value_area.x1 = 0;
|
||||
|
||||
@@ -64,7 +64,7 @@ typedef struct {
|
||||
lv_color_t pattern_recolor;
|
||||
lv_opa_t pattern_opa;
|
||||
lv_opa_t pattern_recolor_opa;
|
||||
uint8_t pattern_repeat :1;
|
||||
uint8_t pattern_repeat : 1;
|
||||
lv_blend_mode_t pattern_blend_mode;
|
||||
|
||||
/*Value*/
|
||||
@@ -78,7 +78,7 @@ typedef struct {
|
||||
lv_style_int_t value_line_space;
|
||||
lv_align_t value_align;
|
||||
lv_blend_mode_t value_blend_mode;
|
||||
}lv_draw_rect_dsc_t;
|
||||
} lv_draw_rect_dsc_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
|
||||
@@ -52,7 +52,8 @@ void lv_draw_triangle(const lv_point_t * points, const lv_area_t * clip_area, lv
|
||||
* @param clip_area polygon will be drawn only in this area
|
||||
* @param draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable
|
||||
*/
|
||||
void lv_draw_polygon(const lv_point_t * points, uint16_t point_cnt, const lv_area_t * clip_area, lv_draw_rect_dsc_t * draw_dsc)
|
||||
void lv_draw_polygon(const lv_point_t * points, uint16_t point_cnt, const lv_area_t * clip_area,
|
||||
lv_draw_rect_dsc_t * draw_dsc)
|
||||
{
|
||||
if(point_cnt < 3) return;
|
||||
if(points == NULL) return;
|
||||
@@ -111,7 +112,8 @@ void lv_draw_polygon(const lv_point_t * points, uint16_t point_cnt, const lv_are
|
||||
|
||||
i_next_right = i_prev_right + 1;
|
||||
if(i_next_right > point_cnt - 1) i_next_right = 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
i_next_left = i_prev_left + 1;
|
||||
if(i_next_left > point_cnt - 1) i_next_left = 0;
|
||||
|
||||
@@ -121,10 +123,10 @@ void lv_draw_polygon(const lv_point_t * points, uint16_t point_cnt, const lv_are
|
||||
|
||||
if(points[i_next_left].y >= points[i_prev_left].y) {
|
||||
if(points[i_next_left].y != points[i_prev_left].y &&
|
||||
points[i_next_left].x != points[i_prev_left].x) {
|
||||
points[i_next_left].x != points[i_prev_left].x) {
|
||||
lv_draw_mask_line_points_init(mp_next, points[i_prev_left].x, points[i_prev_left].y,
|
||||
points[i_next_left].x, points[i_next_left].y,
|
||||
LV_DRAW_MASK_LINE_SIDE_RIGHT);
|
||||
points[i_next_left].x, points[i_next_left].y,
|
||||
LV_DRAW_MASK_LINE_SIDE_RIGHT);
|
||||
lv_draw_mask_add(mp_next, mp);
|
||||
mp_next++;
|
||||
}
|
||||
@@ -139,8 +141,8 @@ void lv_draw_polygon(const lv_point_t * points, uint16_t point_cnt, const lv_are
|
||||
points[i_next_right].x != points[i_prev_right].x) {
|
||||
|
||||
lv_draw_mask_line_points_init(mp_next, points[i_prev_right].x, points[i_prev_right].y,
|
||||
points[i_next_right].x, points[i_next_right].y,
|
||||
LV_DRAW_MASK_LINE_SIDE_LEFT);
|
||||
points[i_next_right].x, points[i_next_right].y,
|
||||
LV_DRAW_MASK_LINE_SIDE_LEFT);
|
||||
lv_draw_mask_add(mp_next, mp);
|
||||
mp_next++;
|
||||
}
|
||||
@@ -148,7 +150,7 @@ void lv_draw_polygon(const lv_point_t * points, uint16_t point_cnt, const lv_are
|
||||
i_prev_right = i_next_right;
|
||||
}
|
||||
|
||||
}while( mask_cnt < point_cnt);
|
||||
} while(mask_cnt < point_cnt);
|
||||
|
||||
lv_draw_rect(&poly_coords, clip_area, draw_dsc);
|
||||
|
||||
|
||||
@@ -42,7 +42,8 @@ void lv_draw_triangle(const lv_point_t * points, const lv_area_t * clip, lv_draw
|
||||
* @param clip_area polygon will be drawn only in this area
|
||||
* @param draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable
|
||||
*/
|
||||
void lv_draw_polygon(const lv_point_t * points, uint16_t point_cnt, const lv_area_t * mask, lv_draw_rect_dsc_t * draw_dsc);
|
||||
void lv_draw_polygon(const lv_point_t * points, uint16_t point_cnt, const lv_area_t * mask,
|
||||
lv_draw_rect_dsc_t * draw_dsc);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
||||
+99
-56
@@ -56,14 +56,15 @@ lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t
|
||||
uint8_t * buf_u8 = (uint8_t *)dsc->data;
|
||||
|
||||
if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR || dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED ||
|
||||
dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) {
|
||||
dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) {
|
||||
uint8_t px_size = lv_img_cf_get_px_size(dsc->header.cf) >> 3;
|
||||
uint32_t px = dsc->header.w * y * px_size + x * px_size;
|
||||
memcpy(&p_color, &buf_u8[px], sizeof(lv_color_t));
|
||||
#if LV_COLOR_SIZE == 32
|
||||
p_color.ch.alpha = 0xFF; /*Only the color should be get so use a deafult alpha value*/
|
||||
#endif
|
||||
} else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT) {
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT) {
|
||||
buf_u8 += 4 * 2;
|
||||
uint8_t bit = x & 0x7;
|
||||
x = x >> 3;
|
||||
@@ -73,7 +74,8 @@ lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t
|
||||
* so the possible real width are 8, 16, 24 ...*/
|
||||
uint32_t px = ((dsc->header.w + 7) >> 3) * y + x;
|
||||
p_color.full = (buf_u8[px] & (1 << (7 - bit))) >> (7 - bit);
|
||||
} else if(dsc->header.cf == LV_IMG_CF_INDEXED_2BIT) {
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_INDEXED_2BIT) {
|
||||
buf_u8 += 4 * 4;
|
||||
uint8_t bit = (x & 0x3) * 2;
|
||||
x = x >> 2;
|
||||
@@ -83,7 +85,8 @@ lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t
|
||||
* so the possible real width are 4, 8, 12 ...*/
|
||||
uint32_t px = ((dsc->header.w + 3) >> 2) * y + x;
|
||||
p_color.full = (buf_u8[px] & (3 << (6 - bit))) >> (6 - bit);
|
||||
} else if(dsc->header.cf == LV_IMG_CF_INDEXED_4BIT) {
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_INDEXED_4BIT) {
|
||||
buf_u8 += 4 * 16;
|
||||
uint8_t bit = (x & 0x1) * 4;
|
||||
x = x >> 1;
|
||||
@@ -93,11 +96,13 @@ lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t
|
||||
* so the possible real width are 2, 4, 6 ...*/
|
||||
uint32_t px = ((dsc->header.w + 1) >> 1) * y + x;
|
||||
p_color.full = (buf_u8[px] & (0xF << (4 - bit))) >> (4 - bit);
|
||||
} else if(dsc->header.cf == LV_IMG_CF_INDEXED_8BIT) {
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_INDEXED_8BIT) {
|
||||
buf_u8 += 4 * 256;
|
||||
uint32_t px = dsc->header.w * y + x;
|
||||
p_color.full = buf_u8[px];
|
||||
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT || dsc->header.cf == LV_IMG_CF_ALPHA_2BIT ||
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT || dsc->header.cf == LV_IMG_CF_ALPHA_2BIT ||
|
||||
dsc->header.cf == LV_IMG_CF_ALPHA_4BIT || dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) {
|
||||
p_color = color;
|
||||
}
|
||||
@@ -119,7 +124,8 @@ lv_opa_t lv_img_buf_get_px_alpha(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y)
|
||||
if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) {
|
||||
uint32_t px = dsc->header.w * y * LV_IMG_PX_SIZE_ALPHA_BYTE + x * LV_IMG_PX_SIZE_ALPHA_BYTE;
|
||||
return buf_u8[px + LV_IMG_PX_SIZE_ALPHA_BYTE - 1];
|
||||
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT) {
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT) {
|
||||
uint8_t bit = x & 0x7;
|
||||
x = x >> 3;
|
||||
|
||||
@@ -129,7 +135,8 @@ lv_opa_t lv_img_buf_get_px_alpha(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y)
|
||||
uint32_t px = ((dsc->header.w + 7) >> 3) * y + x;
|
||||
uint8_t px_opa = (buf_u8[px] & (1 << (7 - bit))) >> (7 - bit);
|
||||
return px_opa ? LV_OPA_TRANSP : LV_OPA_COVER;
|
||||
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_2BIT) {
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_ALPHA_2BIT) {
|
||||
const uint8_t opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping with bpp = 2*/
|
||||
|
||||
uint8_t bit = (x & 0x3) * 2;
|
||||
@@ -141,9 +148,11 @@ lv_opa_t lv_img_buf_get_px_alpha(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y)
|
||||
uint32_t px = ((dsc->header.w + 3) >> 2) * y + x;
|
||||
uint8_t px_opa = (buf_u8[px] & (3 << (6 - bit))) >> (6 - bit);
|
||||
return opa_table[px_opa];
|
||||
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_4BIT) {
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_ALPHA_4BIT) {
|
||||
const uint8_t opa_table[16] = {0, 17, 34, 51, /*Opacity mapping with bpp = 4*/
|
||||
68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255};
|
||||
68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255
|
||||
};
|
||||
|
||||
uint8_t bit = (x & 0x1) * 4;
|
||||
x = x >> 1;
|
||||
@@ -154,7 +163,8 @@ lv_opa_t lv_img_buf_get_px_alpha(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y)
|
||||
uint32_t px = ((dsc->header.w + 1) >> 1) * y + x;
|
||||
uint8_t px_opa = (buf_u8[px] & (0xF << (4 - bit))) >> (4 - bit);
|
||||
return opa_table[px_opa];
|
||||
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) {
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) {
|
||||
uint32_t px = dsc->header.w * y + x;
|
||||
return buf_u8[px];
|
||||
}
|
||||
@@ -178,7 +188,8 @@ void lv_img_buf_set_px_alpha(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_
|
||||
uint8_t px_size = lv_img_cf_get_px_size(dsc->header.cf) >> 3;
|
||||
uint32_t px = dsc->header.w * y * px_size + x * px_size;
|
||||
buf_u8[px + px_size - 1] = opa;
|
||||
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT) {
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT) {
|
||||
opa = opa >> 7; /*opa -> [0,1]*/
|
||||
uint8_t bit = x & 0x7;
|
||||
x = x >> 3;
|
||||
@@ -189,7 +200,8 @@ void lv_img_buf_set_px_alpha(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_
|
||||
uint32_t px = ((dsc->header.w + 7) >> 3) * y + x;
|
||||
buf_u8[px] = buf_u8[px] & ~(1 << (7 - bit));
|
||||
buf_u8[px] = buf_u8[px] | ((opa & 0x1) << (7 - bit));
|
||||
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_2BIT) {
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_ALPHA_2BIT) {
|
||||
opa = opa >> 6; /*opa -> [0,3]*/
|
||||
uint8_t bit = (x & 0x3) * 2;
|
||||
x = x >> 2;
|
||||
@@ -200,7 +212,8 @@ void lv_img_buf_set_px_alpha(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_
|
||||
uint32_t px = ((dsc->header.w + 3) >> 2) * y + x;
|
||||
buf_u8[px] = buf_u8[px] & ~(3 << (6 - bit));
|
||||
buf_u8[px] = buf_u8[px] | ((opa & 0x3) << (6 - bit));
|
||||
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_4BIT) {
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_ALPHA_4BIT) {
|
||||
opa = opa >> 4; /*opa -> [0,15]*/
|
||||
uint8_t bit = (x & 0x1) * 4;
|
||||
x = x >> 1;
|
||||
@@ -211,7 +224,8 @@ void lv_img_buf_set_px_alpha(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_
|
||||
uint32_t px = ((dsc->header.w + 1) >> 1) * y + x;
|
||||
buf_u8[px] = buf_u8[px] & ~(0xF << (4 - bit));
|
||||
buf_u8[px] = buf_u8[px] | ((opa & 0xF) << (4 - bit));
|
||||
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) {
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) {
|
||||
uint32_t px = dsc->header.w * y + x;
|
||||
buf_u8[px] = opa;
|
||||
}
|
||||
@@ -233,11 +247,13 @@ void lv_img_buf_set_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_
|
||||
uint8_t px_size = lv_img_cf_get_px_size(dsc->header.cf) >> 3;
|
||||
uint32_t px = dsc->header.w * y * px_size + x * px_size;
|
||||
memcpy(&buf_u8[px], &c, px_size);
|
||||
} else if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) {
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) {
|
||||
uint8_t px_size = lv_img_cf_get_px_size(dsc->header.cf) >> 3;
|
||||
uint32_t px = dsc->header.w * y * px_size + x * px_size;
|
||||
memcpy(&buf_u8[px], &c, px_size - 1); /*-1 to not overwrite the alpha value*/
|
||||
} else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT) {
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT) {
|
||||
buf_u8 += sizeof(lv_color32_t) * 2; /*Skip the palette*/
|
||||
|
||||
uint8_t bit = x & 0x7;
|
||||
@@ -249,7 +265,8 @@ void lv_img_buf_set_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_
|
||||
uint32_t px = ((dsc->header.w + 7) >> 3) * y + x;
|
||||
buf_u8[px] = buf_u8[px] & ~(1 << (7 - bit));
|
||||
buf_u8[px] = buf_u8[px] | ((c.full & 0x1) << (7 - bit));
|
||||
} else if(dsc->header.cf == LV_IMG_CF_INDEXED_2BIT) {
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_INDEXED_2BIT) {
|
||||
buf_u8 += sizeof(lv_color32_t) * 4; /*Skip the palette*/
|
||||
uint8_t bit = (x & 0x3) * 2;
|
||||
x = x >> 2;
|
||||
@@ -261,7 +278,8 @@ void lv_img_buf_set_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_
|
||||
|
||||
buf_u8[px] = buf_u8[px] & ~(3 << (6 - bit));
|
||||
buf_u8[px] = buf_u8[px] | ((c.full & 0x3) << (6 - bit));
|
||||
} else if(dsc->header.cf == LV_IMG_CF_INDEXED_4BIT) {
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_INDEXED_4BIT) {
|
||||
buf_u8 += sizeof(lv_color32_t) * 16; /*Skip the palette*/
|
||||
uint8_t bit = (x & 0x1) * 4;
|
||||
x = x >> 1;
|
||||
@@ -272,7 +290,8 @@ void lv_img_buf_set_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_
|
||||
uint32_t px = ((dsc->header.w + 1) >> 1) * y + x;
|
||||
buf_u8[px] = buf_u8[px] & ~(0xF << (4 - bit));
|
||||
buf_u8[px] = buf_u8[px] | ((c.full & 0xF) << (4 - bit));
|
||||
} else if(dsc->header.cf == LV_IMG_CF_INDEXED_8BIT) {
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_INDEXED_8BIT) {
|
||||
buf_u8 += sizeof(lv_color32_t) * 256; /*Skip the palette*/
|
||||
uint32_t px = dsc->header.w * y + x;
|
||||
buf_u8[px] = c.full;
|
||||
@@ -292,7 +311,7 @@ void lv_img_buf_set_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_
|
||||
void lv_img_buf_set_palette(lv_img_dsc_t * dsc, uint8_t id, lv_color_t c)
|
||||
{
|
||||
if((dsc->header.cf == LV_IMG_CF_ALPHA_1BIT && id > 1) || (dsc->header.cf == LV_IMG_CF_ALPHA_2BIT && id > 3) ||
|
||||
(dsc->header.cf == LV_IMG_CF_ALPHA_4BIT && id > 15) || (dsc->header.cf == LV_IMG_CF_ALPHA_8BIT)) {
|
||||
(dsc->header.cf == LV_IMG_CF_ALPHA_4BIT && id > 15) || (dsc->header.cf == LV_IMG_CF_ALPHA_8BIT)) {
|
||||
LV_LOG_WARN("lv_img_buf_set_px_alpha: invalid 'id'");
|
||||
return;
|
||||
}
|
||||
@@ -310,10 +329,10 @@ void lv_img_buf_set_palette(lv_img_dsc_t * dsc, uint8_t id, lv_color_t c)
|
||||
* @param cf a color format (`LV_IMG_CF_...`)
|
||||
* @return an allocated image, or NULL on failure
|
||||
*/
|
||||
lv_img_dsc_t *lv_img_buf_alloc(lv_coord_t w, lv_coord_t h, lv_img_cf_t cf)
|
||||
lv_img_dsc_t * lv_img_buf_alloc(lv_coord_t w, lv_coord_t h, lv_img_cf_t cf)
|
||||
{
|
||||
/* Allocate image descriptor */
|
||||
lv_img_dsc_t *dsc = lv_mem_alloc(sizeof(lv_img_dsc_t));
|
||||
lv_img_dsc_t * dsc = lv_mem_alloc(sizeof(lv_img_dsc_t));
|
||||
if(dsc == NULL)
|
||||
return NULL;
|
||||
|
||||
@@ -346,7 +365,7 @@ lv_img_dsc_t *lv_img_buf_alloc(lv_coord_t w, lv_coord_t h, lv_img_cf_t cf)
|
||||
* Free an allocated image buffer
|
||||
* @param dsc image buffer to free
|
||||
*/
|
||||
void lv_img_buf_free(lv_img_dsc_t *dsc)
|
||||
void lv_img_buf_free(lv_img_dsc_t * dsc)
|
||||
{
|
||||
if(dsc != NULL) {
|
||||
if(dsc->data != NULL)
|
||||
@@ -366,18 +385,30 @@ void lv_img_buf_free(lv_img_dsc_t *dsc)
|
||||
uint32_t lv_img_buf_get_img_size(lv_coord_t w, lv_coord_t h, lv_img_cf_t cf)
|
||||
{
|
||||
switch(cf) {
|
||||
case LV_IMG_CF_TRUE_COLOR: return LV_IMG_BUF_SIZE_TRUE_COLOR(w, h);
|
||||
case LV_IMG_CF_TRUE_COLOR_ALPHA: return LV_IMG_BUF_SIZE_TRUE_COLOR_ALPHA(w, h);
|
||||
case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED: return LV_IMG_BUF_SIZE_TRUE_COLOR_CHROMA_KEYED(w, h);
|
||||
case LV_IMG_CF_ALPHA_1BIT: return LV_IMG_BUF_SIZE_ALPHA_1BIT(w, h);
|
||||
case LV_IMG_CF_ALPHA_2BIT: return LV_IMG_BUF_SIZE_ALPHA_2BIT(w, h);
|
||||
case LV_IMG_CF_ALPHA_4BIT: return LV_IMG_BUF_SIZE_ALPHA_4BIT(w, h);
|
||||
case LV_IMG_CF_ALPHA_8BIT: return LV_IMG_BUF_SIZE_ALPHA_8BIT(w, h);
|
||||
case LV_IMG_CF_INDEXED_1BIT: return LV_IMG_BUF_SIZE_INDEXED_1BIT(w, h);
|
||||
case LV_IMG_CF_INDEXED_2BIT: return LV_IMG_BUF_SIZE_INDEXED_2BIT(w, h);
|
||||
case LV_IMG_CF_INDEXED_4BIT: return LV_IMG_BUF_SIZE_INDEXED_4BIT(w, h);
|
||||
case LV_IMG_CF_INDEXED_8BIT: return LV_IMG_BUF_SIZE_INDEXED_8BIT(w, h);
|
||||
default: return 0;
|
||||
case LV_IMG_CF_TRUE_COLOR:
|
||||
return LV_IMG_BUF_SIZE_TRUE_COLOR(w, h);
|
||||
case LV_IMG_CF_TRUE_COLOR_ALPHA:
|
||||
return LV_IMG_BUF_SIZE_TRUE_COLOR_ALPHA(w, h);
|
||||
case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED:
|
||||
return LV_IMG_BUF_SIZE_TRUE_COLOR_CHROMA_KEYED(w, h);
|
||||
case LV_IMG_CF_ALPHA_1BIT:
|
||||
return LV_IMG_BUF_SIZE_ALPHA_1BIT(w, h);
|
||||
case LV_IMG_CF_ALPHA_2BIT:
|
||||
return LV_IMG_BUF_SIZE_ALPHA_2BIT(w, h);
|
||||
case LV_IMG_CF_ALPHA_4BIT:
|
||||
return LV_IMG_BUF_SIZE_ALPHA_4BIT(w, h);
|
||||
case LV_IMG_CF_ALPHA_8BIT:
|
||||
return LV_IMG_BUF_SIZE_ALPHA_8BIT(w, h);
|
||||
case LV_IMG_CF_INDEXED_1BIT:
|
||||
return LV_IMG_BUF_SIZE_INDEXED_1BIT(w, h);
|
||||
case LV_IMG_CF_INDEXED_2BIT:
|
||||
return LV_IMG_BUF_SIZE_INDEXED_2BIT(w, h);
|
||||
case LV_IMG_CF_INDEXED_4BIT:
|
||||
return LV_IMG_BUF_SIZE_INDEXED_4BIT(w, h);
|
||||
case LV_IMG_CF_INDEXED_8BIT:
|
||||
return LV_IMG_BUF_SIZE_INDEXED_8BIT(w, h);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,7 +436,8 @@ void lv_img_buf_transform_init(lv_img_transform_dsc_t * dsc)
|
||||
|
||||
dsc->tmp.chroma_keyed = lv_img_cf_is_chroma_keyed(dsc->cfg.cf) ? 1 : 0;
|
||||
dsc->tmp.has_alpha = lv_img_cf_has_alpha(dsc->cfg.cf) ? 1 : 0;
|
||||
if(dsc->cfg.cf == LV_IMG_CF_TRUE_COLOR || dsc->cfg.cf == LV_IMG_CF_TRUE_COLOR_ALPHA || dsc->cfg.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) {
|
||||
if(dsc->cfg.cf == LV_IMG_CF_TRUE_COLOR || dsc->cfg.cf == LV_IMG_CF_TRUE_COLOR_ALPHA ||
|
||||
dsc->cfg.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) {
|
||||
dsc->tmp.native_color = 1;
|
||||
}
|
||||
|
||||
@@ -443,7 +475,8 @@ bool lv_img_buf_transform(lv_img_transform_dsc_t * dsc, lv_coord_t x, lv_coord_t
|
||||
/*Get the source pixel from the upscaled image*/
|
||||
xs = ((dsc->tmp.cosma * xt - dsc->tmp.sinma * yt) >> (LV_TRIGO_SHIFT - 8)) + dsc->tmp.pivot_x_256;
|
||||
ys = ((dsc->tmp.sinma * xt + dsc->tmp.cosma * yt) >> (LV_TRIGO_SHIFT - 8)) + dsc->tmp.pivot_y_256;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
xt *= dsc->tmp.zoom_inv;
|
||||
yt *= dsc->tmp.zoom_inv;
|
||||
xs = ((dsc->tmp.cosma * xt - dsc->tmp.sinma * yt) >> (LV_TRIGO_SHIFT)) + dsc->tmp.pivot_x_256;
|
||||
@@ -472,13 +505,15 @@ bool lv_img_buf_transform(lv_img_transform_dsc_t * dsc, lv_coord_t x, lv_coord_t
|
||||
|
||||
pxi = dsc->cfg.src_w * ys_int * px_size + xs_int * px_size;
|
||||
memcpy(&dsc->res.color, &src_u8[pxi], px_size);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
px_size = LV_IMG_PX_SIZE_ALPHA_BYTE;
|
||||
pxi = dsc->cfg.src_w * ys_int * px_size + xs_int * px_size;
|
||||
memcpy(&dsc->res.color, &src_u8[pxi], px_size - 1);
|
||||
dsc->res.opa = src_u8[pxi + px_size - 1];
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pxi = 0; /*unused*/
|
||||
px_size = 0; /*unused*/
|
||||
dsc->res.color = lv_img_buf_get_px_color(&dsc->tmp.img_dsc, xs_int, ys_int, dsc->cfg.color);
|
||||
@@ -516,7 +551,8 @@ bool lv_img_buf_transform(lv_img_transform_dsc_t * dsc, lv_coord_t x, lv_coord_t
|
||||
* @param zoom zoom, (256 no zoom)
|
||||
* @param pivot x,y pivot coordinates of rotation
|
||||
*/
|
||||
void lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t h, int16_t angle, uint16_t zoom, lv_point_t * pivot)
|
||||
void lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t h, int16_t angle, uint16_t zoom,
|
||||
lv_point_t * pivot)
|
||||
{
|
||||
|
||||
int32_t angle_low = angle / 10;
|
||||
@@ -543,8 +579,8 @@ void lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t h
|
||||
lv_area_t a;
|
||||
a.x1 = ((-pivot->x) * zoom) >> 8;
|
||||
a.y1 = ((-pivot->y) * zoom) >> 8;
|
||||
a.x2 = ((w -pivot->x) * zoom) >> 8;
|
||||
a.y2 = ((h -pivot->y) * zoom) >> 8;
|
||||
a.x2 = ((w - pivot->x) * zoom) >> 8;
|
||||
a.y2 = ((h - pivot->y) * zoom) >> 8;
|
||||
|
||||
xt = a.x1;
|
||||
yt = a.y1;
|
||||
@@ -587,14 +623,16 @@ static inline bool transform_anti_alias(lv_img_transform_dsc_t * dsc)
|
||||
lv_opa_t xr; /*x mix ratio*/
|
||||
|
||||
if(xs_fract < 0x70) {
|
||||
xn = - 1;
|
||||
if(dsc->tmp.xs_int + xn < 0) xn = 0;
|
||||
xr = xs_fract + 0x80;
|
||||
} else if(xs_fract > 0x90) {
|
||||
xn = - 1;
|
||||
if(dsc->tmp.xs_int + xn < 0) xn = 0;
|
||||
xr = xs_fract + 0x80;
|
||||
}
|
||||
else if(xs_fract > 0x90) {
|
||||
xn = 1;
|
||||
if(dsc->tmp.xs_int + xn >= dsc->cfg.src_w) xn = 0;
|
||||
xr = (0xFF - xs_fract) + 0x80;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
xn = 0;
|
||||
xr = 0xFF;
|
||||
}
|
||||
@@ -603,16 +641,18 @@ static inline bool transform_anti_alias(lv_img_transform_dsc_t * dsc)
|
||||
lv_opa_t yr; /*x mix ratio*/
|
||||
|
||||
if(ys_fract < 0x70) {
|
||||
yn = - 1;
|
||||
if(dsc->tmp.ys_int + yn < 0) yn = 0;
|
||||
yn = - 1;
|
||||
if(dsc->tmp.ys_int + yn < 0) yn = 0;
|
||||
|
||||
yr = ys_fract + 0x80;
|
||||
} else if(ys_fract > 0x90) {
|
||||
yr = ys_fract + 0x80;
|
||||
}
|
||||
else if(ys_fract > 0x90) {
|
||||
yn = 1;
|
||||
if(dsc->tmp.ys_int + yn >= dsc->cfg.src_h) yn = 0;
|
||||
|
||||
yr = (0xFF - ys_fract) + 0x80;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
yn = 0;
|
||||
yr = 0xFF;
|
||||
}
|
||||
@@ -630,13 +670,15 @@ static inline bool transform_anti_alias(lv_img_transform_dsc_t * dsc)
|
||||
if(dsc->tmp.native_color) {
|
||||
memcpy(&c01, &src_u8[dsc->tmp.pxi + dsc->tmp.px_size * xn], sizeof(lv_color_t));
|
||||
memcpy(&c10, &src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn], sizeof(lv_color_t));
|
||||
memcpy(&c11, &src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn + dsc->tmp.px_size * xn], sizeof(lv_color_t));
|
||||
memcpy(&c11, &src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn + dsc->tmp.px_size * xn],
|
||||
sizeof(lv_color_t));
|
||||
if(dsc->tmp.has_alpha) {
|
||||
a10 = src_u8[dsc->tmp.pxi + dsc->tmp.px_size * xn + dsc->tmp.px_size - 1];
|
||||
a01 = src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn + dsc->tmp.px_size - 1];
|
||||
a11 = src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn + dsc->tmp.px_size * xn + dsc->tmp.px_size - 1];
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
c01 = lv_img_buf_get_px_color(&dsc->tmp.img_dsc, dsc->tmp.xs_int + xn, dsc->tmp.ys_int, dsc->cfg.color);
|
||||
c10 = lv_img_buf_get_px_color(&dsc->tmp.img_dsc, dsc->tmp.xs_int, dsc->tmp.ys_int + yn, dsc->cfg.color);
|
||||
c11 = lv_img_buf_get_px_color(&dsc->tmp.img_dsc, dsc->tmp.xs_int + xn, dsc->tmp.ys_int + yn, dsc->cfg.color);
|
||||
@@ -662,7 +704,8 @@ static inline bool transform_anti_alias(lv_img_transform_dsc_t * dsc)
|
||||
if(a10 <= LV_OPA_MIN) xr0 = LV_OPA_COVER;
|
||||
if(a01 <= LV_OPA_MIN) xr1 = LV_OPA_TRANSP;
|
||||
if(a11 <= LV_OPA_MIN) xr1 = LV_OPA_COVER;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
xr0 = xr;
|
||||
xr1 = xr;
|
||||
dsc->res.opa = LV_OPA_COVER;
|
||||
|
||||
+13
-14
@@ -103,8 +103,7 @@ typedef uint8_t lv_img_cf_t;
|
||||
/**
|
||||
* LittlevGL image header
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
|
||||
/* The first 8 bit is very important to distinguish the different source types.
|
||||
* For more info see `lv_img_get_src_type()` in lv_img.c */
|
||||
@@ -121,8 +120,7 @@ typedef struct
|
||||
|
||||
/** Image header it is compatible with
|
||||
* the result from image converter utility*/
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
lv_img_header_t header;
|
||||
uint32_t data_size;
|
||||
const uint8_t * data;
|
||||
@@ -140,12 +138,12 @@ typedef struct {
|
||||
lv_color_t color; /*a color used for `LV_IMG_CF_INDEXED_1/2/4/8BIT` color formats*/
|
||||
lv_img_cf_t cf; /*color format of the image to rotate*/
|
||||
bool antialias;
|
||||
}cfg;
|
||||
} cfg;
|
||||
|
||||
struct {
|
||||
lv_color_t color;
|
||||
lv_opa_t opa;
|
||||
}res;
|
||||
} res;
|
||||
|
||||
|
||||
struct {
|
||||
@@ -155,9 +153,9 @@ typedef struct {
|
||||
int32_t sinma;
|
||||
int32_t cosma;
|
||||
|
||||
uint8_t chroma_keyed :1;
|
||||
uint8_t has_alpha :1;
|
||||
uint8_t native_color :1;
|
||||
uint8_t chroma_keyed : 1;
|
||||
uint8_t has_alpha : 1;
|
||||
uint8_t native_color : 1;
|
||||
|
||||
uint16_t zoom_inv;
|
||||
|
||||
@@ -168,8 +166,8 @@ typedef struct {
|
||||
lv_coord_t ys_int;
|
||||
uint32_t pxi;
|
||||
uint8_t px_size;
|
||||
}tmp;
|
||||
}lv_img_transform_dsc_t;
|
||||
} tmp;
|
||||
} lv_img_transform_dsc_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
@@ -182,7 +180,7 @@ typedef struct {
|
||||
* @param cf a color format (`LV_IMG_CF_...`)
|
||||
* @return an allocated image, or NULL on failure
|
||||
*/
|
||||
lv_img_dsc_t *lv_img_buf_alloc(lv_coord_t w, lv_coord_t h, lv_img_cf_t cf);
|
||||
lv_img_dsc_t * lv_img_buf_alloc(lv_coord_t w, lv_coord_t h, lv_img_cf_t cf);
|
||||
|
||||
/**
|
||||
* Get the color of an image's pixel
|
||||
@@ -242,7 +240,7 @@ void lv_img_buf_set_palette(lv_img_dsc_t * dsc, uint8_t id, lv_color_t c);
|
||||
* Free an allocated image buffer
|
||||
* @param dsc image buffer to free
|
||||
*/
|
||||
void lv_img_buf_free(lv_img_dsc_t *dsc);
|
||||
void lv_img_buf_free(lv_img_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Get the memory consumption of a raw bitmap, given color format and dimensions.
|
||||
@@ -279,7 +277,8 @@ bool lv_img_buf_transform(lv_img_transform_dsc_t * dsc, lv_coord_t x, lv_coord_t
|
||||
* @param zoom zoom, (256 no zoom)
|
||||
* @param pivot x,y pivot coordinates of rotation
|
||||
*/
|
||||
void lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t h, int16_t angle, uint16_t zoom, lv_point_t * pivot);
|
||||
void lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t h, int16_t angle, uint16_t zoom,
|
||||
lv_point_t * pivot);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "../lv_misc/lv_gc.h"
|
||||
|
||||
#if defined(LV_GC_INCLUDE)
|
||||
#include LV_GC_INCLUDE
|
||||
#include LV_GC_INCLUDE
|
||||
#endif /* LV_ENABLE_GC */
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -30,7 +30,7 @@
|
||||
#define LV_IMG_CACHE_LIFE_LIMIT 1000
|
||||
|
||||
#if LV_IMG_CACHE_DEF_SIZE < 1
|
||||
#error "LV_IMG_CACHE_DEF_SIZE must be >= 1. See lv_conf.h"
|
||||
#error "LV_IMG_CACHE_DEF_SIZE must be >= 1. See lv_conf.h"
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
@@ -86,7 +86,8 @@ lv_img_cache_entry_t * lv_img_cache_open(const void * src, lv_color_t color)
|
||||
lv_img_src_t src_type = lv_img_src_get_type(cache[i].dec_dsc.src);
|
||||
if(src_type == LV_IMG_SRC_VARIABLE) {
|
||||
if(cache[i].dec_dsc.src == src && cache[i].dec_dsc.color.full == color.full) match = true;
|
||||
} else if(src_type == LV_IMG_SRC_FILE) {
|
||||
}
|
||||
else if(src_type == LV_IMG_SRC_FILE) {
|
||||
if(strcmp(cache[i].dec_dsc.src, src) == 0) match = true;
|
||||
}
|
||||
|
||||
@@ -116,7 +117,8 @@ lv_img_cache_entry_t * lv_img_cache_open(const void * src, lv_color_t color)
|
||||
if(cached_src->dec_dsc.src) {
|
||||
lv_img_decoder_close(&cached_src->dec_dsc);
|
||||
LV_LOG_INFO("image draw: cache miss, close and reuse an entry");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
LV_LOG_INFO("image draw: cache miss, cached to an empty entry");
|
||||
}
|
||||
|
||||
|
||||
@@ -25,11 +25,10 @@ extern "C" {
|
||||
|
||||
/**
|
||||
* When loading images from the network it can take a long time to download and decode the image.
|
||||
*
|
||||
*
|
||||
* To avoid repeating this heavy load images can be cached.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
lv_img_decoder_dsc_t dec_dsc; /**< Image information */
|
||||
|
||||
/** Count the cache entries's life. Add `time_tio_open` to `life` when the entry is used.
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "../lv_misc/lv_gc.h"
|
||||
|
||||
#if defined(LV_GC_INCLUDE)
|
||||
#include LV_GC_INCLUDE
|
||||
#include LV_GC_INCLUDE
|
||||
#endif /* LV_ENABLE_GC */
|
||||
|
||||
/*********************
|
||||
@@ -26,8 +26,7 @@
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
#if LV_USE_FILESYSTEM
|
||||
lv_fs_file_t * f;
|
||||
#endif
|
||||
@@ -93,8 +92,7 @@ lv_res_t lv_img_decoder_get_info(const char * src, lv_img_header_t * header)
|
||||
|
||||
lv_res_t res = LV_RES_INV;
|
||||
lv_img_decoder_t * d;
|
||||
LV_LL_READ(LV_GC_ROOT(_lv_img_defoder_ll), d)
|
||||
{
|
||||
LV_LL_READ(LV_GC_ROOT(_lv_img_defoder_ll), d) {
|
||||
res = LV_RES_INV;
|
||||
if(d->info_cb) {
|
||||
res = d->info_cb(d, src, header);
|
||||
@@ -127,15 +125,15 @@ lv_res_t lv_img_decoder_open(lv_img_decoder_dsc_t * dsc, const void * src, lv_co
|
||||
size_t fnlen = strlen(src);
|
||||
dsc->src = lv_mem_alloc(fnlen + 1);
|
||||
strcpy((char *)dsc->src, src);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
dsc->src = src;
|
||||
}
|
||||
|
||||
lv_res_t res = LV_RES_INV;
|
||||
|
||||
lv_img_decoder_t * d;
|
||||
LV_LL_READ(LV_GC_ROOT(_lv_img_defoder_ll), d)
|
||||
{
|
||||
LV_LL_READ(LV_GC_ROOT(_lv_img_defoder_ll), d) {
|
||||
/*Info an Open callbacks are required*/
|
||||
if(d->info_cb == NULL || d->open_cb == NULL) continue;
|
||||
|
||||
@@ -305,7 +303,8 @@ lv_res_t lv_img_decoder_built_in_info(lv_img_decoder_t * decoder, const void * s
|
||||
/* Symbols always have transparent parts. Important because of cover check in the design
|
||||
* function. The actual value doesn't matter because lv_draw_label will draw it*/
|
||||
header->cf = LV_IMG_CF_ALPHA_1BIT;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("Image get info found unknown src type");
|
||||
return LV_RES_INV;
|
||||
}
|
||||
@@ -357,10 +356,11 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
|
||||
LV_LOG_WARN("Image built-in decoder cannot read file because LV_USE_FILESYSTEM = 0");
|
||||
return LV_RES_INV;
|
||||
#endif
|
||||
} else if(dsc->src_type == LV_IMG_SRC_VARIABLE) {
|
||||
/*The variables should have valid data*/
|
||||
}
|
||||
else if(dsc->src_type == LV_IMG_SRC_VARIABLE) {
|
||||
/*The variables should have valid data*/
|
||||
if(((lv_img_dsc_t *)dsc->src)->data == NULL) {
|
||||
return LV_RES_INV;
|
||||
return LV_RES_INV;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,7 +372,8 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
|
||||
* So simply give its pointer*/
|
||||
dsc->img_data = ((lv_img_dsc_t *)dsc->src)->data;
|
||||
return LV_RES_OK;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/*If it's a file it need to be read line by line later*/
|
||||
dsc->img_data = NULL;
|
||||
return LV_RES_OK;
|
||||
@@ -421,7 +422,8 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
|
||||
LV_LOG_WARN("Image built-in decoder can read the palette because LV_USE_FILESYSTEM = 0");
|
||||
return LV_RES_INV;
|
||||
#endif
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/*The palette begins in the beginning of the image data. Just point to it.*/
|
||||
lv_color32_t * palette_p = (lv_color32_t *)((lv_img_dsc_t *)dsc->src)->data;
|
||||
|
||||
@@ -473,7 +475,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
|
||||
* @return LV_RES_OK: ok; LV_RES_INV: failed
|
||||
*/
|
||||
lv_res_t lv_img_decoder_built_in_read_line(lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * dsc, lv_coord_t x,
|
||||
lv_coord_t y, lv_coord_t len, uint8_t * buf)
|
||||
lv_coord_t y, lv_coord_t len, uint8_t * buf)
|
||||
{
|
||||
(void)decoder; /*Unused*/
|
||||
|
||||
@@ -486,14 +488,17 @@ lv_res_t lv_img_decoder_built_in_read_line(lv_img_decoder_t * decoder, lv_img_de
|
||||
if(dsc->src_type == LV_IMG_SRC_FILE) {
|
||||
res = lv_img_decoder_built_in_line_true_color(dsc, x, y, len, buf);
|
||||
}
|
||||
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT || dsc->header.cf == LV_IMG_CF_ALPHA_2BIT ||
|
||||
dsc->header.cf == LV_IMG_CF_ALPHA_4BIT || dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) {
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT || dsc->header.cf == LV_IMG_CF_ALPHA_2BIT ||
|
||||
dsc->header.cf == LV_IMG_CF_ALPHA_4BIT || dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) {
|
||||
|
||||
res = lv_img_decoder_built_in_line_alpha(dsc, x, y, len, buf);
|
||||
} else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT || dsc->header.cf == LV_IMG_CF_INDEXED_2BIT ||
|
||||
dsc->header.cf == LV_IMG_CF_INDEXED_4BIT || dsc->header.cf == LV_IMG_CF_INDEXED_8BIT) {
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT || dsc->header.cf == LV_IMG_CF_INDEXED_2BIT ||
|
||||
dsc->header.cf == LV_IMG_CF_INDEXED_4BIT || dsc->header.cf == LV_IMG_CF_INDEXED_8BIT) {
|
||||
res = lv_img_decoder_built_in_line_indexed(dsc, x, y, len, buf);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("Built-in image decoder read not supports the color format");
|
||||
return LV_RES_INV;
|
||||
}
|
||||
@@ -570,7 +575,8 @@ static lv_res_t lv_img_decoder_built_in_line_alpha(lv_img_decoder_dsc_t * dsc, l
|
||||
const lv_opa_t alpha1_opa_table[2] = {0, 255}; /*Opacity mapping with bpp = 1 (Just for compatibility)*/
|
||||
const lv_opa_t alpha2_opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping with bpp = 2*/
|
||||
const lv_opa_t alpha4_opa_table[16] = {0, 17, 34, 51, /*Opacity mapping with bpp = 4*/
|
||||
68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255};
|
||||
68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255
|
||||
};
|
||||
|
||||
/*Simply fill the buffer with the color. Later only the alpha value will be modified.*/
|
||||
lv_color_t bg_color = dsc->color;
|
||||
@@ -635,7 +641,8 @@ static lv_res_t lv_img_decoder_built_in_line_alpha(lv_img_decoder_dsc_t * dsc, l
|
||||
const lv_img_dsc_t * img_dsc = dsc->src;
|
||||
|
||||
data_tmp = img_dsc->data + ofs;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
#if LV_USE_FILESYSTEM
|
||||
lv_fs_seek(user_data->f, ofs + 4); /*+4 to skip the header*/
|
||||
lv_fs_read(user_data->f, fs_buf, w, NULL);
|
||||
@@ -720,7 +727,8 @@ static lv_res_t lv_img_decoder_built_in_line_indexed(lv_img_decoder_dsc_t * dsc,
|
||||
if(dsc->src_type == LV_IMG_SRC_VARIABLE) {
|
||||
const lv_img_dsc_t * img_dsc = dsc->src;
|
||||
data_tmp = img_dsc->data + ofs;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
#if LV_USE_FILESYSTEM
|
||||
lv_fs_seek(user_data->f, ofs + 4); /*+4 to skip the header*/
|
||||
lv_fs_read(user_data->f, fs_buf, w, NULL);
|
||||
|
||||
@@ -84,8 +84,7 @@ typedef lv_res_t (*lv_img_decoder_read_line_f_t)(struct _lv_img_decoder * decode
|
||||
*/
|
||||
typedef void (*lv_img_decoder_close_f_t)(struct _lv_img_decoder * decoder, struct _lv_img_decoder_dsc * dsc);
|
||||
|
||||
typedef struct _lv_img_decoder
|
||||
{
|
||||
typedef struct _lv_img_decoder {
|
||||
lv_img_decoder_info_f_t info_cb;
|
||||
lv_img_decoder_open_f_t open_cb;
|
||||
lv_img_decoder_read_line_f_t read_line_cb;
|
||||
@@ -97,8 +96,7 @@ typedef struct _lv_img_decoder
|
||||
} lv_img_decoder_t;
|
||||
|
||||
/**Describe an image decoding session. Stores data about the decoding*/
|
||||
typedef struct _lv_img_decoder_dsc
|
||||
{
|
||||
typedef struct _lv_img_decoder_dsc {
|
||||
/**The decoder which was able to open the image source*/
|
||||
lv_img_decoder_t * decoder;
|
||||
|
||||
@@ -254,7 +252,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
|
||||
* @return LV_RES_OK: ok; LV_RES_INV: failed
|
||||
*/
|
||||
lv_res_t lv_img_decoder_built_in_read_line(lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * dsc, lv_coord_t x,
|
||||
lv_coord_t y, lv_coord_t len, uint8_t * buf);
|
||||
lv_coord_t y, lv_coord_t len, uint8_t * buf);
|
||||
|
||||
/**
|
||||
* Close the pending decoding. Free resources etc.
|
||||
|
||||
@@ -58,7 +58,8 @@ const uint8_t * lv_font_get_glyph_bitmap(const lv_font_t * font_p, uint32_t lett
|
||||
* @return true: descriptor is successfully loaded into `dsc_out`.
|
||||
* false: the letter was not found, no data is loaded to `dsc_out`
|
||||
*/
|
||||
bool lv_font_get_glyph_dsc(const lv_font_t * font_p, lv_font_glyph_dsc_t * dsc_out, uint32_t letter, uint32_t letter_next)
|
||||
bool lv_font_get_glyph_dsc(const lv_font_t * font_p, lv_font_glyph_dsc_t * dsc_out, uint32_t letter,
|
||||
uint32_t letter_next)
|
||||
{
|
||||
return font_p->get_glyph_dsc(font_p, dsc_out, letter, letter_next);
|
||||
}
|
||||
|
||||
@@ -39,15 +39,14 @@ extern "C" {
|
||||
*-----------------*/
|
||||
|
||||
/** Describes the properties of a glyph. */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
uint16_t adv_w; /**< The glyph needs this space. Draw the next glyph after this width. 8 bit integer, 4 bit fractional */
|
||||
uint16_t box_w; /**< Width of the glyph's bounding box*/
|
||||
uint16_t box_h; /**< Height of the glyph's bounding box*/
|
||||
int16_t ofs_x; /**< x offset of the bounding box*/
|
||||
int16_t ofs_y; /**< y offset of the bounding box*/
|
||||
uint8_t bpp; /**< Bit-per-pixel: 1, 2, 4, 8*/
|
||||
}lv_font_glyph_dsc_t;
|
||||
} lv_font_glyph_dsc_t;
|
||||
|
||||
|
||||
/** The bitmaps might be upscaled by 3 to achieve subpixel rendering. */
|
||||
@@ -61,8 +60,7 @@ enum {
|
||||
typedef uint8_t lv_font_subpx_t;
|
||||
|
||||
/** Describe the properties of a font*/
|
||||
typedef struct _lv_font_struct
|
||||
{
|
||||
typedef struct _lv_font_struct {
|
||||
/** Get a glyph's descriptor from a font*/
|
||||
bool (*get_glyph_dsc)(const struct _lv_font_struct *, lv_font_glyph_dsc_t *, uint32_t letter, uint32_t letter_next);
|
||||
|
||||
@@ -72,7 +70,7 @@ typedef struct _lv_font_struct
|
||||
/*Pointer to the font in a font pack (must have the same line height)*/
|
||||
lv_coord_t line_height; /**< The real line height where any text fits*/
|
||||
lv_coord_t base_line; /**< Base line measured from the top of the line_height*/
|
||||
uint8_t subpx :2; /**< An element of `lv_font_subpx_t`*/
|
||||
uint8_t subpx : 2; /**< An element of `lv_font_subpx_t`*/
|
||||
void * dsc; /**< Store implementation specific or run_time data or caching here*/
|
||||
#if LV_USE_USER_DATA
|
||||
lv_font_user_data_t user_data; /**< Custom user data for font. */
|
||||
@@ -101,7 +99,8 @@ const uint8_t * lv_font_get_glyph_bitmap(const lv_font_t * font_p, uint32_t lett
|
||||
* @return true: descriptor is successfully loaded into `dsc_out`.
|
||||
* false: the letter was not found, no data is loaded to `dsc_out`
|
||||
*/
|
||||
bool lv_font_get_glyph_dsc(const lv_font_t * font_p, lv_font_glyph_dsc_t * dsc_out, uint32_t letter, uint32_t letter_next);
|
||||
bool lv_font_get_glyph_dsc(const lv_font_t * font_p, lv_font_glyph_dsc_t * dsc_out, uint32_t letter,
|
||||
uint32_t letter_next);
|
||||
|
||||
/**
|
||||
* Get the width of a glyph with kerning
|
||||
|
||||
@@ -26,7 +26,7 @@ typedef enum {
|
||||
RLE_STATE_SINGLE = 0,
|
||||
RLE_STATE_REPEATE,
|
||||
RLE_STATE_COUNTER,
|
||||
}rle_state_t;
|
||||
} rle_state_t;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
@@ -76,7 +76,7 @@ static rle_state_t rle_state;
|
||||
*/
|
||||
const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unicode_letter)
|
||||
{
|
||||
if(unicode_letter == '\t') unicode_letter = ' ';
|
||||
if(unicode_letter == '\t') unicode_letter = ' ';
|
||||
|
||||
lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *) font->dsc;
|
||||
uint32_t gid = get_glyph_dsc_id(font, unicode_letter);
|
||||
@@ -88,8 +88,7 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic
|
||||
if(gdsc) return &fdsc->glyph_bitmap[gdsc->bitmap_index];
|
||||
}
|
||||
/*Handle compressed bitmap*/
|
||||
else
|
||||
{
|
||||
else {
|
||||
static uint8_t * buf = NULL;
|
||||
|
||||
uint32_t gsize = gdsc->box_w * gdsc->box_h;
|
||||
@@ -97,10 +96,18 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic
|
||||
|
||||
uint32_t buf_size = gsize;
|
||||
switch(fdsc->bpp) {
|
||||
case 1: buf_size = gsize >> 3; break;
|
||||
case 2: buf_size = gsize >> 2; break;
|
||||
case 3: buf_size = gsize >> 1; break;
|
||||
case 4: buf_size = gsize >> 1; break;
|
||||
case 1:
|
||||
buf_size = gsize >> 3;
|
||||
break;
|
||||
case 2:
|
||||
buf_size = gsize >> 2;
|
||||
break;
|
||||
case 3:
|
||||
buf_size = gsize >> 1;
|
||||
break;
|
||||
case 4:
|
||||
buf_size = gsize >> 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if(lv_mem_get_size(buf) < buf_size) {
|
||||
@@ -109,7 +116,7 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic
|
||||
if(buf == NULL) return NULL;
|
||||
}
|
||||
|
||||
decompress(&fdsc->glyph_bitmap[gdsc->bitmap_index], buf, gdsc->box_w , gdsc->box_h, (uint8_t)fdsc->bpp);
|
||||
decompress(&fdsc->glyph_bitmap[gdsc->bitmap_index], buf, gdsc->box_w, gdsc->box_h, (uint8_t)fdsc->bpp);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -125,13 +132,14 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic
|
||||
* @return true: descriptor is successfully loaded into `dsc_out`.
|
||||
* false: the letter was not found, no data is loaded to `dsc_out`
|
||||
*/
|
||||
bool lv_font_get_glyph_dsc_fmt_txt(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next)
|
||||
bool lv_font_get_glyph_dsc_fmt_txt(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter,
|
||||
uint32_t unicode_letter_next)
|
||||
{
|
||||
bool is_tab = false;
|
||||
if(unicode_letter == '\t') {
|
||||
unicode_letter = ' ';
|
||||
is_tab = true;
|
||||
}
|
||||
bool is_tab = false;
|
||||
if(unicode_letter == '\t') {
|
||||
unicode_letter = ' ';
|
||||
is_tab = true;
|
||||
}
|
||||
lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *) font->dsc;
|
||||
uint32_t gid = get_glyph_dsc_id(font, unicode_letter);
|
||||
if(!gid) return false;
|
||||
@@ -195,7 +203,8 @@ static uint32_t get_glyph_dsc_id(const lv_font_t * font, uint32_t letter)
|
||||
glyph_id = fdsc->cmaps[i].glyph_id_start + gid_ofs_8[rcp];
|
||||
}
|
||||
else if(fdsc->cmaps[i].type == LV_FONT_FMT_TXT_CMAP_SPARSE_TINY) {
|
||||
uint8_t * p = lv_utils_bsearch(&rcp, fdsc->cmaps[i].unicode_list, fdsc->cmaps[i].list_length, sizeof(fdsc->cmaps[i].unicode_list[0]), unicode_list_compare);
|
||||
uint8_t * p = lv_utils_bsearch(&rcp, fdsc->cmaps[i].unicode_list, fdsc->cmaps[i].list_length,
|
||||
sizeof(fdsc->cmaps[i].unicode_list[0]), unicode_list_compare);
|
||||
|
||||
if(p) {
|
||||
lv_uintptr_t ofs = (lv_uintptr_t)(p - (uint8_t *) fdsc->cmaps[i].unicode_list);
|
||||
@@ -204,10 +213,11 @@ static uint32_t get_glyph_dsc_id(const lv_font_t * font, uint32_t letter)
|
||||
}
|
||||
}
|
||||
else if(fdsc->cmaps[i].type == LV_FONT_FMT_TXT_CMAP_SPARSE_FULL) {
|
||||
uint8_t * p = lv_utils_bsearch(&rcp, fdsc->cmaps[i].unicode_list, fdsc->cmaps[i].list_length, sizeof(fdsc->cmaps[i].unicode_list[0]), unicode_list_compare);
|
||||
uint8_t * p = lv_utils_bsearch(&rcp, fdsc->cmaps[i].unicode_list, fdsc->cmaps[i].list_length,
|
||||
sizeof(fdsc->cmaps[i].unicode_list[0]), unicode_list_compare);
|
||||
|
||||
if(p) {
|
||||
lv_uintptr_t ofs = (lv_uintptr_t)(p - (uint8_t*) fdsc->cmaps[i].unicode_list);
|
||||
lv_uintptr_t ofs = (lv_uintptr_t)(p - (uint8_t *) fdsc->cmaps[i].unicode_list);
|
||||
ofs = ofs >> 1; /*The list stores `uint16_t` so the get the index divide by 2*/
|
||||
const uint8_t * gid_ofs_16 = fdsc->cmaps[i].glyph_id_ofs_list;
|
||||
glyph_id = fdsc->cmaps[i].glyph_id_start + gid_ofs_16[ofs];
|
||||
@@ -248,7 +258,8 @@ static int8_t get_kern_value(const lv_font_t * font, uint32_t gid_left, uint32_t
|
||||
ofs = ofs >> 1; /*ofs is for pair, divide by 2 to refer as a single value*/
|
||||
value = kdsc->values[ofs];
|
||||
}
|
||||
} else if(kdsc->glyph_ids_size == 1) {
|
||||
}
|
||||
else if(kdsc->glyph_ids_size == 1) {
|
||||
/* Use binary search to find the kern value.
|
||||
* The pairs are ordered left_id first, then right_id secondly. */
|
||||
const uint16_t * g_ids = kdsc->glyph_ids;
|
||||
@@ -257,15 +268,17 @@ static int8_t get_kern_value(const lv_font_t * font, uint32_t gid_left, uint32_t
|
||||
|
||||
/*If the `g_id_both` were found get its index from the pointer*/
|
||||
if(kid_p) {
|
||||
lv_uintptr_t ofs = (lv_uintptr_t) (kid_p - (const uint8_t *)g_ids);
|
||||
lv_uintptr_t ofs = (lv_uintptr_t)(kid_p - (const uint8_t *)g_ids);
|
||||
ofs = ofs >> 4; /*ofs is 4 byte pairs, divide by 4 to refer as a single value*/
|
||||
value = kdsc->values[ofs];
|
||||
}
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/*Invalid value*/
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/*Kern classes*/
|
||||
const lv_font_fmt_txt_kern_classes_t * kdsc = fdsc->kern_dsc;
|
||||
uint8_t left_class = kdsc->left_class_mapping[gid_left];
|
||||
@@ -274,7 +287,7 @@ static int8_t get_kern_value(const lv_font_t * font, uint32_t gid_left, uint32_t
|
||||
/* If class = 0, kerning not exist for that glyph
|
||||
* else got the value form `class_pair_values` 2D array*/
|
||||
if(left_class > 0 && right_class > 0) {
|
||||
value = kdsc->class_pair_values[(left_class-1)* kdsc->right_class_cnt + (right_class-1)];
|
||||
value = kdsc->class_pair_values[(left_class - 1) * kdsc->right_class_cnt + (right_class - 1)];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -325,7 +338,7 @@ static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord
|
||||
lv_coord_t y;
|
||||
lv_coord_t x;
|
||||
for(x = 0; x < w; x++) {
|
||||
bits_write(out,wrp, line_buf1[x], bpp);
|
||||
bits_write(out, wrp, line_buf1[x], bpp);
|
||||
wrp += wr_size;
|
||||
}
|
||||
|
||||
@@ -334,7 +347,7 @@ static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord
|
||||
|
||||
for(x = 0; x < w; x++) {
|
||||
line_buf1[x] = line_buf2[x] ^ line_buf1[x];
|
||||
bits_write(out,wrp, line_buf1[x], bpp);
|
||||
bits_write(out, wrp, line_buf1[x], bpp);
|
||||
wrp += wr_size;
|
||||
}
|
||||
}
|
||||
@@ -388,14 +401,30 @@ static void bits_write(uint8_t * out, uint32_t bit_pos, uint8_t val, uint8_t len
|
||||
if(len == 3) {
|
||||
len = 4;
|
||||
switch(val) {
|
||||
case 0: val = 0; break;
|
||||
case 1: val = 2; break;
|
||||
case 2: val = 4; break;
|
||||
case 3: val = 6; break;
|
||||
case 4: val = 9; break;
|
||||
case 5: val = 11; break;
|
||||
case 6: val = 13; break;
|
||||
case 7: val = 15; break;
|
||||
case 0:
|
||||
val = 0;
|
||||
break;
|
||||
case 1:
|
||||
val = 2;
|
||||
break;
|
||||
case 2:
|
||||
val = 4;
|
||||
break;
|
||||
case 3:
|
||||
val = 6;
|
||||
break;
|
||||
case 4:
|
||||
val = 9;
|
||||
break;
|
||||
case 5:
|
||||
val = 11;
|
||||
break;
|
||||
case 6:
|
||||
val = 13;
|
||||
break;
|
||||
case 7:
|
||||
val = 15;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -444,14 +473,16 @@ static uint8_t rle_next(void)
|
||||
rle_rdp += 6;
|
||||
if(rle_cnt != 0) {
|
||||
rle_state = RLE_STATE_COUNTER;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ret = get_bits(rle_in, rle_rdp, rle_bpp);
|
||||
rle_prev_v = ret;
|
||||
rle_rdp += rle_bpp;
|
||||
rle_state = RLE_STATE_SINGLE;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ret = get_bits(rle_in, rle_rdp, rle_bpp);
|
||||
rle_prev_v = ret;
|
||||
rle_rdp += rle_bpp;
|
||||
|
||||
@@ -27,11 +27,10 @@ extern "C" {
|
||||
**********************/
|
||||
|
||||
/** This describes a glyph. */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
#if LV_FONT_FMT_TXT_LARGE == 0
|
||||
uint32_t bitmap_index : 20; /**< Start index of the bitmap. A font can be max 1 MB. */
|
||||
uint32_t adv_w :12; /**< Draw the next glyph after this width. 8.4 format (real_value * 16 is stored). */
|
||||
uint32_t adv_w : 12; /**< Draw the next glyph after this width. 8.4 format (real_value * 16 is stored). */
|
||||
uint8_t box_w; /**< Width of the glyph's bounding box*/
|
||||
uint8_t box_h; /**< Height of the glyph's bounding box*/
|
||||
int8_t ofs_x; /**< x offset of the bounding box*/
|
||||
@@ -44,7 +43,7 @@ typedef struct
|
||||
int16_t ofs_x; /**< x offset of the bounding box*/
|
||||
int16_t ofs_y; /**< y offset of the bounding box. Measured from the top of the line*/
|
||||
#endif
|
||||
}lv_font_fmt_txt_glyph_dsc_t;
|
||||
} lv_font_fmt_txt_glyph_dsc_t;
|
||||
|
||||
|
||||
/** Format of font character map. */
|
||||
@@ -112,7 +111,7 @@ typedef struct {
|
||||
|
||||
/** Type of this character map*/
|
||||
lv_font_fmt_txt_cmap_type_t type;
|
||||
}lv_font_fmt_txt_cmap_t;
|
||||
} lv_font_fmt_txt_cmap_t;
|
||||
|
||||
/** A simple mapping of kern values from pairs*/
|
||||
typedef struct {
|
||||
@@ -125,9 +124,9 @@ typedef struct {
|
||||
*/
|
||||
const void * glyph_ids;
|
||||
const int8_t * values;
|
||||
uint32_t pair_cnt :24;
|
||||
uint32_t glyph_ids_size :2; /*0: `glyph_ids` is stored as `uint8_t`; 1: as `uint16_t`*/
|
||||
}lv_font_fmt_txt_kern_pair_t;
|
||||
uint32_t pair_cnt : 24;
|
||||
uint32_t glyph_ids_size : 2; /*0: `glyph_ids` is stored as `uint8_t`; 1: as `uint16_t`*/
|
||||
} lv_font_fmt_txt_kern_pair_t;
|
||||
|
||||
/** More complex but more optimal class based kern value storage*/
|
||||
typedef struct {
|
||||
@@ -144,14 +143,14 @@ typedef struct {
|
||||
const uint8_t * right_class_mapping; /*Map the glyph_ids to classes: index -> glyph_id -> class_id*/
|
||||
uint8_t left_class_cnt;
|
||||
uint8_t right_class_cnt;
|
||||
}lv_font_fmt_txt_kern_classes_t;
|
||||
} lv_font_fmt_txt_kern_classes_t;
|
||||
|
||||
|
||||
/** Bitmap formats*/
|
||||
typedef enum {
|
||||
LV_FONT_FMT_TXT_PLAIN = 0,
|
||||
LV_FONT_FMT_TXT_COMPRESSED = 1,
|
||||
}lv_font_fmt_txt_bitmap_format_t;
|
||||
} lv_font_fmt_txt_bitmap_format_t;
|
||||
|
||||
|
||||
/*Describe store additional data for fonts */
|
||||
@@ -176,25 +175,25 @@ typedef struct {
|
||||
uint16_t kern_scale;
|
||||
|
||||
/*Number of cmap tables*/
|
||||
uint16_t cmap_num :10;
|
||||
uint16_t cmap_num : 10;
|
||||
|
||||
/*Bit per pixel: 1, 2, 3, 4*/
|
||||
uint16_t bpp :3;
|
||||
uint16_t bpp : 3;
|
||||
|
||||
/*Type of `kern_dsc`*/
|
||||
uint16_t kern_classes :1;
|
||||
uint16_t kern_classes : 1;
|
||||
|
||||
/*
|
||||
* storage format of the bitmap
|
||||
* from `lv_font_fmt_txt_bitmap_format_t`
|
||||
*/
|
||||
uint16_t bitmap_format :2;
|
||||
uint16_t bitmap_format : 2;
|
||||
|
||||
/*Cache the last letter and is glyph id*/
|
||||
uint32_t last_letter;
|
||||
uint32_t last_glyph_id;
|
||||
|
||||
}lv_font_fmt_txt_dsc_t;
|
||||
} lv_font_fmt_txt_dsc_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
@@ -216,7 +215,8 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t lett
|
||||
* @return true: descriptor is successfully loaded into `dsc_out`.
|
||||
* false: the letter was not found, no data is loaded to `dsc_out`
|
||||
*/
|
||||
bool lv_font_get_glyph_dsc_fmt_txt(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next);
|
||||
bool lv_font_get_glyph_dsc_fmt_txt(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter,
|
||||
uint32_t unicode_letter_next);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef LV_FONT_ROBOTO_12
|
||||
#define LV_FONT_ROBOTO_12 1
|
||||
#define LV_FONT_ROBOTO_12 1
|
||||
#endif
|
||||
|
||||
#if LV_FONT_ROBOTO_12
|
||||
@@ -1334,8 +1334,7 @@ static const uint16_t unicode_list_1[] = {
|
||||
};
|
||||
|
||||
/*Collect the unicode lists and glyph_id offsets*/
|
||||
static const lv_font_fmt_txt_cmap_t cmaps[] =
|
||||
{
|
||||
static const lv_font_fmt_txt_cmap_t cmaps[] = {
|
||||
{
|
||||
.range_start = 32, .range_length = 95, .glyph_id_start = 1,
|
||||
.unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY
|
||||
@@ -1352,8 +1351,7 @@ static const lv_font_fmt_txt_cmap_t cmaps[] =
|
||||
|
||||
|
||||
/*Map glyph_ids to kern left classes*/
|
||||
static const uint8_t kern_left_class_mapping[] =
|
||||
{
|
||||
static const uint8_t kern_left_class_mapping[] = {
|
||||
0, 1, 0, 2, 0, 0, 0, 0,
|
||||
2, 3, 0, 0, 0, 4, 0, 4,
|
||||
5, 0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -1377,8 +1375,7 @@ static const uint8_t kern_left_class_mapping[] =
|
||||
};
|
||||
|
||||
/*Map glyph_ids to kern right classes*/
|
||||
static const uint8_t kern_right_class_mapping[] =
|
||||
{
|
||||
static const uint8_t kern_right_class_mapping[] = {
|
||||
0, 1, 0, 2, 0, 0, 0, 3,
|
||||
2, 0, 4, 5, 0, 6, 7, 6,
|
||||
8, 0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -1402,8 +1399,7 @@ static const uint8_t kern_right_class_mapping[] =
|
||||
};
|
||||
|
||||
/*Kern values between classes*/
|
||||
static const int8_t kern_class_values[] =
|
||||
{
|
||||
static const int8_t kern_class_values[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -4, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -1583,8 +1579,7 @@ static const int8_t kern_class_values[] =
|
||||
|
||||
|
||||
/*Collect the kern class' data in one place*/
|
||||
static const lv_font_fmt_txt_kern_classes_t kern_classes =
|
||||
{
|
||||
static const lv_font_fmt_txt_kern_classes_t kern_classes = {
|
||||
.class_pair_values = kern_class_values,
|
||||
.left_class_mapping = kern_left_class_mapping,
|
||||
.right_class_mapping = kern_right_class_mapping,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef LV_FONT_ROBOTO_12_SUBPX
|
||||
#define LV_FONT_ROBOTO_12_SUBPX 1
|
||||
#define LV_FONT_ROBOTO_12_SUBPX 1
|
||||
#endif
|
||||
|
||||
#if LV_FONT_ROBOTO_12_SUBPX
|
||||
@@ -3125,8 +3125,7 @@ static const uint16_t unicode_list_1[] = {
|
||||
};
|
||||
|
||||
/*Collect the unicode lists and glyph_id offsets*/
|
||||
static const lv_font_fmt_txt_cmap_t cmaps[] =
|
||||
{
|
||||
static const lv_font_fmt_txt_cmap_t cmaps[] = {
|
||||
{
|
||||
.range_start = 32, .range_length = 95, .glyph_id_start = 1,
|
||||
.unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY
|
||||
@@ -3143,8 +3142,7 @@ static const lv_font_fmt_txt_cmap_t cmaps[] =
|
||||
|
||||
|
||||
/*Map glyph_ids to kern left classes*/
|
||||
static const uint8_t kern_left_class_mapping[] =
|
||||
{
|
||||
static const uint8_t kern_left_class_mapping[] = {
|
||||
0, 1, 0, 2, 0, 0, 0, 0,
|
||||
2, 3, 0, 0, 0, 4, 0, 4,
|
||||
5, 0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -3168,8 +3166,7 @@ static const uint8_t kern_left_class_mapping[] =
|
||||
};
|
||||
|
||||
/*Map glyph_ids to kern right classes*/
|
||||
static const uint8_t kern_right_class_mapping[] =
|
||||
{
|
||||
static const uint8_t kern_right_class_mapping[] = {
|
||||
0, 1, 0, 2, 0, 0, 0, 3,
|
||||
2, 0, 4, 5, 0, 6, 7, 6,
|
||||
8, 0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -3193,8 +3190,7 @@ static const uint8_t kern_right_class_mapping[] =
|
||||
};
|
||||
|
||||
/*Kern values between classes*/
|
||||
static const int8_t kern_class_values[] =
|
||||
{
|
||||
static const int8_t kern_class_values[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -4, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -3374,8 +3370,7 @@ static const int8_t kern_class_values[] =
|
||||
|
||||
|
||||
/*Collect the kern class' data in one place*/
|
||||
static const lv_font_fmt_txt_kern_classes_t kern_classes =
|
||||
{
|
||||
static const lv_font_fmt_txt_kern_classes_t kern_classes = {
|
||||
.class_pair_values = kern_class_values,
|
||||
.left_class_mapping = kern_left_class_mapping,
|
||||
.right_class_mapping = kern_right_class_mapping,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef LV_FONT_ROBOTO_16
|
||||
#define LV_FONT_ROBOTO_16 1
|
||||
#define LV_FONT_ROBOTO_16 1
|
||||
#endif
|
||||
|
||||
#if LV_FONT_ROBOTO_16
|
||||
@@ -1826,8 +1826,7 @@ static const uint16_t unicode_list_1[] = {
|
||||
};
|
||||
|
||||
/*Collect the unicode lists and glyph_id offsets*/
|
||||
static const lv_font_fmt_txt_cmap_t cmaps[] =
|
||||
{
|
||||
static const lv_font_fmt_txt_cmap_t cmaps[] = {
|
||||
{
|
||||
.range_start = 32, .range_length = 95, .glyph_id_start = 1,
|
||||
.unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY
|
||||
@@ -1844,8 +1843,7 @@ static const lv_font_fmt_txt_cmap_t cmaps[] =
|
||||
|
||||
|
||||
/*Pair left and right glyphs for kerning*/
|
||||
static const uint8_t kern_pair_glyph_ids[] =
|
||||
{
|
||||
static const uint8_t kern_pair_glyph_ids[] = {
|
||||
1, 53,
|
||||
3, 3,
|
||||
3, 8,
|
||||
@@ -2285,68 +2283,66 @@ static const uint8_t kern_pair_glyph_ids[] =
|
||||
|
||||
/* Kerning between the respective left and right glyphs
|
||||
* 4.4 format which needs to scaled with `kern_scale`*/
|
||||
static const int8_t kern_pair_values[] =
|
||||
{
|
||||
static const int8_t kern_pair_values[] = {
|
||||
-5, -13, -13, -15, -6, -7, -7, -7,
|
||||
-7, -2, -2, -8, -2, -7, -10, 1,
|
||||
-13, -13, -15, -6, -7, -7, -7, -7,
|
||||
-2, -2, -8, -2, -7, -10, 1, 3,
|
||||
2, 3, -21, -21, -21, -21, -28, -15,
|
||||
-15, -8, -1, -1, -1, -1, -16, -2,
|
||||
-11, -9, -12, -1, -2, -1, -6, -4,
|
||||
-6, 2, -3, -3, -7, -3, -4, -1,
|
||||
-2, -13, -13, -3, -3, -3, -3, -5,
|
||||
-3, 3, -2, -2, -2, -2, -2, -2,
|
||||
-2, -2, -3, -3, -3, -29, -29, -21,
|
||||
-33, 3, -4, -3, -3, -3, -3, -3,
|
||||
-3, -3, -3, -3, -3, 2, -4, 2,
|
||||
-3, 2, -4, 2, -3, -3, -8, -4,
|
||||
-4, -4, -4, -3, -3, -3, -3, -3,
|
||||
-3, -3, -3, -3, -3, -5, -8, -5,
|
||||
-42, -42, 2, -8, -8, -8, -8, -34,
|
||||
-7, -22, -18, -30, -5, -17, -11, -17,
|
||||
2, -4, 2, -3, 2, -4, 2, -3,
|
||||
-13, -13, -3, -3, -3, -3, -5, -3,
|
||||
-40, -40, -17, -25, -4, -3, -1, -2,
|
||||
-2, -2, -2, -2, -2, 2, 2, 2,
|
||||
-5, -3, -2, -4, -10, -2, -6, -5,
|
||||
-27, -29, -27, -10, -3, -3, -30, -3,
|
||||
-3, -2, 2, 2, 2, 2, -14, -12,
|
||||
-12, -12, -12, -14, -14, -12, -14, -12,
|
||||
-9, -14, -12, -9, -7, -10, -9, -7,
|
||||
-3, 3, -28, -5, -28, -9, -2, -2,
|
||||
-2, -2, 2, -6, -5, -5, -5, -5,
|
||||
-6, -5, -4, -3, -1, -1, 2, 2,
|
||||
-15, -7, -15, -5, 2, 2, -4, -4,
|
||||
-4, -4, -4, -4, -4, -3, -2, 2,
|
||||
-6, -3, -3, -3, -3, 2, -3, -3,
|
||||
-3, -3, -3, -3, -3, -4, -4, -4,
|
||||
3, -6, -26, -6, -26, -12, -4, -4,
|
||||
-12, -4, -4, -2, 2, -12, 2, 2,
|
||||
2, 2, 2, -9, -8, -8, -8, -3,
|
||||
-8, -5, -5, -8, -5, -8, -5, -7,
|
||||
-3, -5, -2, -3, -2, -4, 2, -6,
|
||||
2, -3, -3, -3, -3, -3, -3, -3,
|
||||
-3, -3, -3, -2, -3, -3, -3, -2,
|
||||
-2, -8, -8, -2, -2, -4, -4, -1,
|
||||
-2, -1, -2, -1, -1, -2, -2, -2,
|
||||
-2, 2, 2, 3, 2, -3, -3, -3,
|
||||
-3, -3, 2, -13, -13, -2, -2, -2,
|
||||
-2, -2, -13, -13, -13, -13, -17, -17,
|
||||
-2, -3, -2, -2, -4, -4, -1, -2,
|
||||
-1, -2, 2, 2, -15, -15, -5, -2,
|
||||
-2, -2, 2, -2, -2, -2, 6, 2,
|
||||
2, 2, -2, 2, 2, -13, -13, -2,
|
||||
-2, -2, -2, 2, -2, -2, -2, -15,
|
||||
-15, -2, -2, -2, -2, -2, -2, 2,
|
||||
2, -13, -13, -2, -2, -2, -2, 2,
|
||||
-2, -2, -2, -2, -2, -2, -2, -2,
|
||||
-2, -2, -2
|
||||
};
|
||||
-7, -2, -2, -8, -2, -7, -10, 1,
|
||||
-13, -13, -15, -6, -7, -7, -7, -7,
|
||||
-2, -2, -8, -2, -7, -10, 1, 3,
|
||||
2, 3, -21, -21, -21, -21, -28, -15,
|
||||
-15, -8, -1, -1, -1, -1, -16, -2,
|
||||
-11, -9, -12, -1, -2, -1, -6, -4,
|
||||
-6, 2, -3, -3, -7, -3, -4, -1,
|
||||
-2, -13, -13, -3, -3, -3, -3, -5,
|
||||
-3, 3, -2, -2, -2, -2, -2, -2,
|
||||
-2, -2, -3, -3, -3, -29, -29, -21,
|
||||
-33, 3, -4, -3, -3, -3, -3, -3,
|
||||
-3, -3, -3, -3, -3, 2, -4, 2,
|
||||
-3, 2, -4, 2, -3, -3, -8, -4,
|
||||
-4, -4, -4, -3, -3, -3, -3, -3,
|
||||
-3, -3, -3, -3, -3, -5, -8, -5,
|
||||
-42, -42, 2, -8, -8, -8, -8, -34,
|
||||
-7, -22, -18, -30, -5, -17, -11, -17,
|
||||
2, -4, 2, -3, 2, -4, 2, -3,
|
||||
-13, -13, -3, -3, -3, -3, -5, -3,
|
||||
-40, -40, -17, -25, -4, -3, -1, -2,
|
||||
-2, -2, -2, -2, -2, 2, 2, 2,
|
||||
-5, -3, -2, -4, -10, -2, -6, -5,
|
||||
-27, -29, -27, -10, -3, -3, -30, -3,
|
||||
-3, -2, 2, 2, 2, 2, -14, -12,
|
||||
-12, -12, -12, -14, -14, -12, -14, -12,
|
||||
-9, -14, -12, -9, -7, -10, -9, -7,
|
||||
-3, 3, -28, -5, -28, -9, -2, -2,
|
||||
-2, -2, 2, -6, -5, -5, -5, -5,
|
||||
-6, -5, -4, -3, -1, -1, 2, 2,
|
||||
-15, -7, -15, -5, 2, 2, -4, -4,
|
||||
-4, -4, -4, -4, -4, -3, -2, 2,
|
||||
-6, -3, -3, -3, -3, 2, -3, -3,
|
||||
-3, -3, -3, -3, -3, -4, -4, -4,
|
||||
3, -6, -26, -6, -26, -12, -4, -4,
|
||||
-12, -4, -4, -2, 2, -12, 2, 2,
|
||||
2, 2, 2, -9, -8, -8, -8, -3,
|
||||
-8, -5, -5, -8, -5, -8, -5, -7,
|
||||
-3, -5, -2, -3, -2, -4, 2, -6,
|
||||
2, -3, -3, -3, -3, -3, -3, -3,
|
||||
-3, -3, -3, -2, -3, -3, -3, -2,
|
||||
-2, -8, -8, -2, -2, -4, -4, -1,
|
||||
-2, -1, -2, -1, -1, -2, -2, -2,
|
||||
-2, 2, 2, 3, 2, -3, -3, -3,
|
||||
-3, -3, 2, -13, -13, -2, -2, -2,
|
||||
-2, -2, -13, -13, -13, -13, -17, -17,
|
||||
-2, -3, -2, -2, -4, -4, -1, -2,
|
||||
-1, -2, 2, 2, -15, -15, -5, -2,
|
||||
-2, -2, 2, -2, -2, -2, 6, 2,
|
||||
2, 2, -2, 2, 2, -13, -13, -2,
|
||||
-2, -2, -2, 2, -2, -2, -2, -15,
|
||||
-15, -2, -2, -2, -2, -2, -2, 2,
|
||||
2, -13, -13, -2, -2, -2, -2, 2,
|
||||
-2, -2, -2, -2, -2, -2, -2, -2,
|
||||
-2, -2, -2
|
||||
};
|
||||
|
||||
/*Collect the kern pair's data in one place*/
|
||||
static const lv_font_fmt_txt_kern_pair_t kern_pairs =
|
||||
{
|
||||
static const lv_font_fmt_txt_kern_pair_t kern_pairs = {
|
||||
.glyph_ids = kern_pair_glyph_ids,
|
||||
.values = kern_pair_values,
|
||||
.pair_cnt = 435,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef LV_FONT_ROBOTO_22
|
||||
#define LV_FONT_ROBOTO_22 1
|
||||
#define LV_FONT_ROBOTO_22 1
|
||||
#endif
|
||||
|
||||
#if LV_FONT_ROBOTO_22
|
||||
@@ -2930,8 +2930,7 @@ static const uint16_t unicode_list_1[] = {
|
||||
};
|
||||
|
||||
/*Collect the unicode lists and glyph_id offsets*/
|
||||
static const lv_font_fmt_txt_cmap_t cmaps[] =
|
||||
{
|
||||
static const lv_font_fmt_txt_cmap_t cmaps[] = {
|
||||
{
|
||||
.range_start = 32, .range_length = 95, .glyph_id_start = 1,
|
||||
.unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY
|
||||
@@ -2948,8 +2947,7 @@ static const lv_font_fmt_txt_cmap_t cmaps[] =
|
||||
|
||||
|
||||
/*Map glyph_ids to kern left classes*/
|
||||
static const uint8_t kern_left_class_mapping[] =
|
||||
{
|
||||
static const uint8_t kern_left_class_mapping[] = {
|
||||
0, 1, 0, 2, 0, 0, 0, 0,
|
||||
2, 3, 0, 0, 0, 4, 0, 4,
|
||||
5, 0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -2973,8 +2971,7 @@ static const uint8_t kern_left_class_mapping[] =
|
||||
};
|
||||
|
||||
/*Map glyph_ids to kern right classes*/
|
||||
static const uint8_t kern_right_class_mapping[] =
|
||||
{
|
||||
static const uint8_t kern_right_class_mapping[] = {
|
||||
0, 1, 0, 2, 0, 0, 0, 3,
|
||||
2, 0, 4, 5, 0, 6, 7, 6,
|
||||
8, 0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -2998,8 +2995,7 @@ static const uint8_t kern_right_class_mapping[] =
|
||||
};
|
||||
|
||||
/*Kern values between classes*/
|
||||
static const int8_t kern_class_values[] =
|
||||
{
|
||||
static const int8_t kern_class_values[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -7, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -3179,8 +3175,7 @@ static const int8_t kern_class_values[] =
|
||||
|
||||
|
||||
/*Collect the kern class' data in one place*/
|
||||
static const lv_font_fmt_txt_kern_classes_t kern_classes =
|
||||
{
|
||||
static const lv_font_fmt_txt_kern_classes_t kern_classes = {
|
||||
.class_pair_values = kern_class_values,
|
||||
.left_class_mapping = kern_left_class_mapping,
|
||||
.right_class_mapping = kern_right_class_mapping,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef LV_FONT_ROBOTO_28
|
||||
#define LV_FONT_ROBOTO_28 1
|
||||
#define LV_FONT_ROBOTO_28 1
|
||||
#endif
|
||||
|
||||
#if LV_FONT_ROBOTO_28
|
||||
@@ -4315,8 +4315,7 @@ static const uint16_t unicode_list_1[] = {
|
||||
};
|
||||
|
||||
/*Collect the unicode lists and glyph_id offsets*/
|
||||
static const lv_font_fmt_txt_cmap_t cmaps[] =
|
||||
{
|
||||
static const lv_font_fmt_txt_cmap_t cmaps[] = {
|
||||
{
|
||||
.range_start = 32, .range_length = 95, .glyph_id_start = 1,
|
||||
.unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY
|
||||
@@ -4333,8 +4332,7 @@ static const lv_font_fmt_txt_cmap_t cmaps[] =
|
||||
|
||||
|
||||
/*Map glyph_ids to kern left classes*/
|
||||
static const uint8_t kern_left_class_mapping[] =
|
||||
{
|
||||
static const uint8_t kern_left_class_mapping[] = {
|
||||
0, 1, 0, 2, 0, 0, 0, 0,
|
||||
2, 3, 0, 0, 0, 4, 0, 4,
|
||||
5, 0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -4358,8 +4356,7 @@ static const uint8_t kern_left_class_mapping[] =
|
||||
};
|
||||
|
||||
/*Map glyph_ids to kern right classes*/
|
||||
static const uint8_t kern_right_class_mapping[] =
|
||||
{
|
||||
static const uint8_t kern_right_class_mapping[] = {
|
||||
0, 1, 0, 2, 0, 0, 0, 3,
|
||||
2, 0, 4, 5, 0, 6, 7, 6,
|
||||
8, 0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -4383,8 +4380,7 @@ static const uint8_t kern_right_class_mapping[] =
|
||||
};
|
||||
|
||||
/*Kern values between classes*/
|
||||
static const int8_t kern_class_values[] =
|
||||
{
|
||||
static const int8_t kern_class_values[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -9, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -4564,8 +4560,7 @@ static const int8_t kern_class_values[] =
|
||||
|
||||
|
||||
/*Collect the kern class' data in one place*/
|
||||
static const lv_font_fmt_txt_kern_classes_t kern_classes =
|
||||
{
|
||||
static const lv_font_fmt_txt_kern_classes_t kern_classes = {
|
||||
.class_pair_values = kern_class_values,
|
||||
.left_class_mapping = kern_left_class_mapping,
|
||||
.right_class_mapping = kern_right_class_mapping,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef LV_FONT_ROBOTO_28_COMPRESSED
|
||||
#define LV_FONT_ROBOTO_28_COMPRESSED 1
|
||||
#define LV_FONT_ROBOTO_28_COMPRESSED 1
|
||||
#endif
|
||||
|
||||
#if LV_FONT_ROBOTO_28_COMPRESSED
|
||||
@@ -2157,8 +2157,7 @@ static const uint16_t unicode_list_1[] = {
|
||||
};
|
||||
|
||||
/*Collect the unicode lists and glyph_id offsets*/
|
||||
static const lv_font_fmt_txt_cmap_t cmaps[] =
|
||||
{
|
||||
static const lv_font_fmt_txt_cmap_t cmaps[] = {
|
||||
{
|
||||
.range_start = 32, .range_length = 95, .glyph_id_start = 1,
|
||||
.unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY
|
||||
@@ -2175,8 +2174,7 @@ static const lv_font_fmt_txt_cmap_t cmaps[] =
|
||||
|
||||
|
||||
/*Map glyph_ids to kern left classes*/
|
||||
static const uint8_t kern_left_class_mapping[] =
|
||||
{
|
||||
static const uint8_t kern_left_class_mapping[] = {
|
||||
0, 1, 0, 2, 0, 0, 0, 0,
|
||||
2, 3, 0, 0, 0, 4, 0, 4,
|
||||
5, 0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -2200,8 +2198,7 @@ static const uint8_t kern_left_class_mapping[] =
|
||||
};
|
||||
|
||||
/*Map glyph_ids to kern right classes*/
|
||||
static const uint8_t kern_right_class_mapping[] =
|
||||
{
|
||||
static const uint8_t kern_right_class_mapping[] = {
|
||||
0, 1, 0, 2, 0, 0, 0, 3,
|
||||
2, 0, 4, 5, 0, 6, 7, 6,
|
||||
8, 0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -2225,8 +2222,7 @@ static const uint8_t kern_right_class_mapping[] =
|
||||
};
|
||||
|
||||
/*Kern values between classes*/
|
||||
static const int8_t kern_class_values[] =
|
||||
{
|
||||
static const int8_t kern_class_values[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, -9, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -2406,8 +2402,7 @@ static const int8_t kern_class_values[] =
|
||||
|
||||
|
||||
/*Collect the kern class' data in one place*/
|
||||
static const lv_font_fmt_txt_kern_classes_t kern_classes =
|
||||
{
|
||||
static const lv_font_fmt_txt_kern_classes_t kern_classes = {
|
||||
.class_pair_values = kern_class_values,
|
||||
.left_class_mapping = kern_left_class_mapping,
|
||||
.right_class_mapping = kern_right_class_mapping,
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
/*******************************************************************************
|
||||
* Size: 8 px
|
||||
* Bpp: 1
|
||||
* Opts:
|
||||
* Opts:
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef LV_FONT_UNSCII_8
|
||||
#define LV_FONT_UNSCII_8 1
|
||||
#define LV_FONT_UNSCII_8 1
|
||||
#endif
|
||||
|
||||
#if LV_FONT_UNSCII_8
|
||||
@@ -418,8 +418,7 @@ static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = {
|
||||
|
||||
|
||||
/*Collect the unicode lists and glyph_id offsets*/
|
||||
static const lv_font_fmt_txt_cmap_t cmaps[] =
|
||||
{
|
||||
static const lv_font_fmt_txt_cmap_t cmaps[] = {
|
||||
{
|
||||
.range_start = 32, .range_length = 96, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY,
|
||||
.glyph_id_start = 1, .unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
|
||||
#if defined(LV_GC_INCLUDE)
|
||||
#include LV_GC_INCLUDE
|
||||
#include LV_GC_INCLUDE
|
||||
#endif /* LV_ENABLE_GC */
|
||||
|
||||
/*********************
|
||||
@@ -139,7 +139,7 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
|
||||
disp->refr_task = lv_task_create(lv_disp_refr_task, LV_DISP_DEF_REFR_PERIOD, LV_REFR_TASK_PRIO, disp);
|
||||
LV_ASSERT_MEM(disp->refr_task);
|
||||
if(disp->refr_task == NULL) return NULL;
|
||||
|
||||
|
||||
disp->inv_p = 0;
|
||||
disp->last_activity_time = 0;
|
||||
|
||||
@@ -170,8 +170,7 @@ void lv_disp_drv_update(lv_disp_t * disp, lv_disp_drv_t * new_drv)
|
||||
memcpy(&disp->driver, new_drv, sizeof(lv_disp_drv_t));
|
||||
|
||||
lv_obj_t * scr;
|
||||
LV_LL_READ(disp->scr_ll, scr)
|
||||
{
|
||||
LV_LL_READ(disp->scr_ll, scr) {
|
||||
lv_obj_set_size(scr, lv_disp_get_hor_res(disp), lv_disp_get_ver_res(disp));
|
||||
}
|
||||
}
|
||||
@@ -352,7 +351,8 @@ bool lv_disp_is_true_double_buf(lv_disp_t * disp)
|
||||
|
||||
if(lv_disp_is_double_buf(disp) && disp->driver.buffer->size == scr_size) {
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,7 @@ struct _disp_drv_t;
|
||||
/**
|
||||
* Structure for holding display buffer information.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
void * buf1; /**< First display buffer. */
|
||||
void * buf2; /**< Second display buffer. */
|
||||
|
||||
@@ -59,8 +58,7 @@ typedef struct
|
||||
/**
|
||||
* Display Driver structure to be registered by HAL
|
||||
*/
|
||||
typedef struct _disp_drv_t
|
||||
{
|
||||
typedef struct _disp_drv_t {
|
||||
|
||||
lv_coord_t hor_res; /**< Horizontal resolution. */
|
||||
lv_coord_t ver_res; /**< Vertical resolution. */
|
||||
@@ -124,8 +122,7 @@ struct _lv_obj_t;
|
||||
* Display structure.
|
||||
* ::lv_disp_drv_t is the first member of the structure.
|
||||
*/
|
||||
typedef struct _disp_t
|
||||
{
|
||||
typedef struct _disp_t {
|
||||
/**< Driver to the display*/
|
||||
lv_disp_drv_t driver;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "lv_hal_disp.h"
|
||||
|
||||
#if defined(LV_GC_INCLUDE)
|
||||
#include LV_GC_INCLUDE
|
||||
#include LV_GC_INCLUDE
|
||||
#endif /* LV_ENABLE_GC */
|
||||
|
||||
/*********************
|
||||
@@ -148,7 +148,8 @@ bool lv_indev_read(lv_indev_t * indev, lv_indev_data_t * data)
|
||||
LV_LOG_TRACE("idnev read started");
|
||||
cont = indev->driver.read_cb(&indev->driver, data);
|
||||
LV_LOG_TRACE("idnev read finished");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("indev function registered");
|
||||
}
|
||||
|
||||
|
||||
+16
-21
@@ -61,16 +61,15 @@ enum {
|
||||
typedef uint8_t lv_drag_dir_t;
|
||||
|
||||
enum {
|
||||
LV_GESTURE_DIR_TOP, /**< Gesture dir up. */
|
||||
LV_GESTURE_DIR_BOTTOM, /**< Gesture dir down. */
|
||||
LV_GESTURE_DIR_LEFT, /**< Gesture dir left. */
|
||||
LV_GESTURE_DIR_RIGHT, /**< Gesture dir right. */
|
||||
LV_GESTURE_DIR_TOP, /**< Gesture dir up. */
|
||||
LV_GESTURE_DIR_BOTTOM, /**< Gesture dir down. */
|
||||
LV_GESTURE_DIR_LEFT, /**< Gesture dir left. */
|
||||
LV_GESTURE_DIR_RIGHT, /**< Gesture dir right. */
|
||||
};
|
||||
typedef uint8_t lv_gesture_dir_t;
|
||||
|
||||
/** Data structure passed to an input driver to fill */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
lv_point_t point; /**< For LV_INDEV_TYPE_POINTER the currently pressed point*/
|
||||
uint32_t key; /**< For LV_INDEV_TYPE_KEYPAD the currently pressed key*/
|
||||
uint32_t btn_id; /**< For LV_INDEV_TYPE_BUTTON the currently pressed button*/
|
||||
@@ -81,8 +80,7 @@ typedef struct
|
||||
|
||||
|
||||
/** Initialized by the user and registered by 'lv_indev_add()'*/
|
||||
typedef struct _lv_indev_drv_t
|
||||
{
|
||||
typedef struct _lv_indev_drv_t {
|
||||
|
||||
/**< Input device type*/
|
||||
lv_indev_type_t type;
|
||||
@@ -128,13 +126,11 @@ typedef struct _lv_indev_drv_t
|
||||
/** Run time data of input devices
|
||||
* Internally used by the library, you should not need to touch it.
|
||||
*/
|
||||
typedef struct _lv_indev_proc_t
|
||||
{
|
||||
typedef struct _lv_indev_proc_t {
|
||||
lv_indev_state_t state; /**< Current state of the input device. */
|
||||
union
|
||||
{
|
||||
struct
|
||||
{ /*Pointer and button data*/
|
||||
union {
|
||||
struct {
|
||||
/*Pointer and button data*/
|
||||
lv_point_t act_point; /**< Current point of input device. */
|
||||
lv_point_t last_point; /**< Last point of input device. */
|
||||
lv_point_t vect; /**< Difference between `act_point` and `last_point`. */
|
||||
@@ -145,16 +141,16 @@ typedef struct _lv_indev_proc_t
|
||||
other post-release event)*/
|
||||
struct _lv_obj_t * last_pressed; /*The lastly pressed object*/
|
||||
|
||||
lv_gesture_dir_t gesture_dir;
|
||||
lv_point_t gesture_sum; /*Count the gesture pixels to check LV_INDEV_DEF_GESTURE_LIMIT*/
|
||||
lv_gesture_dir_t gesture_dir;
|
||||
lv_point_t gesture_sum; /*Count the gesture pixels to check LV_INDEV_DEF_GESTURE_LIMIT*/
|
||||
/*Flags*/
|
||||
uint8_t drag_limit_out : 1;
|
||||
uint8_t drag_in_prog : 1;
|
||||
lv_drag_dir_t drag_dir : 3;
|
||||
uint8_t gesture_sent : 1;
|
||||
uint8_t gesture_sent : 1;
|
||||
} pointer;
|
||||
struct
|
||||
{ /*Keypad data*/
|
||||
struct {
|
||||
/*Keypad data*/
|
||||
lv_indev_state_t last_state;
|
||||
uint32_t last_key;
|
||||
} keypad;
|
||||
@@ -175,8 +171,7 @@ struct _lv_group_t;
|
||||
|
||||
/** The main input device descriptor with driver, runtime data ('proc') and some additional
|
||||
* information*/
|
||||
typedef struct _lv_indev_t
|
||||
{
|
||||
typedef struct _lv_indev_t {
|
||||
lv_indev_drv_t driver;
|
||||
lv_indev_proc_t proc;
|
||||
struct _lv_obj_t * cursor; /**< Cursor for LV_INPUT_TYPE_POINTER*/
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user