add canvas_reset_cache

This commit is contained in:
lixianjing 2022-05-06 21:03:15 +08:00
parent dd34bc6aa4
commit c956e89cef
4 changed files with 39 additions and 1 deletions

View File

@ -3,6 +3,7 @@
2022/05/06
* 增加[如何显示上下文菜单(俗称右键菜单)](how_to_show_context_menu.md)
* 增加 STYLE\_ID\_CLEAR\_BG。为 true 时,绘制背景时用 clear\_rect 代替 fill\_rect。其作用是可以直接修改 lcd 颜色的 alpha 通道,方便于其它硬件层(如摄像头/视频)进行合成。
* 修复窗口动画播放完后由于在线canvas数据与lcd不一致导致的有一帧闪屏的现象感谢雨欣提供补丁
2022/05/05
* 修复combo\_box设置readonly和value控件后焦点状态切换异常的问题感谢雨欣提供补丁

View File

@ -2063,13 +2063,36 @@ canvas_t* canvas_cast(canvas_t* c) {
ret_t canvas_reset(canvas_t* c) {
return_value_if_fail(c != NULL && c->lcd != NULL, RET_BAD_PARAMS);
TKMEM_FREE(c->font_name);
canvas_reset_cache(c);
TKMEM_FREE(c->last_text_str);
memset(c, 0x00, sizeof(canvas_t));
return RET_OK;
}
ret_t canvas_reset_cache(canvas_t* c) {
return_value_if_fail(c != NULL && c->lcd != NULL, RET_BAD_PARAMS);
c->ox = 0;
c->oy = 0;
c->global_alpha = 0;
c->clip_left = 0;
c->clip_top = 0;
c->clip_right = canvas_get_width(c) - 1;
c->clip_bottom = canvas_get_height(c) - 1;
c->text_align_v = ALIGN_V_NONE;
c->text_align_h = ALIGN_H_NONE;
c->font_manager = NULL;
c->assets_manager = NULL;
canvas_reset_font(c);
return RET_OK;
}
ret_t canvas_get_text_metrics(canvas_t* c, float_t* ascent, float_t* descent, float_t* line_hight) {
return_value_if_fail(c != NULL, RET_BAD_PARAMS);
return_value_if_fail(ascent != NULL && descent != NULL && line_hight != NULL, RET_BAD_PARAMS);

View File

@ -715,6 +715,18 @@ canvas_t* canvas_cast(canvas_t* c);
*/
ret_t canvas_reset(canvas_t* c);
/**
* @method canvas_reset_cache
* canvas中缓存
* > 线线使lcd对象的数据保持一致
*
* @annotation ["scriptable"]
* @param {canvas_t*} c canvas对象
*
* @return {ret_t} RET_OK表示成功
*/
ret_t canvas_reset_cache(canvas_t* c);
/**
* @method canvas_draw_image_at
*

View File

@ -152,6 +152,8 @@ ret_t window_manager_default_snap_curr_window(widget_t* widget, widget_t* curr_w
ENSURE(canvas_offline_destroy(canvas) == RET_OK);
img->flags |= BITMAP_FLAG_OPAQUE;
canvas_restore(c);
/* 清除在线画布的缓存确保绘制完窗口动画后lcd对象的数据能和在线画布同步 */
canvas_reset_cache(c);
#endif
return RET_OK;
}