1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

feat(disp): add a temporary invalidation disable interface (#3378)

* feat(disp): add a temporary disable invalidation interface

* minor adjustments

* remove forgotten comment

Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
This commit is contained in:
_VIFEXTech 2022-05-27 04:46:55 +08:00 committed by GitHub
parent 2cf4d4b17e
commit d151a6789f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 72 additions and 0 deletions

View File

@ -413,6 +413,38 @@ void lv_disp_clean_dcache(lv_disp_t * disp)
disp->driver->clean_dcache_cb(disp->driver);
}
/**
* Temporarily enable and disable the invalidation of the display.
* @param disp pointer to a display (NULL to use the default display)
* @param en true: enable invalidation; false: invalidation
*/
void lv_disp_enable_invalidation(lv_disp_t * disp, bool en)
{
if(!disp) disp = lv_disp_get_default();
if(!disp) {
LV_LOG_WARN("no display registered");
return;
}
disp->inv_en_cnt += en ? 1 : -1;
}
/**
* Get display invalidation is enabled.
* @param disp pointer to a display (NULL to use the default display)
* @return return true if invalidation is enabled
*/
bool lv_disp_is_invalidation_enabled(lv_disp_t * disp)
{
if(!disp) disp = lv_disp_get_default();
if(!disp) {
LV_LOG_WARN("no display registered");
return false;
}
return (disp->inv_en_cnt > 0);
}
/**
* Get a pointer to the screen refresher timer to
* modify its parameters with `lv_timer_...` functions.

View File

@ -148,6 +148,20 @@ void lv_disp_trig_activity(lv_disp_t * disp);
*/
void lv_disp_clean_dcache(lv_disp_t * disp);
/**
* Temporarily enable and disable the invalidation of the display.
* @param disp pointer to a display (NULL to use the default display)
* @param en true: enable invalidation; false: invalidation
*/
void lv_disp_enable_invalidation(lv_disp_t * disp, bool en);
/**
* Get display invalidation is enabled.
* @param disp pointer to a display (NULL to use the default display)
* @return return true if invalidation is enabled
*/
bool lv_disp_is_invalidation_enabled(lv_disp_t * disp);
/**
* Get a pointer to the screen refresher timer to
* modify its parameters with `lv_timer_...` functions.

View File

@ -838,6 +838,9 @@ void lv_obj_invalidate_area(const lv_obj_t * obj, const lv_area_t * area)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_disp_t * disp = lv_obj_get_disp(obj);
if(!lv_disp_is_invalidation_enabled(disp)) return;
lv_area_t area_tmp;
lv_area_copy(&area_tmp, area);
if(!lv_obj_area_is_visible(obj, &area_tmp)) return;

View File

@ -206,6 +206,7 @@ void _lv_inv_area(lv_disp_t * disp, const lv_area_t * area_p)
{
if(!disp) disp = lv_disp_get_default();
if(!disp) return;
if(!lv_disp_is_invalidation_enabled(disp)) return;
if(disp->rendering_in_progress) {
LV_LOG_ERROR("detected modifying dirty areas in render");

View File

@ -177,6 +177,8 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
disp->driver = driver;
disp->inv_en_cnt = 1;
lv_disp_t * disp_def_tmp = disp_def;
disp_def = disp; /*Temporarily change the default screen to create the default screens on the
new display*/

View File

@ -187,6 +187,7 @@ uint8_t del_prev :
lv_area_t inv_areas[LV_INV_BUF_SIZE];
uint8_t inv_area_joined[LV_INV_BUF_SIZE];
uint16_t inv_p;
int32_t inv_en_cnt;
/*Miscellaneous data*/
uint32_t last_activity_time; /**< Last time when there was activity on this display*/

View File

@ -9,6 +9,7 @@
#include "lv_img.h"
#if LV_USE_IMG != 0
#include "../core/lv_disp.h"
#include "../misc/lv_assert.h"
#include "../draw/lv_img_decoder.h"
#include "../misc/lv_fs.h"
@ -202,7 +203,13 @@ void lv_img_set_angle(lv_obj_t * obj, int16_t angle)
lv_obj_invalidate_area(obj, &a);
img->angle = angle;
/* Disable invalidations because lv_obj_refresh_ext_draw_size would invalidate
* the whole ext draw area */
lv_disp_t * disp = lv_obj_get_disp(obj);
lv_disp_enable_invalidation(disp, false);
lv_obj_refresh_ext_draw_size(obj);
lv_disp_enable_invalidation(disp, true);
_lv_img_buf_get_transformed_area(&a, w, h, img->angle, img->zoom, &img->pivot);
a.x1 += obj->coords.x1;
@ -230,7 +237,13 @@ void lv_img_set_pivot(lv_obj_t * obj, lv_coord_t x, lv_coord_t y)
img->pivot.x = x;
img->pivot.y = y;
/* Disable invalidations because lv_obj_refresh_ext_draw_size would invalidate
* the whole ext draw area */
lv_disp_t * disp = lv_obj_get_disp(obj);
lv_disp_enable_invalidation(disp, false);
lv_obj_refresh_ext_draw_size(obj);
lv_disp_enable_invalidation(disp, true);
_lv_img_buf_get_transformed_area(&a, w, h, img->angle, img->zoom, &img->pivot);
a.x1 += obj->coords.x1;
@ -259,7 +272,13 @@ void lv_img_set_zoom(lv_obj_t * obj, uint16_t zoom)
lv_obj_invalidate_area(obj, &a);
img->zoom = zoom;
/* Disable invalidations because lv_obj_refresh_ext_draw_size would invalidate
* the whole ext draw area */
lv_disp_t * disp = lv_obj_get_disp(obj);
lv_disp_enable_invalidation(disp, false);
lv_obj_refresh_ext_draw_size(obj);
lv_disp_enable_invalidation(disp, true);
_lv_img_buf_get_transformed_area(&a, w, h, img->angle, img->zoom, &img->pivot);
a.x1 += obj->coords.x1 - 1;