From 6df66140165dad3398fa8a55ef9650ee025a4c9b Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 5 Apr 2019 06:55:35 +0200 Subject: [PATCH] update GPU inteface with 2D fill --- src/lv_draw/lv_draw_basic.c | 16 ++++++++-------- src/lv_hal/lv_hal_disp.c | 4 ++-- src/lv_hal/lv_hal_disp.h | 16 +++++++++------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/lv_draw/lv_draw_basic.c b/src/lv_draw/lv_draw_basic.c index df37b8677..4894dd793 100644 --- a/src/lv_draw/lv_draw_basic.c +++ b/src/lv_draw/lv_draw_basic.c @@ -157,16 +157,16 @@ void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p, lv_color_ /*Not opaque fill*/ else if(opa == LV_OPA_COVER) { /*Use hw fill if present*/ - if(disp->driver.mem_fill) { + if(disp->driver.mem_fill_cb) { lv_coord_t row; for(row = vdb_rel_a.y1; row <= vdb_rel_a.y2; row++) { - disp->driver.mem_fill(&vdb_buf_tmp[vdb_rel_a.x1], w, color); + disp->driver.mem_fill_cb(vdb->buf_act, &vdb->area, &vdb_rel_a, color); vdb_buf_tmp += vdb_width; } } /*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) { + disp->driver.mem_blend_cb) { /*Fill a one line sized buffer with a color and blend this later*/ if(color_array_tmp[0].full != color.full || last_width != w) { uint16_t i; @@ -179,7 +179,7 @@ void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p, lv_color_ /*Blend the filled line to every line VDB line-by-line*/ lv_coord_t row; for(row = vdb_rel_a.y1; row <= vdb_rel_a.y2; row++) { - disp->driver.mem_blend(&vdb_buf_tmp[vdb_rel_a.x1], color_array_tmp, w, opa); + disp->driver.mem_blend_cb(&vdb_buf_tmp[vdb_rel_a.x1], color_array_tmp, w, opa); vdb_buf_tmp += vdb_width; } @@ -193,7 +193,7 @@ void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p, lv_color_ /*Fill with opacity*/ else { /*Use hw blend if present*/ - if(disp->driver.mem_blend) { + if(disp->driver.mem_blend_cb) { if(color_array_tmp[0].full != color.full || last_width != w) { uint16_t i; for(i = 0; i < w; i++) { @@ -204,7 +204,7 @@ void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p, lv_color_ } lv_coord_t row; for(row = vdb_rel_a.y1; row <= vdb_rel_a.y2; row++) { - disp->driver.mem_blend(&vdb_buf_tmp[vdb_rel_a.x1], color_array_tmp, w, opa); + disp->driver.mem_blend_cb(&vdb_buf_tmp[vdb_rel_a.x1], color_array_tmp, w, opa); vdb_buf_tmp += vdb_width; } @@ -442,10 +442,10 @@ void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p, const uint else { for(row = masked_a.y1; row <= masked_a.y2; row++) { #if LV_USE_GPU - if(disp->driver.mem_blend == false) { + if(disp->driver.mem_blend_cb == false) { sw_mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa); } else { - disp->driver.mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa); + disp->driver.mem_blend_cb(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa); } #else sw_mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa); diff --git a/src/lv_hal/lv_hal_disp.c b/src/lv_hal/lv_hal_disp.c index 892bfac09..5ec49d1a7 100644 --- a/src/lv_hal/lv_hal_disp.c +++ b/src/lv_hal/lv_hal_disp.c @@ -67,8 +67,8 @@ void lv_disp_drv_init(lv_disp_drv_t * driver) #endif #if LV_USE_GPU - driver->mem_blend = NULL; - driver->mem_fill = NULL; + driver->mem_blend_cb = NULL; + driver->mem_fill_cb = NULL; #endif driver->set_px_cb = NULL; diff --git a/src/lv_hal/lv_hal_disp.h b/src/lv_hal/lv_hal_disp.h index 5a138cceb..5ffde953c 100644 --- a/src/lv_hal/lv_hal_disp.h +++ b/src/lv_hal/lv_hal_disp.h @@ -90,6 +90,15 @@ typedef struct _disp_drv_t * number of flushed pixels */ void (*monitor_cb)(struct _disp_drv_t * disp_drv, uint32_t time, uint32_t px); + +#if LV_USE_GPU + /*OPTIONAL: Blend two memories using opacity (GPU only)*/ + void (*mem_blend_cb)(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa); + + /*OPTIONAL: Fill a memory with a color (GPU only)*/ + void (*mem_fill_cb)(lv_color_t * dest_buf, const lv_area_t * dest_area, const lv_area_t * fill_area, lv_color_t color); +#endif + #if LV_USE_USER_DATA_SINGLE lv_disp_drv_user_data_t user_data; #endif @@ -101,13 +110,6 @@ typedef struct _disp_drv_t lv_disp_drv_user_data_t monitor_user_data; #endif -#if LV_USE_GPU - /*OPTIONAL: Blend two memories using opacity (GPU only)*/ - void (*mem_blend)(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa); - - /*OPTIONAL: Fill a memory with a color (GPU only)*/ - void (*mem_fill)(lv_color_t * dest, uint32_t length, lv_color_t color); -#endif } lv_disp_drv_t;