From d7ae21ce85fdc8e249dc172caf2df10f31045731 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sat, 29 Dec 2018 09:18:58 +0100 Subject: [PATCH] lv_vdb: add comments --- lv_core/lv_vdb.c | 14 ++++++++------ lv_core/lv_vdb.h | 6 ++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lv_core/lv_vdb.c b/lv_core/lv_vdb.c index 30ebc5a56..c362a48c0 100644 --- a/lv_core/lv_vdb.c +++ b/lv_core/lv_vdb.c @@ -108,12 +108,6 @@ void lv_vdb_flush(void) lv_disp_flush(vdb_act->area.x1, vdb_act->area.y1, vdb_act->area.x2, vdb_act->area.y2, vdb_act->buf); -#if LV_VDB_TRUE_DOUBLE_BUFFERED - while(vdb_flushing); - memcpy(vdb[(vdb_active + 1) & 0x1].buf, vdb[vdb_active].buf, LV_VDB_SIZE_IN_BYTES); -#endif - - #if LV_VDB_DOUBLE /*Make the other VDB active. The content of the current will be kept until the next flush*/ vdb_active++; @@ -124,6 +118,14 @@ void lv_vdb_flush(void) memset(vdb[vdb_active].buf, 0x00, LV_VDB_SIZE_IN_BYTES); # endif /*LV_COLOR_SCREEN_TRANSP*/ + /* With true double buffering the flushing should be only the address change of the current frame buffer + * Wait until the address change is ready and copy the active content to the other frame buffer (new active VDB) + * The changes will be written to the new VDB.*/ +#if LV_VDB_TRUE_DOUBLE_BUFFERED + while(vdb_flushing); + memcpy(vdb[vdb_active].buf, vdb[(vdb_active + 1) & 0x1].buf, LV_VDB_SIZE_IN_BYTES); +#endif + #endif /*#if LV_VDB_DOUBLE*/ } diff --git a/lv_core/lv_vdb.h b/lv_core/lv_vdb.h index cbb4329a4..278fc4e8e 100644 --- a/lv_core/lv_vdb.h +++ b/lv_core/lv_vdb.h @@ -35,6 +35,12 @@ extern "C" { #define LV_VDB_PX_BPP LV_COLOR_SIZE #endif + +#if LV_VDB_TRUE_DOUBLE_BUFFERED && (LV_VDB_SIZE != LV_HOR_RES * LV_VER_RES || LV_VDB_DOUBLE == 0) +#error "With LV_VDB_TRUE_DOUBLE_BUFFERED: (LV_VDB_SIZE = LV_HOR_RES * LV_VER_RES and LV_VDB_DOUBLE = 1 is required" +#endif + + /* The size of VDB in bytes. * (LV_VDB_SIZE * LV_VDB_PX_BPP) >> 3): just divide by 8 to convert bits to bytes * (((LV_VDB_SIZE * LV_VDB_PX_BPP) & 0x7) ? 1 : 0): add an extra byte to round up.