feat(draw): improve acceleration for LV_IMG_CF_ALPHA_8BIT (#3337)
* feat(draw): improve acceleration for LV_IMG_CF_ALPHA_8BIT * fix format issue * fix: use normal method when conditions are not fulfilled. * fix a typo * feat(demo): add Weighted FPS and Opa speed log output (#3326) Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com> Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com> * perf(layer): cache the layer_type fixes #3334 * fix partial redraw and setting color Co-authored-by: _VIFEXTech <1290176185@qq.com> Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com> Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
This commit is contained in:
@@ -239,9 +239,18 @@ LV_ATTRIBUTE_FAST_MEM static lv_res_t decode_and_draw(lv_draw_ctx_t * draw_ctx,
|
|||||||
|
|
||||||
lv_img_cf_t cf;
|
lv_img_cf_t cf;
|
||||||
if(lv_img_cf_is_chroma_keyed(cdsc->dec_dsc.header.cf)) cf = LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED;
|
if(lv_img_cf_is_chroma_keyed(cdsc->dec_dsc.header.cf)) cf = LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED;
|
||||||
|
else if(LV_IMG_CF_ALPHA_8BIT == cdsc->dec_dsc.header.cf) cf = LV_IMG_CF_ALPHA_8BIT;
|
||||||
else if(lv_img_cf_has_alpha(cdsc->dec_dsc.header.cf)) cf = LV_IMG_CF_TRUE_COLOR_ALPHA;
|
else if(lv_img_cf_has_alpha(cdsc->dec_dsc.header.cf)) cf = LV_IMG_CF_TRUE_COLOR_ALPHA;
|
||||||
else cf = LV_IMG_CF_TRUE_COLOR;
|
else cf = LV_IMG_CF_TRUE_COLOR;
|
||||||
|
|
||||||
|
if(cf == LV_IMG_CF_ALPHA_8BIT) {
|
||||||
|
if(draw_dsc->angle || draw_dsc->zoom != LV_IMG_ZOOM_NONE) {
|
||||||
|
/* resume normal method */
|
||||||
|
cf = LV_IMG_CF_TRUE_COLOR_ALPHA;
|
||||||
|
cdsc->dec_dsc.img_data = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(cdsc->dec_dsc.error_msg != NULL) {
|
if(cdsc->dec_dsc.error_msg != NULL) {
|
||||||
LV_LOG_WARN("Image draw error");
|
LV_LOG_WARN("Image draw error");
|
||||||
|
|
||||||
|
|||||||
@@ -361,7 +361,8 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
|
|||||||
|
|
||||||
lv_img_cf_t cf = dsc->header.cf;
|
lv_img_cf_t cf = dsc->header.cf;
|
||||||
/*Process true color formats*/
|
/*Process true color formats*/
|
||||||
if(cf == LV_IMG_CF_TRUE_COLOR || cf == LV_IMG_CF_TRUE_COLOR_ALPHA || cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) {
|
if(cf == LV_IMG_CF_TRUE_COLOR || cf == LV_IMG_CF_TRUE_COLOR_ALPHA || cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED ||
|
||||||
|
cf == LV_IMG_CF_ALPHA_8BIT) {
|
||||||
if(dsc->src_type == LV_IMG_SRC_VARIABLE) {
|
if(dsc->src_type == LV_IMG_SRC_VARIABLE) {
|
||||||
/*In case of uncompressed formats the image stored in the ROM/RAM.
|
/*In case of uncompressed formats the image stored in the ROM/RAM.
|
||||||
*So simply give its pointer*/
|
*So simply give its pointer*/
|
||||||
@@ -426,8 +427,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
|
|||||||
return LV_RES_OK;
|
return LV_RES_OK;
|
||||||
}
|
}
|
||||||
/*Alpha indexed images.*/
|
/*Alpha indexed images.*/
|
||||||
else if(cf == LV_IMG_CF_ALPHA_1BIT || cf == LV_IMG_CF_ALPHA_2BIT || cf == LV_IMG_CF_ALPHA_4BIT ||
|
else if(cf == LV_IMG_CF_ALPHA_1BIT || cf == LV_IMG_CF_ALPHA_2BIT || cf == LV_IMG_CF_ALPHA_4BIT) {
|
||||||
cf == LV_IMG_CF_ALPHA_8BIT) {
|
|
||||||
return LV_RES_OK; /*Nothing to process*/
|
return LV_RES_OK; /*Nothing to process*/
|
||||||
}
|
}
|
||||||
/*Unknown format. Can't decode it.*/
|
/*Unknown format. Can't decode it.*/
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_blend_basic(lv_draw_ctx_t * draw_ctx, cons
|
|||||||
lv_coord_t mask_stride;
|
lv_coord_t mask_stride;
|
||||||
if(mask) {
|
if(mask) {
|
||||||
mask_stride = lv_area_get_width(dsc->mask_area);
|
mask_stride = lv_area_get_width(dsc->mask_area);
|
||||||
mask += mask_stride * (dsc->mask_area->y1 - blend_area.y1) + (dsc->mask_area->x1 - blend_area.x1);
|
mask += mask_stride * (blend_area.y1 - dsc->mask_area->y1) + (blend_area.x1 - dsc->mask_area->x1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mask_stride = 0;
|
mask_stride = 0;
|
||||||
|
|||||||
@@ -67,6 +67,19 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_img_decoded(struct _lv_draw_ctx_t * draw_c
|
|||||||
blend_dsc.blend_area = coords;
|
blend_dsc.blend_area = coords;
|
||||||
lv_draw_sw_blend(draw_ctx, &blend_dsc);
|
lv_draw_sw_blend(draw_ctx, &blend_dsc);
|
||||||
}
|
}
|
||||||
|
else if(!mask_any && !transform && cf == LV_IMG_CF_ALPHA_8BIT) {
|
||||||
|
lv_area_t clipped_coords;
|
||||||
|
if(!_lv_area_intersect(&clipped_coords, coords, draw_ctx->clip_area)) return;
|
||||||
|
|
||||||
|
blend_dsc.mask_buf = (lv_opa_t *)src_buf;
|
||||||
|
blend_dsc.mask_area = coords;
|
||||||
|
blend_dsc.src_buf = NULL;
|
||||||
|
blend_dsc.color = draw_dsc->recolor;
|
||||||
|
blend_dsc.mask_res = LV_DRAW_MASK_RES_CHANGED;
|
||||||
|
|
||||||
|
blend_dsc.blend_area = coords;
|
||||||
|
lv_draw_sw_blend(draw_ctx, &blend_dsc);
|
||||||
|
}
|
||||||
/*In the other cases every pixel need to be checked one-by-one*/
|
/*In the other cases every pixel need to be checked one-by-one*/
|
||||||
else {
|
else {
|
||||||
blend_area.x1 = draw_ctx->clip_area->x1;
|
blend_area.x1 = draw_ctx->clip_area->x1;
|
||||||
|
|||||||
Reference in New Issue
Block a user