draw_img: optimize ARGB rendering
This commit is contained in:
@@ -395,6 +395,58 @@ static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area,
|
|||||||
|
|
||||||
|
|
||||||
bool transform = draw_dsc->angle != 0 || draw_dsc->zoom != LV_IMG_ZOOM_NONE ? true : false;
|
bool transform = draw_dsc->angle != 0 || draw_dsc->zoom != LV_IMG_ZOOM_NONE ? true : false;
|
||||||
|
|
||||||
|
/*Simple ARGB image. Handle it as special case because it's very common*/
|
||||||
|
if(other_mask_cnt == 0 && !transform && !chroma_key && alpha_byte) {
|
||||||
|
int32_t x;
|
||||||
|
int32_t y;
|
||||||
|
lv_coord_t draw_area_h = lv_area_get_height(&draw_area);
|
||||||
|
lv_coord_t draw_area_w = lv_area_get_width(&draw_area);
|
||||||
|
for(y = 0; y < draw_area_h; y++) {
|
||||||
|
map_px = map_buf_tmp;
|
||||||
|
for(x = 0; x < draw_area_w; x++, map_px += px_size_byte, px_i++) {
|
||||||
|
lv_opa_t px_opa = map_px[LV_IMG_PX_SIZE_ALPHA_BYTE - 1];
|
||||||
|
mask_buf[px_i] = px_opa;
|
||||||
|
if(px_opa < LV_OPA_MIN) {
|
||||||
|
#if LV_COLOR_DEPTH == 32
|
||||||
|
map2[px_i].ch.alpha = 0xFF;
|
||||||
|
#endif
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if LV_COLOR_DEPTH == 8
|
||||||
|
c.full = map_px[0];
|
||||||
|
#elif LV_COLOR_DEPTH == 16
|
||||||
|
c.full = map_px[0] + (map_px[1] << 8);
|
||||||
|
#elif LV_COLOR_DEPTH == 32
|
||||||
|
c.full = *((uint32_t *)map_px);
|
||||||
|
#endif
|
||||||
|
map2[px_i].full = c.full;
|
||||||
|
}
|
||||||
|
|
||||||
|
map_buf_tmp += map_w * px_size_byte;
|
||||||
|
if(px_i + lv_area_get_width(&draw_area) < mask_buf_size) {
|
||||||
|
blend_area.y2 ++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
lv_blend_map(clip_area, &blend_area, map2, mask_buf, LV_DRAW_MASK_RES_CHANGED, draw_dsc->opa, draw_dsc->blend_mode);
|
||||||
|
|
||||||
|
blend_area.y1 = blend_area.y2 + 1;
|
||||||
|
blend_area.y2 = blend_area.y1;
|
||||||
|
|
||||||
|
px_i = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*Flush the last part*/
|
||||||
|
if(blend_area.y1 != blend_area.y2) {
|
||||||
|
blend_area.y2--;
|
||||||
|
lv_blend_map(clip_area, &blend_area, map2, mask_buf, LV_DRAW_MASK_RES_CHANGED, draw_dsc->opa, draw_dsc->blend_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
lv_mem_buf_release(mask_buf);
|
||||||
|
lv_mem_buf_release(map2);
|
||||||
|
} else {
|
||||||
|
|
||||||
lv_img_transform_dsc_t trans_dsc;
|
lv_img_transform_dsc_t trans_dsc;
|
||||||
lv_memset_00(&trans_dsc, sizeof(lv_img_transform_dsc_t));
|
lv_memset_00(&trans_dsc, sizeof(lv_img_transform_dsc_t));
|
||||||
if(transform) {
|
if(transform) {
|
||||||
@@ -433,14 +485,15 @@ static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area,
|
|||||||
|
|
||||||
for(x = 0; x < lv_area_get_width(&draw_area); x++, map_px += px_size_byte, px_i++) {
|
for(x = 0; x < lv_area_get_width(&draw_area); x++, map_px += px_size_byte, px_i++) {
|
||||||
|
|
||||||
if(transform == false) {
|
if(transform == false)
|
||||||
|
{
|
||||||
if(alpha_byte) {
|
if(alpha_byte) {
|
||||||
lv_opa_t px_opa = map_px[LV_IMG_PX_SIZE_ALPHA_BYTE - 1];
|
lv_opa_t px_opa = map_px[LV_IMG_PX_SIZE_ALPHA_BYTE - 1];
|
||||||
mask_buf[px_i] = px_opa;
|
mask_buf[px_i] = px_opa;
|
||||||
if(px_opa < LV_OPA_MIN) {
|
if(px_opa < LV_OPA_MIN) {
|
||||||
#if LV_COLOR_DEPTH == 32
|
#if LV_COLOR_DEPTH == 32
|
||||||
map2[px_i].ch.alpha = 0xFF;
|
map2[px_i].ch.alpha = 0xFF;
|
||||||
#endif
|
#endif
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -448,13 +501,13 @@ static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area,
|
|||||||
mask_buf[px_i] = LV_OPA_COVER;
|
mask_buf[px_i] = LV_OPA_COVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LV_COLOR_DEPTH == 8
|
#if LV_COLOR_DEPTH == 8
|
||||||
c.full = map_px[0];
|
c.full = map_px[0];
|
||||||
#elif LV_COLOR_DEPTH == 16
|
#elif LV_COLOR_DEPTH == 16
|
||||||
c.full = map_px[0] + (map_px[1] << 8);
|
c.full = map_px[0] + (map_px[1] << 8);
|
||||||
#elif LV_COLOR_DEPTH == 32
|
#elif LV_COLOR_DEPTH == 32
|
||||||
c.full = *((uint32_t *)map_px);
|
c.full = *((uint32_t *)map_px);
|
||||||
#endif
|
#endif
|
||||||
if(chroma_key) {
|
if(chroma_key) {
|
||||||
if(c.full == chroma_keyed_color.full) {
|
if(c.full == chroma_keyed_color.full) {
|
||||||
mask_buf[px_i] = LV_OPA_TRANSP;
|
mask_buf[px_i] = LV_OPA_TRANSP;
|
||||||
@@ -523,6 +576,7 @@ static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area,
|
|||||||
blend_area.y2--;
|
blend_area.y2--;
|
||||||
lv_blend_map(clip_area, &blend_area, map2, mask_buf, mask_res, draw_dsc->opa, draw_dsc->blend_mode);
|
lv_blend_map(clip_area, &blend_area, map2, mask_buf, mask_res, draw_dsc->opa, draw_dsc->blend_mode);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lv_mem_buf_release(mask_buf);
|
lv_mem_buf_release(mask_buf);
|
||||||
lv_mem_buf_release(map2);
|
lv_mem_buf_release(map2);
|
||||||
|
|||||||
Reference in New Issue
Block a user