simplify mem_fill

This commit is contained in:
Gabor Kiss-Vamosi
2019-06-13 19:25:23 +02:00
parent 3abcf52ad7
commit 0e41e9aacb
3 changed files with 22 additions and 13 deletions

View File

@@ -172,10 +172,20 @@ static void mem_blend(lv_disp_drv_t * disp_drv, lv_color_t * dest, const lv_colo
/* If your MCU has hardware accelerator (GPU) then you can use it to fill a memory with a color
* It can be used only in buffered mode (LV_VDB_SIZE != 0 in lv_conf.h)*/
static void mem_fill(lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, const lv_area_t * dest_area,
const lv_area_t * fill_area, lv_color_t color);
static void mem_fill_cb(lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width,
const lv_area_t * fill_area, lv_color_t color);
{
/*It's an example code which should be done by your GPU*/
uint32_t x, y;
dest_buf += dest_widht * fill_area->y1; /*Go to the first line*/
for(y = fill_area->y1; y < fill_area->y2; y++) {
for(x = fill_area->x1; x < fill_area->x2; x++) {
dest_buf[x] = color;
}
dest_buf+=des_width; /*Go to the next line*/
}
uint32_t i;
for(i = 0; i < length; i++) {

View File

@@ -42,7 +42,7 @@
* STATIC PROTOTYPES
**********************/
static void sw_mem_blend(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa);
static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_t * fill_area, lv_color_t color,
static void sw_color_fill(lv_color_t * mem, lv_coord_t mem_width, const lv_area_t * fill_area, lv_color_t color,
lv_opa_t opa);
#if LV_COLOR_SCREEN_TRANSP
@@ -150,13 +150,13 @@ void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p, lv_color_
lv_coord_t w = lv_area_get_width(&vdb_rel_a);
/*Don't use hw. acc. for every small fill (because of the init overhead)*/
if(w < VFILL_HW_ACC_SIZE_LIMIT) {
sw_color_fill(&vdb->area, vdb->buf_act, &vdb_rel_a, color, opa);
sw_color_fill(vdb->buf_act, vdb_width, &vdb_rel_a, color, opa);
}
/*Not opaque fill*/
else if(opa == LV_OPA_COVER) {
/*Use hw fill if present*/
if(disp->driver.mem_fill_cb) {
disp->driver.mem_fill_cb(&disp->driver, vdb->buf_act, &vdb->area, &vdb_rel_a, color);
disp->driver.mem_fill_cb(&disp->driver, vdb->buf_act, vdb_width, &vdb_rel_a, color);
}
/*Use hw blend if present and the area is not too small*/
else if(lv_area_get_height(&vdb_rel_a) > VFILL_HW_ACC_SIZE_LIMIT && disp->driver.mem_blend_cb) {
@@ -179,7 +179,7 @@ void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p, lv_color_
}
/*Else use sw fill if no better option*/
else {
sw_color_fill(&vdb->area, vdb->buf_act, &vdb_rel_a, color, opa);
sw_color_fill(vdb->buf_act, vdb_width, &vdb_rel_a, color, opa);
}
}
@@ -204,11 +204,11 @@ void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p, lv_color_
}
/*Use sw fill with opa if no better option*/
else {
sw_color_fill(&vdb->area, vdb->buf_act, &vdb_rel_a, color, opa);
sw_color_fill(vdb->buf_act, vdb_width, &vdb_rel_a, color, opa);
}
}
#else
sw_color_fill(&vdb->area, vdb->buf_act, &vdb_rel_a, color, opa);
sw_color_fill(vdb->buf_act, vdb_width, &vdb_rel_a, color, opa);
#endif
}
@@ -552,20 +552,19 @@ static void sw_mem_blend(lv_color_t * dest, const lv_color_t * src, uint32_t len
}
/**
*
* @param mem_area coordinates of 'mem' memory area
* Fill an area with a color
* @param mem a memory address. Considered to a rectangular window according to 'mem_area'
* @param mem_width width of the 'mem' buffer
* @param fill_area coordinates of an area to fill. Relative to 'mem_area'.
* @param color fill color
* @param opa opacity (0, LV_OPA_TRANSP: transparent ... 255, LV_OPA_COVER, fully cover)
*/
static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_t * fill_area, lv_color_t color,
static void sw_color_fill(lv_color_t * mem, lv_coord_t mem_width, const lv_area_t * fill_area, lv_color_t color,
lv_opa_t opa)
{
/*Set all row in vdb to the given color*/
lv_coord_t row;
lv_coord_t col;
lv_coord_t mem_width = lv_area_get_width(mem_area);
lv_disp_t * disp = lv_refr_get_disp_refreshing();
if(disp->driver.set_px_cb) {

View File

@@ -96,7 +96,7 @@ typedef struct _disp_drv_t
lv_opa_t opa);
/*OPTIONAL: Fill a memory with a color (GPU only)*/
void (*mem_fill_cb)(struct _disp_drv_t * disp_drv, lv_color_t * dest_buf, const lv_area_t * dest_area,
void (*mem_fill_cb)(struct _disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width,
const lv_area_t * fill_area, lv_color_t color);
#endif