diff --git a/src/draw/sw/blend/lv_draw_sw_blend_to_argb8888.c b/src/draw/sw/blend/lv_draw_sw_blend_to_argb8888.c index 348fc5c0d..5dbdeaa80 100644 --- a/src/draw/sw/blend/lv_draw_sw_blend_to_argb8888.c +++ b/src/draw/sw/blend/lv_draw_sw_blend_to_argb8888.c @@ -49,6 +49,8 @@ static void lv_color_mix_with_alpha_cache_init(lv_color_mix_alpha_cache_t * cach LV_ATTRIBUTE_FAST_MEM static inline void blend_non_normal_pixel(lv_color32_t * dest, lv_color32_t src, lv_blend_mode_t mode, lv_color_mix_alpha_cache_t * cache); +LV_ATTRIBUTE_FAST_MEM static inline void * drawbuf_next_row(const void * buf, uint32_t stride); + /********************** * STATIC VARIABLES **********************/ @@ -68,7 +70,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_blend_color_to_argb8888(_lv_draw_sw_blend_ lv_opa_t opa = dsc->opa; const lv_opa_t * mask = dsc->mask_buf; int32_t mask_stride = dsc->mask_stride; - int32_t dest_stride_px = dsc->dest_stride / 4; + int32_t dest_stride = dsc->dest_stride; lv_color_mix_alpha_cache_t cache; lv_color_mix_with_alpha_cache_init(&cache); @@ -106,7 +108,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_blend_color_to_argb8888(_lv_draw_sw_blend_ dest_buf[x] = color32; } - dest_buf += dest_stride_px; + dest_buf = drawbuf_next_row(dest_buf, dest_stride); } } /*Opacity only*/ @@ -118,7 +120,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_blend_color_to_argb8888(_lv_draw_sw_blend_ for(x = 0; x < w; x++) { dest_buf[x] = lv_color_32_32_mix(color_argb, dest_buf[x], &cache); } - dest_buf += dest_stride_px; + dest_buf = drawbuf_next_row(dest_buf, dest_stride); } } /*Masked with full opacity*/ @@ -131,7 +133,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_blend_color_to_argb8888(_lv_draw_sw_blend_ dest_buf[x] = lv_color_32_32_mix(color_argb, dest_buf[x], &cache); } - dest_buf += dest_stride_px; + dest_buf = drawbuf_next_row(dest_buf, dest_stride); mask += mask_stride; } } @@ -144,7 +146,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_blend_color_to_argb8888(_lv_draw_sw_blend_ color_argb.alpha = LV_OPA_MIX2(mask[x], opa); dest_buf[x] = lv_color_32_32_mix(color_argb, dest_buf[x], &cache); } - dest_buf += dest_stride_px; + dest_buf = drawbuf_next_row(dest_buf, dest_stride); mask += mask_stride; } } @@ -181,9 +183,9 @@ LV_ATTRIBUTE_FAST_MEM static void rgb565_image_blend(_lv_draw_sw_blend_image_dsc int32_t h = dsc->dest_h; lv_opa_t opa = dsc->opa; lv_color32_t * dest_buf_c32 = dsc->dest_buf; - int32_t dest_stride_px = dsc->dest_stride / 4; + int32_t dest_stride = dsc->dest_stride; const lv_color16_t * src_buf_c16 = (const lv_color16_t *) dsc->src_buf; - int32_t src_stride_px = dsc->src_stride / 2; + int32_t src_stride = dsc->src_stride; const lv_opa_t * mask_buf = dsc->mask_buf; int32_t mask_stride = dsc->mask_stride; @@ -204,8 +206,8 @@ LV_ATTRIBUTE_FAST_MEM static void rgb565_image_blend(_lv_draw_sw_blend_image_dsc color_argb.blue = (src_buf_c16[x].blue * 2106) >> 8; dest_buf_c32[x] = lv_color_32_32_mix(color_argb, dest_buf_c32[x], &cache); } - dest_buf_c32 += dest_stride_px; - src_buf_c16 += src_stride_px; + dest_buf_c32 = drawbuf_next_row(dest_buf_c32, dest_stride); + src_buf_c16 = drawbuf_next_row(src_buf_c16, src_stride); } } else if(mask_buf && opa >= LV_OPA_MAX) { @@ -217,8 +219,8 @@ LV_ATTRIBUTE_FAST_MEM static void rgb565_image_blend(_lv_draw_sw_blend_image_dsc color_argb.blue = (src_buf_c16[x].blue * 2106) >> 8; dest_buf_c32[x] = lv_color_32_32_mix(color_argb, dest_buf_c32[x], &cache); } - dest_buf_c32 += dest_stride_px; - src_buf_c16 += src_stride_px; + dest_buf_c32 = drawbuf_next_row(dest_buf_c32, dest_stride); + src_buf_c16 = drawbuf_next_row(src_buf_c16, src_stride); mask_buf += mask_stride; } } @@ -231,8 +233,8 @@ LV_ATTRIBUTE_FAST_MEM static void rgb565_image_blend(_lv_draw_sw_blend_image_dsc color_argb.blue = (src_buf_c16[x].blue * 2106) >> 8; dest_buf_c32[x] = lv_color_32_32_mix(color_argb, dest_buf_c32[x], &cache); } - dest_buf_c32 += dest_stride_px; - src_buf_c16 += src_stride_px; + dest_buf_c32 = drawbuf_next_row(dest_buf_c32, dest_stride); + src_buf_c16 = drawbuf_next_row(src_buf_c16, src_stride); mask_buf += mask_stride; } } @@ -249,8 +251,8 @@ LV_ATTRIBUTE_FAST_MEM static void rgb565_image_blend(_lv_draw_sw_blend_image_dsc blend_non_normal_pixel(&dest_buf_c32[x], src_argb, dsc->blend_mode, &cache); } if(mask_buf) mask_buf += mask_stride; - dest_buf_c32 += dest_stride_px; - src_buf_c16 += src_stride_px; + dest_buf_c32 = drawbuf_next_row(dest_buf_c32, dest_stride); + src_buf_c16 = drawbuf_next_row(src_buf_c16, src_stride); } } } @@ -262,7 +264,7 @@ LV_ATTRIBUTE_FAST_MEM static void rgb888_image_blend(_lv_draw_sw_blend_image_dsc int32_t h = dsc->dest_h; lv_opa_t opa = dsc->opa; lv_color32_t * dest_buf_c32 = dsc->dest_buf; - int32_t dest_stride_px = dsc->dest_stride / 4; + int32_t dest_stride = dsc->dest_stride; const uint8_t * src_buf = dsc->src_buf; int32_t src_stride = dsc->src_stride; const lv_opa_t * mask_buf = dsc->mask_buf; @@ -283,8 +285,8 @@ LV_ATTRIBUTE_FAST_MEM static void rgb888_image_blend(_lv_draw_sw_blend_image_dsc uint32_t line_in_bytes = w * 4; for(y = 0; y < h; y++) { lv_memcpy(dest_buf_c32, src_buf, line_in_bytes); - dest_buf_c32 += dest_stride_px; - src_buf += src_stride; + dest_buf_c32 = drawbuf_next_row(dest_buf_c32, dest_stride); + src_buf = drawbuf_next_row(src_buf, src_stride); } } else if(src_px_size == 3) { @@ -295,8 +297,8 @@ LV_ATTRIBUTE_FAST_MEM static void rgb888_image_blend(_lv_draw_sw_blend_image_dsc dest_buf_c32[dest_x].blue = src_buf[src_x + 0]; dest_buf_c32[dest_x].alpha = 0xff; } - dest_buf_c32 += dest_stride_px; - src_buf += src_stride; + dest_buf_c32 = drawbuf_next_row(dest_buf_c32, dest_stride); + src_buf = drawbuf_next_row(src_buf, src_stride); } } } @@ -309,8 +311,8 @@ LV_ATTRIBUTE_FAST_MEM static void rgb888_image_blend(_lv_draw_sw_blend_image_dsc color_argb.blue = src_buf[src_x + 0]; dest_buf_c32[dest_x] = lv_color_32_32_mix(color_argb, dest_buf_c32[dest_x], &cache); } - dest_buf_c32 += dest_stride_px; - src_buf += src_stride; + dest_buf_c32 = drawbuf_next_row(dest_buf_c32, dest_stride); + src_buf = drawbuf_next_row(src_buf, src_stride); } } if(mask_buf && opa >= LV_OPA_MAX) { @@ -322,8 +324,8 @@ LV_ATTRIBUTE_FAST_MEM static void rgb888_image_blend(_lv_draw_sw_blend_image_dsc color_argb.blue = src_buf[src_x + 0]; dest_buf_c32[dest_x] = lv_color_32_32_mix(color_argb, dest_buf_c32[dest_x], &cache); } - dest_buf_c32 += dest_stride_px; - src_buf += src_stride; + dest_buf_c32 = drawbuf_next_row(dest_buf_c32, dest_stride); + src_buf = drawbuf_next_row(src_buf, src_stride); mask_buf += mask_stride; } } @@ -336,8 +338,8 @@ LV_ATTRIBUTE_FAST_MEM static void rgb888_image_blend(_lv_draw_sw_blend_image_dsc color_argb.blue = src_buf[src_x + 0]; dest_buf_c32[dest_x] = lv_color_32_32_mix(color_argb, dest_buf_c32[dest_x], &cache); } - dest_buf_c32 += dest_stride_px; - src_buf += src_stride; + dest_buf_c32 = drawbuf_next_row(dest_buf_c32, dest_stride); + src_buf = drawbuf_next_row(src_buf, src_stride); mask_buf += mask_stride; } } @@ -355,8 +357,8 @@ LV_ATTRIBUTE_FAST_MEM static void rgb888_image_blend(_lv_draw_sw_blend_image_dsc blend_non_normal_pixel(&dest_buf_c32[dest_x], src_argb, dsc->blend_mode, &cache); } if(mask_buf) mask_buf += mask_stride; - dest_buf_c32 += dest_stride_px; - src_buf += src_stride; + dest_buf_c32 = drawbuf_next_row(dest_buf_c32, dest_stride); + src_buf = drawbuf_next_row(src_buf, src_stride); } } } @@ -367,9 +369,9 @@ LV_ATTRIBUTE_FAST_MEM static void argb8888_image_blend(_lv_draw_sw_blend_image_d int32_t h = dsc->dest_h; lv_opa_t opa = dsc->opa; lv_color32_t * dest_buf_c32 = dsc->dest_buf; - int32_t dest_stride_px = dsc->dest_stride / 4; + int32_t dest_stride = dsc->dest_stride; const lv_color32_t * src_buf_c32 = dsc->src_buf; - int32_t src_stride_px = dsc->src_stride / 4; + int32_t src_stride = dsc->src_stride; const lv_opa_t * mask_buf = dsc->mask_buf; int32_t mask_stride = dsc->mask_stride; @@ -386,8 +388,8 @@ LV_ATTRIBUTE_FAST_MEM static void argb8888_image_blend(_lv_draw_sw_blend_image_d for(x = 0; x < w; x++) { dest_buf_c32[x] = lv_color_32_32_mix(src_buf_c32[x], dest_buf_c32[x], &cache); } - dest_buf_c32 += dest_stride_px; - src_buf_c32 += src_stride_px; + dest_buf_c32 = drawbuf_next_row(dest_buf_c32, dest_stride); + src_buf_c32 = drawbuf_next_row(src_buf_c32, src_stride); } } else if(mask_buf == NULL && opa < LV_OPA_MAX) { @@ -397,8 +399,8 @@ LV_ATTRIBUTE_FAST_MEM static void argb8888_image_blend(_lv_draw_sw_blend_image_d color_argb.alpha = LV_OPA_MIX2(color_argb.alpha, opa); dest_buf_c32[x] = lv_color_32_32_mix(color_argb, dest_buf_c32[x], &cache); } - dest_buf_c32 += dest_stride_px; - src_buf_c32 += src_stride_px; + dest_buf_c32 = drawbuf_next_row(dest_buf_c32, dest_stride); + src_buf_c32 = drawbuf_next_row(src_buf_c32, src_stride); } } else if(mask_buf && opa >= LV_OPA_MAX) { @@ -408,8 +410,8 @@ LV_ATTRIBUTE_FAST_MEM static void argb8888_image_blend(_lv_draw_sw_blend_image_d color_argb.alpha = LV_OPA_MIX2(color_argb.alpha, mask_buf[x]); dest_buf_c32[x] = lv_color_32_32_mix(color_argb, dest_buf_c32[x], &cache); } - dest_buf_c32 += dest_stride_px; - src_buf_c32 += src_stride_px; + dest_buf_c32 = drawbuf_next_row(dest_buf_c32, dest_stride); + src_buf_c32 = drawbuf_next_row(src_buf_c32, src_stride); mask_buf += mask_stride; } } @@ -420,8 +422,8 @@ LV_ATTRIBUTE_FAST_MEM static void argb8888_image_blend(_lv_draw_sw_blend_image_d color_argb.alpha = LV_OPA_MIX3(color_argb.alpha, opa, mask_buf[x]); dest_buf_c32[x] = lv_color_32_32_mix(color_argb, dest_buf_c32[x], &cache); } - dest_buf_c32 += dest_stride_px; - src_buf_c32 += src_stride_px; + dest_buf_c32 = drawbuf_next_row(dest_buf_c32, dest_stride); + src_buf_c32 = drawbuf_next_row(src_buf_c32, src_stride); mask_buf += mask_stride; } } @@ -435,8 +437,8 @@ LV_ATTRIBUTE_FAST_MEM static void argb8888_image_blend(_lv_draw_sw_blend_image_d blend_non_normal_pixel(&dest_buf_c32[x], color_argb, dsc->blend_mode, &cache); } if(mask_buf) mask_buf += mask_stride; - dest_buf_c32 += dest_stride_px; - src_buf_c32 += src_stride_px; + dest_buf_c32 = drawbuf_next_row(dest_buf_c32, dest_stride); + src_buf_c32 = drawbuf_next_row(src_buf_c32, src_stride); } } } @@ -517,4 +519,9 @@ LV_ATTRIBUTE_FAST_MEM static inline void blend_non_normal_pixel(lv_color32_t * d *dest = lv_color_32_32_mix(res, *dest, cache); } +LV_ATTRIBUTE_FAST_MEM static inline void * drawbuf_next_row(const void * buf, uint32_t stride) +{ + return (void *)((uint8_t *)buf + stride); +} + #endif diff --git a/src/draw/sw/blend/lv_draw_sw_blend_to_rgb565.c b/src/draw/sw/blend/lv_draw_sw_blend_to_rgb565.c index a0571b260..0336f64c1 100644 --- a/src/draw/sw/blend/lv_draw_sw_blend_to_rgb565.c +++ b/src/draw/sw/blend/lv_draw_sw_blend_to_rgb565.c @@ -36,6 +36,8 @@ LV_ATTRIBUTE_FAST_MEM static void argb8888_image_blend(_lv_draw_sw_blend_image_d LV_ATTRIBUTE_FAST_MEM static inline uint16_t lv_color_24_16_mix(const uint8_t * c1, uint16_t c2, uint8_t mix); +LV_ATTRIBUTE_FAST_MEM static inline void * drawbuf_next_row(const void * buf, uint32_t stride); + /********************** * STATIC VARIABLES **********************/ @@ -70,7 +72,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_blend_color_to_rgb565(_lv_draw_sw_blend_fi const lv_opa_t * mask = dsc->mask_buf; int32_t mask_stride = dsc->mask_stride; uint16_t * dest_buf_u16 = dsc->dest_buf; - int32_t dest_stride_px = dsc->dest_stride / 2; + int32_t dest_stride = dsc->dest_stride; int32_t x; int32_t y; @@ -106,7 +108,8 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_blend_color_to_rgb565(_lv_draw_sw_blend_fi dest_buf_u16++; } - dest_buf_u16 += dest_stride_px - w; + dest_buf_u16 = drawbuf_next_row(dest_buf_u16, dest_stride); + dest_buf_u16 -= w; } } /*Opacity only*/ @@ -145,7 +148,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_blend_color_to_rgb565(_lv_draw_sw_blend_fi for(; x < w ; x++) { dest_buf_u16[x] = lv_color_16_16_mix(color16, dest_buf_u16[x], opa); } - dest_buf_u16 += dest_stride_px; + dest_buf_u16 = drawbuf_next_row(dest_buf_u16, dest_stride); } } @@ -183,7 +186,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_blend_color_to_rgb565(_lv_draw_sw_blend_fi for(; x < w ; x++) { dest_buf_u16[x] = lv_color_16_16_mix(color16, dest_buf_u16[x], mask[x]); } - dest_buf_u16 += dest_stride_px; + dest_buf_u16 = drawbuf_next_row(dest_buf_u16, dest_stride); mask += mask_stride; } } @@ -193,7 +196,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_blend_color_to_rgb565(_lv_draw_sw_blend_fi for(x = 0; x < w; x++) { dest_buf_u16[x] = lv_color_16_16_mix(color16, dest_buf_u16[x], LV_OPA_MIX2(mask[x], opa)); } - dest_buf_u16 += dest_stride_px; + dest_buf_u16 = drawbuf_next_row(dest_buf_u16, dest_stride); mask += mask_stride; } } @@ -201,7 +204,6 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_blend_color_to_rgb565(_lv_draw_sw_blend_fi LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_blend_image_to_rgb565(_lv_draw_sw_blend_image_dsc_t * dsc) { - switch(dsc->src_color_format) { case LV_COLOR_FORMAT_RGB565: rgb565_image_blend(dsc); @@ -231,9 +233,9 @@ LV_ATTRIBUTE_FAST_MEM static void rgb565_image_blend(_lv_draw_sw_blend_image_dsc int32_t h = dsc->dest_h; lv_opa_t opa = dsc->opa; uint16_t * dest_buf_u16 = dsc->dest_buf; - int32_t dest_stride_px = dsc->dest_stride / 2; + int32_t dest_stride = dsc->dest_stride; const uint16_t * src_buf_u16 = dsc->src_buf; - int32_t src_stride_px = dsc->src_stride / 2; + int32_t src_stride = dsc->src_stride; const lv_opa_t * mask_buf = dsc->mask_buf; int32_t mask_stride = dsc->mask_stride; @@ -245,8 +247,8 @@ LV_ATTRIBUTE_FAST_MEM static void rgb565_image_blend(_lv_draw_sw_blend_image_dsc uint32_t line_in_bytes = w * 2; for(y = 0; y < h; y++) { lv_memcpy(dest_buf_u16, src_buf_u16, line_in_bytes); - dest_buf_u16 += dest_stride_px; - src_buf_u16 += src_stride_px; + dest_buf_u16 = drawbuf_next_row(dest_buf_u16, dest_stride); + src_buf_u16 = drawbuf_next_row(src_buf_u16, src_stride); } } else if(mask_buf == NULL && opa < LV_OPA_MAX) { @@ -254,8 +256,8 @@ LV_ATTRIBUTE_FAST_MEM static void rgb565_image_blend(_lv_draw_sw_blend_image_dsc for(x = 0; x < w; x++) { dest_buf_u16[x] = lv_color_16_16_mix(src_buf_u16[x], dest_buf_u16[x], opa); } - dest_buf_u16 += dest_stride_px; - src_buf_u16 += src_stride_px; + dest_buf_u16 = drawbuf_next_row(dest_buf_u16, dest_stride); + src_buf_u16 = drawbuf_next_row(src_buf_u16, src_stride); } } else if(mask_buf && opa >= LV_OPA_MAX) { @@ -263,8 +265,8 @@ LV_ATTRIBUTE_FAST_MEM static void rgb565_image_blend(_lv_draw_sw_blend_image_dsc for(x = 0; x < w; x++) { dest_buf_u16[x] = lv_color_16_16_mix(src_buf_u16[x], dest_buf_u16[x], mask_buf[x]); } - dest_buf_u16 += dest_stride_px; - src_buf_u16 += src_stride_px; + dest_buf_u16 = drawbuf_next_row(dest_buf_u16, dest_stride); + src_buf_u16 = drawbuf_next_row(src_buf_u16, src_stride); mask_buf += mask_stride; } } @@ -273,8 +275,8 @@ LV_ATTRIBUTE_FAST_MEM static void rgb565_image_blend(_lv_draw_sw_blend_image_dsc for(x = 0; x < w; x++) { dest_buf_u16[x] = lv_color_16_16_mix(src_buf_u16[x], dest_buf_u16[x], LV_OPA_MIX2(mask_buf[x], opa)); } - dest_buf_u16 += dest_stride_px; - src_buf_u16 += src_stride_px; + dest_buf_u16 = drawbuf_next_row(dest_buf_u16, dest_stride); + src_buf_u16 = drawbuf_next_row(src_buf_u16, src_stride); mask_buf += mask_stride; } } @@ -318,8 +320,8 @@ LV_ATTRIBUTE_FAST_MEM static void rgb565_image_blend(_lv_draw_sw_blend_image_dsc } } - dest_buf_u16 += dest_stride_px; - src_buf_u16 += src_stride_px; + dest_buf_u16 = drawbuf_next_row(dest_buf_u16, dest_stride); + src_buf_u16 = drawbuf_next_row(src_buf_u16, src_stride); if(mask_buf) mask_buf += mask_stride; } } @@ -331,7 +333,7 @@ LV_ATTRIBUTE_FAST_MEM static void rgb888_image_blend(_lv_draw_sw_blend_image_dsc int32_t h = dsc->dest_h; lv_opa_t opa = dsc->opa; uint16_t * dest_buf_u16 = dsc->dest_buf; - int32_t dest_stride_px = dsc->dest_stride / 2; + int32_t dest_stride = dsc->dest_stride; const uint8_t * src_buf_u8 = dsc->src_buf; int32_t src_stride = dsc->src_stride; const lv_opa_t * mask_buf = dsc->mask_buf; @@ -349,7 +351,7 @@ LV_ATTRIBUTE_FAST_MEM static void rgb888_image_blend(_lv_draw_sw_blend_image_dsc ((src_buf_u8[src_x + 1] & 0xFC) << 3) + ((src_buf_u8[src_x + 0] & 0xF8) >> 3); } - dest_buf_u16 += dest_stride_px; + dest_buf_u16 = drawbuf_next_row(dest_buf_u16, dest_stride); src_buf_u8 += src_stride; } } @@ -358,7 +360,7 @@ LV_ATTRIBUTE_FAST_MEM static void rgb888_image_blend(_lv_draw_sw_blend_image_dsc for(dest_x = 0, src_x = 0; dest_x < w; dest_x++, src_x += src_px_size) { dest_buf_u16[dest_x] = lv_color_24_16_mix(&src_buf_u8[src_x], dest_buf_u16[dest_x], opa); } - dest_buf_u16 += dest_stride_px; + dest_buf_u16 = drawbuf_next_row(dest_buf_u16, dest_stride); src_buf_u8 += src_stride; } } @@ -367,7 +369,7 @@ LV_ATTRIBUTE_FAST_MEM static void rgb888_image_blend(_lv_draw_sw_blend_image_dsc for(dest_x = 0, src_x = 0; dest_x < w; dest_x++, src_x += src_px_size) { dest_buf_u16[dest_x] = lv_color_24_16_mix(&src_buf_u8[src_x], dest_buf_u16[dest_x], mask_buf[dest_x]); } - dest_buf_u16 += dest_stride_px; + dest_buf_u16 = drawbuf_next_row(dest_buf_u16, dest_stride); src_buf_u8 += src_stride; mask_buf += mask_stride; } @@ -377,7 +379,7 @@ LV_ATTRIBUTE_FAST_MEM static void rgb888_image_blend(_lv_draw_sw_blend_image_dsc for(dest_x = 0, src_x = 0; dest_x < w; dest_x++, src_x += src_px_size) { dest_buf_u16[dest_x] = lv_color_24_16_mix(&src_buf_u8[src_x], dest_buf_u16[dest_x], LV_OPA_MIX2(mask_buf[dest_x], opa)); } - dest_buf_u16 += dest_stride_px; + dest_buf_u16 = drawbuf_next_row(dest_buf_u16, dest_stride); src_buf_u8 += src_stride; mask_buf += mask_stride; } @@ -420,7 +422,7 @@ LV_ATTRIBUTE_FAST_MEM static void rgb888_image_blend(_lv_draw_sw_blend_image_dsc } } - dest_buf_u16 += dest_stride_px; + dest_buf_u16 = drawbuf_next_row(dest_buf_u16, dest_stride); src_buf_u8 += src_stride; if(mask_buf) mask_buf += mask_stride; } @@ -432,7 +434,7 @@ LV_ATTRIBUTE_FAST_MEM static void argb8888_image_blend(_lv_draw_sw_blend_image_d int32_t h = dsc->dest_h; lv_opa_t opa = dsc->opa; uint16_t * dest_buf_u16 = dsc->dest_buf; - int32_t dest_stride_px = dsc->dest_stride / 2; + int32_t dest_stride = dsc->dest_stride; const uint8_t * src_buf_u8 = dsc->src_buf; int32_t src_stride = dsc->src_stride; const lv_opa_t * mask_buf = dsc->mask_buf; @@ -448,7 +450,7 @@ LV_ATTRIBUTE_FAST_MEM static void argb8888_image_blend(_lv_draw_sw_blend_image_d for(dest_x = 0, src_x = 0; dest_x < w; dest_x++, src_x += 4) { dest_buf_u16[dest_x] = lv_color_24_16_mix(&src_buf_u8[src_x], dest_buf_u16[dest_x], src_buf_u8[src_x + 3]); } - dest_buf_u16 += dest_stride_px; + dest_buf_u16 = drawbuf_next_row(dest_buf_u16, dest_stride); src_buf_u8 += src_stride; } } @@ -458,7 +460,7 @@ LV_ATTRIBUTE_FAST_MEM static void argb8888_image_blend(_lv_draw_sw_blend_image_d dest_buf_u16[dest_x] = lv_color_24_16_mix(&src_buf_u8[src_x], dest_buf_u16[dest_x], LV_OPA_MIX2(src_buf_u8[src_x + 3], opa)); } - dest_buf_u16 += dest_stride_px; + dest_buf_u16 = drawbuf_next_row(dest_buf_u16, dest_stride); src_buf_u8 += src_stride; } } @@ -468,7 +470,7 @@ LV_ATTRIBUTE_FAST_MEM static void argb8888_image_blend(_lv_draw_sw_blend_image_d dest_buf_u16[dest_x] = lv_color_24_16_mix(&src_buf_u8[src_x], dest_buf_u16[dest_x], LV_OPA_MIX2(src_buf_u8[src_x + 3], mask_buf[dest_x])); } - dest_buf_u16 += dest_stride_px; + dest_buf_u16 = drawbuf_next_row(dest_buf_u16, dest_stride); src_buf_u8 += src_stride; mask_buf += mask_stride; } @@ -479,7 +481,7 @@ LV_ATTRIBUTE_FAST_MEM static void argb8888_image_blend(_lv_draw_sw_blend_image_d dest_buf_u16[dest_x] = lv_color_24_16_mix(&src_buf_u8[src_x], dest_buf_u16[dest_x], LV_OPA_MIX3(src_buf_u8[src_x + 3], mask_buf[dest_x], opa)); } - dest_buf_u16 += dest_stride_px; + dest_buf_u16 = drawbuf_next_row(dest_buf_u16, dest_stride); src_buf_u8 += src_stride; mask_buf += mask_stride; } @@ -524,7 +526,7 @@ LV_ATTRIBUTE_FAST_MEM static void argb8888_image_blend(_lv_draw_sw_blend_image_d } } - dest_buf_u16 += dest_stride_px; + dest_buf_u16 = drawbuf_next_row(dest_buf_u16, dest_stride); src_buf_u8 += src_stride; if(mask_buf) mask_buf += mask_stride; } @@ -548,4 +550,9 @@ LV_ATTRIBUTE_FAST_MEM static inline uint16_t lv_color_24_16_mix(const uint8_t * } } +LV_ATTRIBUTE_FAST_MEM static inline void * drawbuf_next_row(const void * buf, uint32_t stride) +{ + return (void *)((uint8_t *)buf + stride); +} + #endif diff --git a/src/draw/sw/blend/lv_draw_sw_blend_to_rgb888.c b/src/draw/sw/blend/lv_draw_sw_blend_to_rgb888.c index d25ba333e..c75d0e96e 100644 --- a/src/draw/sw/blend/lv_draw_sw_blend_to_rgb888.c +++ b/src/draw/sw/blend/lv_draw_sw_blend_to_rgb888.c @@ -44,6 +44,7 @@ LV_ATTRIBUTE_FAST_MEM static void argb8888_image_blend(_lv_draw_sw_blend_image_d LV_ATTRIBUTE_FAST_MEM static inline void lv_color_24_24_mix(const uint8_t * src, uint8_t * dest, uint8_t mix); LV_ATTRIBUTE_FAST_MEM static inline void blend_non_normal_pixel(uint8_t * dest, lv_color32_t src, lv_blend_mode_t mode); +LV_ATTRIBUTE_FAST_MEM static inline void * drawbuf_next_row(const void * buf, uint32_t stride); /********************** * STATIC VARIABLES @@ -104,7 +105,6 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_blend_color_to_rgb888(_lv_draw_sw_blend_fi if(dest_px_size == 4) { uint32_t color32 = lv_color_to_u32(dsc->color); uint32_t * dest_buf_u32 = dsc->dest_buf; - uint32_t dest_stride_px = dest_stride / 4; for(y = 0; y < h; y++) { for(x = 0; x <= w - 16; x += 16) { dest_buf_u32[x + 0] = color32; @@ -131,7 +131,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_blend_color_to_rgb888(_lv_draw_sw_blend_fi dest_buf_u32[x] = color32; } - dest_buf_u32 += dest_stride_px; + dest_buf_u32 = drawbuf_next_row(dest_buf_u32, dest_stride); } } #endif @@ -148,7 +148,8 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_blend_color_to_rgb888(_lv_draw_sw_blend_fi for(x = 0; x < w; x += dest_px_size) { lv_color_24_24_mix((const uint8_t *)&color32, &dest_buf[x], opa); } - dest_buf += dest_stride; + + dest_buf = drawbuf_next_row(dest_buf, dest_stride); } #endif } @@ -225,7 +226,7 @@ LV_ATTRIBUTE_FAST_MEM static void rgb565_image_blend(_lv_draw_sw_blend_image_dsc uint8_t * dest_buf_u8 = dsc->dest_buf; int32_t dest_stride = dsc->dest_stride; const lv_color16_t * src_buf_c16 = (const lv_color16_t *) dsc->src_buf; - int32_t src_stride = dsc->src_stride / 2; + int32_t src_stride = dsc->src_stride; const lv_opa_t * mask_buf = dsc->mask_buf; int32_t mask_stride = dsc->mask_stride; @@ -242,7 +243,7 @@ LV_ATTRIBUTE_FAST_MEM static void rgb565_image_blend(_lv_draw_sw_blend_image_dsc dest_buf_u8[dest_x + 0] = (src_buf_c16[src_x].blue * 2106) >> 8; } dest_buf_u8 += dest_stride; - src_buf_c16 += src_stride; + src_buf_c16 = drawbuf_next_row(src_buf_c16, src_stride); } } else if(mask_buf == NULL && opa < LV_OPA_MAX) { @@ -255,7 +256,7 @@ LV_ATTRIBUTE_FAST_MEM static void rgb565_image_blend(_lv_draw_sw_blend_image_dsc lv_color_24_24_mix(res, &dest_buf_u8[dest_x], opa); } dest_buf_u8 += dest_stride; - src_buf_c16 += src_stride; + src_buf_c16 = drawbuf_next_row(src_buf_c16, src_stride); } } else if(mask_buf && opa >= LV_OPA_MAX) { @@ -268,7 +269,7 @@ LV_ATTRIBUTE_FAST_MEM static void rgb565_image_blend(_lv_draw_sw_blend_image_dsc lv_color_24_24_mix(res, &dest_buf_u8[dest_x], mask_buf[src_x]); } dest_buf_u8 += dest_stride; - src_buf_c16 += src_stride; + src_buf_c16 = drawbuf_next_row(src_buf_c16, src_stride); mask_buf += mask_stride; } } @@ -282,7 +283,7 @@ LV_ATTRIBUTE_FAST_MEM static void rgb565_image_blend(_lv_draw_sw_blend_image_dsc lv_color_24_24_mix(res, &dest_buf_u8[dest_x], LV_OPA_MIX2(opa, mask_buf[src_x])); } dest_buf_u8 += dest_stride; - src_buf_c16 += src_stride; + src_buf_c16 = drawbuf_next_row(src_buf_c16, src_stride); mask_buf += mask_stride; } } @@ -300,7 +301,7 @@ LV_ATTRIBUTE_FAST_MEM static void rgb565_image_blend(_lv_draw_sw_blend_image_dsc } if(mask_buf) mask_buf += mask_stride; dest_buf_u8 += dest_stride; - src_buf_c16 += src_stride; + src_buf_c16 = drawbuf_next_row(src_buf_c16, src_stride); } } } @@ -403,7 +404,7 @@ LV_ATTRIBUTE_FAST_MEM static void argb8888_image_blend(_lv_draw_sw_blend_image_d uint8_t * dest_buf = dsc->dest_buf; int32_t dest_stride = dsc->dest_stride; const lv_color32_t * src_buf_c32 = dsc->src_buf; - int32_t src_stride = dsc->src_stride / 4; + int32_t src_stride = dsc->src_stride; const lv_opa_t * mask_buf = dsc->mask_buf; int32_t mask_stride = dsc->mask_stride; @@ -421,7 +422,7 @@ LV_ATTRIBUTE_FAST_MEM static void argb8888_image_blend(_lv_draw_sw_blend_image_d lv_color_24_24_mix((const uint8_t *)&src_buf_c32[src_x], &dest_buf[dest_x], src_buf_c32[src_x].alpha); } dest_buf += dest_stride; - src_buf_c32 += src_stride; + src_buf_c32 = drawbuf_next_row(src_buf_c32, src_stride); } #endif } @@ -434,7 +435,7 @@ LV_ATTRIBUTE_FAST_MEM static void argb8888_image_blend(_lv_draw_sw_blend_image_d lv_color_24_24_mix((const uint8_t *)&src_buf_c32[src_x], &dest_buf[dest_x], LV_OPA_MIX2(src_buf_c32[src_x].alpha, opa)); } dest_buf += dest_stride; - src_buf_c32 += src_stride; + src_buf_c32 = drawbuf_next_row(src_buf_c32, src_stride); } #endif } @@ -448,7 +449,7 @@ LV_ATTRIBUTE_FAST_MEM static void argb8888_image_blend(_lv_draw_sw_blend_image_d LV_OPA_MIX2(src_buf_c32[src_x].alpha, mask_buf[src_x])); } dest_buf += dest_stride; - src_buf_c32 += src_stride; + src_buf_c32 = drawbuf_next_row(src_buf_c32, src_stride); mask_buf += mask_stride; } #endif @@ -463,7 +464,7 @@ LV_ATTRIBUTE_FAST_MEM static void argb8888_image_blend(_lv_draw_sw_blend_image_d LV_OPA_MIX3(src_buf_c32[src_x].alpha, mask_buf[src_x], opa)); } dest_buf += dest_stride; - src_buf_c32 += src_stride; + src_buf_c32 = drawbuf_next_row(src_buf_c32, src_stride); mask_buf += mask_stride; } #endif @@ -481,7 +482,7 @@ LV_ATTRIBUTE_FAST_MEM static void argb8888_image_blend(_lv_draw_sw_blend_image_d } if(mask_buf) mask_buf += mask_stride; dest_buf += dest_stride; - src_buf_c32 += src_stride; + src_buf_c32 = drawbuf_next_row(src_buf_c32, src_stride); } } } @@ -534,4 +535,9 @@ LV_ATTRIBUTE_FAST_MEM static inline void lv_color_24_24_mix(const uint8_t * src, } } +LV_ATTRIBUTE_FAST_MEM static inline void * drawbuf_next_row(const void * buf, uint32_t stride) +{ + return (void *)((uint8_t *)buf + stride); +} + #endif