From ce4d75059ecf82063361e649b01ca4917ab2ea93 Mon Sep 17 00:00:00 2001 From: lixianjing Date: Wed, 26 Jun 2019 11:37:44 +0800 Subject: [PATCH] add dialog_highlighter_is_dynamic --- src/base/dialog_highlighter.c | 8 ++++++++ src/base/dialog_highlighter.h | 11 +++++++++++ src/base/window_animator.c | 4 ++++ src/dialog_highlighters/dialog_highlighter_default.c | 7 +++++++ 4 files changed, 30 insertions(+) diff --git a/src/base/dialog_highlighter.c b/src/base/dialog_highlighter.c index 80d03abfb..6430d0661 100644 --- a/src/base/dialog_highlighter.c +++ b/src/base/dialog_highlighter.c @@ -69,6 +69,14 @@ ret_t dialog_highlighter_draw(dialog_highlighter_t* h, float_t percent) { return RET_NOT_IMPL; } +bool_t dialog_highlighter_is_dynamic(dialog_highlighter_t* h) { + if (h != NULL && h->vt != NULL && h->vt->is_dynamic != NULL) { + return h->vt->is_dynamic(h); + } else { + return FALSE; + } +} + static ret_t dialog_highlighter_on_destroy(dialog_highlighter_t* h) { return_value_if_fail(h != NULL && h->vt != NULL, RET_BAD_PARAMS); diff --git a/src/base/dialog_highlighter.h b/src/base/dialog_highlighter.h index b82722a04..f02e2a496 100644 --- a/src/base/dialog_highlighter.h +++ b/src/base/dialog_highlighter.h @@ -31,6 +31,7 @@ typedef struct _dialog_highlighter_t dialog_highlighter_t; typedef ret_t (*dialog_highlighter_prepare_t)(dialog_highlighter_t* h, canvas_t* c); typedef ret_t (*dialog_highlighter_draw_t)(dialog_highlighter_t* h, float_t percent); +typedef bool_t (*dialog_highlighter_is_dynamic_t)(dialog_highlighter_t* h); typedef ret_t (*dialog_highlighter_on_destroy_t)(dialog_highlighter_t* h); typedef dialog_highlighter_t* (*dialog_highlighter_create_t)(object_t* args); @@ -41,6 +42,7 @@ typedef struct _dialog_highlighter_vtable_t { uint32_t size; dialog_highlighter_draw_t draw; dialog_highlighter_prepare_t prepare; + dialog_highlighter_is_dynamic_t is_dynamic; dialog_highlighter_on_destroy_t on_destroy; } dialog_highlighter_vtable_t; @@ -129,6 +131,15 @@ ret_t dialog_highlighter_prepare(dialog_highlighter_t* h, canvas_t* c); */ ret_t dialog_highlighter_draw(dialog_highlighter_t* h, float_t percent); +/** + * @method dialog_highlighter_is_dynamic + * 是否是动态绘制(方便外层优化)。 + * @param {dialog_highlighter_t*} h 对话框高亮策略对象。 + * + * @return {bool_t} 返回TRUE表示动态绘制,否则表示不是动态绘制。 + */ +bool_t dialog_highlighter_is_dynamic(dialog_highlighter_t* h); + /** * @method dialog_highlighter_destroy * 销毁对话框高亮策略对象。 diff --git a/src/base/window_animator.c b/src/base/window_animator.c index b32faf43d..07a3775c8 100644 --- a/src/base/window_animator.c +++ b/src/base/window_animator.c @@ -146,6 +146,10 @@ static ret_t window_animator_begin_frame_overlap(window_animator_t* wa) { w = wa->curr_win->parent; } + if (dialog_highlighter_is_dynamic(wa->dialog_highlighter)) { + w = wa->curr_win->parent; + } + r = rect_init(w->x, w->y, w->w, w->h); ENSURE(canvas_begin_frame(wa->canvas, &r, LCD_DRAW_ANIMATION_OVERLAP) == RET_OK); #endif diff --git a/src/dialog_highlighters/dialog_highlighter_default.c b/src/dialog_highlighters/dialog_highlighter_default.c index ea89e9aa6..912759bb4 100755 --- a/src/dialog_highlighters/dialog_highlighter_default.c +++ b/src/dialog_highlighters/dialog_highlighter_default.c @@ -78,11 +78,18 @@ static ret_t dialog_highlighter_default_draw(dialog_highlighter_t* h, float_t pe return RET_OK; } +static bool_t dialog_highlighter_default_is_dynamic(dialog_highlighter_t* h) { + dialog_highlighter_default_t* dh = (dialog_highlighter_default_t*)h; + + return (dh->start_alpha != dh->end_alpha); +} + static const dialog_highlighter_vtable_t s_dialog_highlighter_default_vt = { .type = "dialog_highlighter_default_t", .desc = "dialog_highlighter_default_t", .size = sizeof(dialog_highlighter_default_t), .prepare = dialog_highlighter_default_prepare, + .is_dynamic = dialog_highlighter_default_is_dynamic, .draw = dialog_highlighter_default_draw}; dialog_highlighter_t* dialog_highlighter_default_create(object_t* args) {