| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#include "lv_draw_sw_blend_to_l8.h" |
| 10 |
#if LV_USE_DRAW_SW |
| 11 |
|
| 12 |
#if LV_DRAW_SW_SUPPORT_L8 |
| 13 |
|
| 14 |
#include "lv_draw_sw_blend_private.h" |
| 15 |
#include "../../../misc/lv_math.h" |
| 16 |
#include "../../../display/lv_display.h" |
| 17 |
#include "../../../core/lv_refr.h" |
| 18 |
#include "../../../misc/lv_color.h" |
| 19 |
#include "../../../stdlib/lv_string.h" |
| 20 |
|
| 21 |
#if LV_USE_DRAW_SW_ASM == LV_DRAW_SW_ASM_NEON |
| 22 |
#include "neon/lv_blend_neon.h" |
| 23 |
#elif LV_USE_DRAW_SW_ASM == LV_DRAW_SW_ASM_HELIUM |
| 24 |
#include "helium/lv_blend_helium.h" |
| 25 |
#elif LV_USE_DRAW_SW_ASM == LV_DRAW_SW_ASM_CUSTOM |
| 26 |
#include LV_DRAW_SW_ASM_CUSTOM_INCLUDE |
| 27 |
#endif |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
#if LV_DRAW_SW_SUPPORT_I1 |
| 42 |
static void i1_image_blend(lv_draw_sw_blend_image_dsc_t * dsc); |
| 43 |
|
| 44 |
static inline uint8_t get_bit(const uint8_t * buf, int32_t bit_idx); |
| 45 |
#endif |
| 46 |
|
| 47 |
static void l8_image_blend(lv_draw_sw_blend_image_dsc_t * dsc); |
| 48 |
|
| 49 |
#if LV_DRAW_SW_SUPPORT_AL88 |
| 50 |
static void al88_image_blend(lv_draw_sw_blend_image_dsc_t * dsc); |
| 51 |
#endif |
| 52 |
|
| 53 |
#if LV_DRAW_SW_SUPPORT_RGB565 |
| 54 |
static void rgb565_image_blend(lv_draw_sw_blend_image_dsc_t * dsc); |
| 55 |
#endif |
| 56 |
|
| 57 |
#if LV_DRAW_SW_SUPPORT_RGB565_SWAPPED |
| 58 |
static void rgb565_image_blend_swapped(lv_draw_sw_blend_image_dsc_t * dsc); |
| 59 |
#endif |
| 60 |
|
| 61 |
#if LV_DRAW_SW_SUPPORT_RGB888 || LV_DRAW_SW_SUPPORT_XRGB8888 |
| 62 |
static void rgb888_image_blend(lv_draw_sw_blend_image_dsc_t * dsc, |
| 63 |
const uint8_t src_px_size); |
| 64 |
#endif |
| 65 |
|
| 66 |
#if LV_DRAW_SW_SUPPORT_ARGB8888 |
| 67 |
static void argb8888_image_blend(lv_draw_sw_blend_image_dsc_t * dsc); |
| 68 |
#endif |
| 69 |
|
| 70 |
static inline void lv_color_8_8_mix(const uint8_t src, uint8_t * dest, uint8_t mix); |
| 71 |
|
| 72 |
static inline void blend_non_normal_pixel(uint8_t * dest, lv_color32_t src, |
| 73 |
lv_blend_mode_t mode); |
| 74 |
|
| 75 |
static inline void * drawbuf_next_row(const void * buf, uint32_t stride); |
| 76 |
|
| 77 |
#if LV_DRAW_SW_SUPPORT_RGB565_SWAPPED |
| 78 |
static inline lv_color16_t lv_color16_from_u16(uint16_t raw); |
| 79 |
#endif |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
#ifndef LV_DRAW_SW_COLOR_BLEND_TO_L8 |
| 90 |
#define LV_DRAW_SW_COLOR_BLEND_TO_L8(...) LV_RESULT_INVALID |
| 91 |
#endif |
| 92 |
|
| 93 |
#ifndef LV_DRAW_SW_COLOR_BLEND_TO_L8_WITH_OPA |
| 94 |
#define LV_DRAW_SW_COLOR_BLEND_TO_L8_WITH_OPA(...) LV_RESULT_INVALID |
| 95 |
#endif |
| 96 |
|
| 97 |
#ifndef LV_DRAW_SW_COLOR_BLEND_TO_L8_WITH_MASK |
| 98 |
#define LV_DRAW_SW_COLOR_BLEND_TO_L8_WITH_MASK(...) LV_RESULT_INVALID |
| 99 |
#endif |
| 100 |
|
| 101 |
#ifndef LV_DRAW_SW_COLOR_BLEND_TO_L8_MIX_MASK_OPA |
| 102 |
#define LV_DRAW_SW_COLOR_BLEND_TO_L8_MIX_MASK_OPA(...) LV_RESULT_INVALID |
| 103 |
#endif |
| 104 |
|
| 105 |
#ifndef LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_L8 |
| 106 |
#define LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_L8(...) LV_RESULT_INVALID |
| 107 |
#endif |
| 108 |
|
| 109 |
#ifndef LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_L8_WITH_OPA |
| 110 |
#define LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_L8_WITH_OPA(...) LV_RESULT_INVALID |
| 111 |
#endif |
| 112 |
|
| 113 |
#ifndef LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_L8_WITH_MASK |
| 114 |
#define LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_L8_WITH_MASK(...) LV_RESULT_INVALID |
| 115 |
#endif |
| 116 |
|
| 117 |
#ifndef LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_L8_MIX_MASK_OPA |
| 118 |
#define LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_L8_MIX_MASK_OPA(...) LV_RESULT_INVALID |
| 119 |
#endif |
| 120 |
|
| 121 |
#ifndef LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_L8 |
| 122 |
#define LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_L8(...) LV_RESULT_INVALID |
| 123 |
#endif |
| 124 |
|
| 125 |
#ifndef LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_L8_WITH_OPA |
| 126 |
#define LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_L8_WITH_OPA(...) LV_RESULT_INVALID |
| 127 |
#endif |
| 128 |
|
| 129 |
#ifndef LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_L8_WITH_MASK |
| 130 |
#define LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_L8_WITH_MASK(...) LV_RESULT_INVALID |
| 131 |
#endif |
| 132 |
|
| 133 |
#ifndef LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_L8_MIX_MASK_OPA |
| 134 |
#define LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_L8_MIX_MASK_OPA(...) LV_RESULT_INVALID |
| 135 |
#endif |
| 136 |
|
| 137 |
#ifndef LV_DRAW_SW_L8_BLEND_NORMAL_TO_L8 |
| 138 |
#define LV_DRAW_SW_L8_BLEND_NORMAL_TO_L8(...) LV_RESULT_INVALID |
| 139 |
#endif |
| 140 |
|
| 141 |
#ifndef LV_DRAW_SW_L8_BLEND_NORMAL_TO_L8_WITH_OPA |
| 142 |
#define LV_DRAW_SW_L8_BLEND_NORMAL_TO_L8_WITH_OPA(...) LV_RESULT_INVALID |
| 143 |
#endif |
| 144 |
|
| 145 |
#ifndef LV_DRAW_SW_L8_BLEND_NORMAL_TO_L8_WITH_MASK |
| 146 |
#define LV_DRAW_SW_L8_BLEND_NORMAL_TO_L8_WITH_MASK(...) LV_RESULT_INVALID |
| 147 |
#endif |
| 148 |
|
| 149 |
#ifndef LV_DRAW_SW_L8_BLEND_NORMAL_TO_L8_MIX_MASK_OPA |
| 150 |
#define LV_DRAW_SW_L8_BLEND_NORMAL_TO_L8_MIX_MASK_OPA(...) LV_RESULT_INVALID |
| 151 |
#endif |
| 152 |
|
| 153 |
#ifndef LV_DRAW_SW_AL88_BLEND_NORMAL_TO_L8 |
| 154 |
#define LV_DRAW_SW_AL88_BLEND_NORMAL_TO_L8(...) LV_RESULT_INVALID |
| 155 |
#endif |
| 156 |
|
| 157 |
#ifndef LV_DRAW_SW_AL88_BLEND_NORMAL_TO_L8_WITH_OPA |
| 158 |
#define LV_DRAW_SW_AL88_BLEND_NORMAL_TO_L8_WITH_OPA(...) LV_RESULT_INVALID |
| 159 |
#endif |
| 160 |
|
| 161 |
#ifndef LV_DRAW_SW_AL88_BLEND_NORMAL_TO_L8_WITH_MASK |
| 162 |
#define LV_DRAW_SW_AL88_BLEND_NORMAL_TO_L8_WITH_MASK(...) LV_RESULT_INVALID |
| 163 |
#endif |
| 164 |
|
| 165 |
#ifndef LV_DRAW_SW_AL88_BLEND_NORMAL_TO_L8_MIX_MASK_OPA |
| 166 |
#define LV_DRAW_SW_AL88_BLEND_NORMAL_TO_L8_MIX_MASK_OPA(...) LV_RESULT_INVALID |
| 167 |
#endif |
| 168 |
|
| 169 |
#ifndef LV_DRAW_SW_I1_BLEND_NORMAL_TO_L8 |
| 170 |
#define LV_DRAW_SW_I1_BLEND_NORMAL_TO_L8(...) LV_RESULT_INVALID |
| 171 |
#endif |
| 172 |
|
| 173 |
#ifndef LV_DRAW_SW_I1_BLEND_NORMAL_TO_L8_WITH_OPA |
| 174 |
#define LV_DRAW_SW_I1_BLEND_NORMAL_TO_L8_WITH_OPA(...) LV_RESULT_INVALID |
| 175 |
#endif |
| 176 |
|
| 177 |
#ifndef LV_DRAW_SW_I1_BLEND_NORMAL_TO_L8_WITH_MASK |
| 178 |
#define LV_DRAW_SW_I1_BLEND_NORMAL_TO_L8_WITH_MASK(...) LV_RESULT_INVALID |
| 179 |
#endif |
| 180 |
|
| 181 |
#ifndef LV_DRAW_SW_I1_BLEND_NORMAL_TO_L8_MIX_MASK_OPA |
| 182 |
#define LV_DRAW_SW_I1_BLEND_NORMAL_TO_L8_MIX_MASK_OPA(...) LV_RESULT_INVALID |
| 183 |
#endif |
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
void LV_ATTRIBUTE_FAST_MEM lv_draw_sw_blend_color_to_l8(lv_draw_sw_blend_fill_dsc_t * dsc) |
| 190 |
{ |
| 191 |
int32_t w = dsc->dest_w; |
| 192 |
int32_t h = dsc->dest_h; |
| 193 |
lv_opa_t opa = dsc->opa; |
| 194 |
const lv_opa_t * mask = dsc->mask_buf; |
| 195 |
int32_t mask_stride = dsc->mask_stride; |
| 196 |
int32_t dest_stride = dsc->dest_stride; |
| 197 |
|
| 198 |
int32_t x; |
| 199 |
int32_t y; |
| 200 |
|
| 201 |
LV_UNUSED(w); |
| 202 |
LV_UNUSED(h); |
| 203 |
LV_UNUSED(x); |
| 204 |
LV_UNUSED(y); |
| 205 |
LV_UNUSED(opa); |
| 206 |
LV_UNUSED(mask); |
| 207 |
LV_UNUSED(mask_stride); |
| 208 |
LV_UNUSED(dest_stride); |
| 209 |
|
| 210 |
|
| 211 |
if(mask == NULL && opa >= LV_OPA_MAX) { |
| 212 |
if(LV_RESULT_INVALID == LV_DRAW_SW_COLOR_BLEND_TO_L8(dsc)) { |
| 213 |
uint8_t color8 = lv_color_luminance(dsc->color); |
| 214 |
uint8_t * dest_buf = dsc->dest_buf; |
| 215 |
for(y = 0; y < h; y++) { |
| 216 |
for(x = 0; x < w - 16; x += 16) { |
| 217 |
dest_buf[x + 0] = color8; |
| 218 |
dest_buf[x + 1] = color8; |
| 219 |
dest_buf[x + 2] = color8; |
| 220 |
dest_buf[x + 3] = color8; |
| 221 |
|
| 222 |
dest_buf[x + 4] = color8; |
| 223 |
dest_buf[x + 5] = color8; |
| 224 |
dest_buf[x + 6] = color8; |
| 225 |
dest_buf[x + 7] = color8; |
| 226 |
|
| 227 |
dest_buf[x + 8] = color8; |
| 228 |
dest_buf[x + 9] = color8; |
| 229 |
dest_buf[x + 10] = color8; |
| 230 |
dest_buf[x + 11] = color8; |
| 231 |
|
| 232 |
dest_buf[x + 12] = color8; |
| 233 |
dest_buf[x + 13] = color8; |
| 234 |
dest_buf[x + 14] = color8; |
| 235 |
dest_buf[x + 15] = color8; |
| 236 |
} |
| 237 |
for(; x < w; x ++) { |
| 238 |
dest_buf[x] = color8; |
| 239 |
} |
| 240 |
|
| 241 |
dest_buf = drawbuf_next_row(dest_buf, dest_stride); |
| 242 |
} |
| 243 |
} |
| 244 |
} |
| 245 |
|
| 246 |
else if(mask == NULL && opa < LV_OPA_MAX) { |
| 247 |
if(LV_RESULT_INVALID == LV_DRAW_SW_COLOR_BLEND_TO_L8_WITH_OPA(dsc)) { |
| 248 |
uint8_t color8 = lv_color_luminance(dsc->color); |
| 249 |
uint8_t * dest_buf = dsc->dest_buf; |
| 250 |
|
| 251 |
for(y = 0; y < h; y++) { |
| 252 |
for(x = 0; x < w; x++) { |
| 253 |
lv_color_8_8_mix(color8, &dest_buf[x], opa); |
| 254 |
} |
| 255 |
dest_buf = drawbuf_next_row(dest_buf, dest_stride); |
| 256 |
} |
| 257 |
} |
| 258 |
|
| 259 |
} |
| 260 |
|
| 261 |
else if(mask && opa >= LV_OPA_MAX) { |
| 262 |
if(LV_RESULT_INVALID == LV_DRAW_SW_COLOR_BLEND_TO_L8_WITH_MASK(dsc)) { |
| 263 |
uint8_t color8 = lv_color_luminance(dsc->color); |
| 264 |
uint8_t * dest_buf = dsc->dest_buf; |
| 265 |
for(y = 0; y < h; y++) { |
| 266 |
for(x = 0; x < w; x++) { |
| 267 |
lv_color_8_8_mix(color8, &dest_buf[x], mask[x]); |
| 268 |
} |
| 269 |
dest_buf = drawbuf_next_row(dest_buf, dest_stride); |
| 270 |
mask += mask_stride; |
| 271 |
} |
| 272 |
} |
| 273 |
|
| 274 |
} |
| 275 |
|
| 276 |
else { |
| 277 |
if(LV_RESULT_INVALID == LV_DRAW_SW_COLOR_BLEND_TO_L8_MIX_MASK_OPA(dsc)) { |
| 278 |
uint8_t color8 = lv_color_luminance(dsc->color); |
| 279 |
uint8_t * dest_buf = dsc->dest_buf; |
| 280 |
for(y = 0; y < h; y++) { |
| 281 |
for(x = 0; x < w; x++) { |
| 282 |
lv_color_8_8_mix(color8, &dest_buf[x], LV_OPA_MIX2(mask[x], opa)); |
| 283 |
} |
| 284 |
dest_buf = drawbuf_next_row(dest_buf, dest_stride); |
| 285 |
mask += mask_stride; |
| 286 |
} |
| 287 |
} |
| 288 |
} |
| 289 |
} |
| 290 |
|
| 291 |
void LV_ATTRIBUTE_FAST_MEM lv_draw_sw_blend_image_to_l8(lv_draw_sw_blend_image_dsc_t * dsc) |
| 292 |
{ |
| 293 |
switch(dsc->src_color_format) { |
| 294 |
#if LV_DRAW_SW_SUPPORT_RGB565 |
| 295 |
case LV_COLOR_FORMAT_RGB565: |
| 296 |
rgb565_image_blend(dsc); |
| 297 |
break; |
| 298 |
#endif |
| 299 |
#if LV_DRAW_SW_SUPPORT_RGB565_SWAPPED |
| 300 |
case LV_COLOR_FORMAT_RGB565_SWAPPED: |
| 301 |
rgb565_image_blend_swapped(dsc); |
| 302 |
break; |
| 303 |
#endif |
| 304 |
#if LV_DRAW_SW_SUPPORT_RGB888 |
| 305 |
case LV_COLOR_FORMAT_RGB888: |
| 306 |
rgb888_image_blend(dsc, 3); |
| 307 |
break; |
| 308 |
#endif |
| 309 |
#if LV_DRAW_SW_SUPPORT_XRGB8888 |
| 310 |
case LV_COLOR_FORMAT_XRGB8888: |
| 311 |
rgb888_image_blend(dsc, 4); |
| 312 |
break; |
| 313 |
#endif |
| 314 |
#if LV_DRAW_SW_SUPPORT_ARGB8888 |
| 315 |
case LV_COLOR_FORMAT_ARGB8888: |
| 316 |
argb8888_image_blend(dsc); |
| 317 |
break; |
| 318 |
#endif |
| 319 |
case LV_COLOR_FORMAT_L8: |
| 320 |
l8_image_blend(dsc); |
| 321 |
break; |
| 322 |
#if LV_DRAW_SW_SUPPORT_AL88 |
| 323 |
case LV_COLOR_FORMAT_AL88: |
| 324 |
al88_image_blend(dsc); |
| 325 |
break; |
| 326 |
#endif |
| 327 |
#if LV_DRAW_SW_SUPPORT_I1 |
| 328 |
case LV_COLOR_FORMAT_I1: |
| 329 |
i1_image_blend(dsc); |
| 330 |
break; |
| 331 |
#endif |
| 332 |
default: |
| 333 |
LV_LOG_WARN("Not supported source color format"); |
| 334 |
break; |
| 335 |
} |
| 336 |
} |
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
#if LV_DRAW_SW_SUPPORT_I1 |
| 343 |
static void LV_ATTRIBUTE_FAST_MEM i1_image_blend(lv_draw_sw_blend_image_dsc_t * dsc) |
| 344 |
{ |
| 345 |
int32_t w = dsc->dest_w; |
| 346 |
int32_t h = dsc->dest_h; |
| 347 |
lv_opa_t opa = dsc->opa; |
| 348 |
uint8_t * dest_buf_l8 = dsc->dest_buf; |
| 349 |
int32_t dest_stride = dsc->dest_stride; |
| 350 |
const uint8_t * src_buf_i1 = dsc->src_buf; |
| 351 |
int32_t src_stride = dsc->src_stride; |
| 352 |
const lv_opa_t * mask_buf = dsc->mask_buf; |
| 353 |
int32_t mask_stride = dsc->mask_stride; |
| 354 |
|
| 355 |
int32_t dest_x; |
| 356 |
int32_t src_x; |
| 357 |
int32_t y; |
| 358 |
|
| 359 |
if(dsc->blend_mode == LV_BLEND_MODE_NORMAL) { |
| 360 |
if(mask_buf == NULL && opa >= LV_OPA_MAX) { |
| 361 |
if(LV_RESULT_INVALID == LV_DRAW_SW_I1_BLEND_NORMAL_TO_L8(dsc)) { |
| 362 |
for(y = 0; y < h; y++) { |
| 363 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 364 |
uint8_t chan_val = get_bit(src_buf_i1, src_x) * 255; |
| 365 |
lv_color_8_8_mix(chan_val, &dest_buf_l8[dest_x], opa); |
| 366 |
} |
| 367 |
dest_buf_l8 = drawbuf_next_row(dest_buf_l8, dest_stride); |
| 368 |
src_buf_i1 = drawbuf_next_row(src_buf_i1, src_stride); |
| 369 |
} |
| 370 |
} |
| 371 |
} |
| 372 |
else if(mask_buf == NULL && opa < LV_OPA_MAX) { |
| 373 |
if(LV_RESULT_INVALID == LV_DRAW_SW_I1_BLEND_NORMAL_TO_L8_WITH_OPA(dsc)) { |
| 374 |
for(y = 0; y < h; y++) { |
| 375 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 376 |
uint8_t chan_val = get_bit(src_buf_i1, src_x) * 255; |
| 377 |
lv_color_8_8_mix(chan_val, &dest_buf_l8[dest_x], opa); |
| 378 |
} |
| 379 |
dest_buf_l8 = drawbuf_next_row(dest_buf_l8, dest_stride); |
| 380 |
src_buf_i1 = drawbuf_next_row(src_buf_i1, src_stride); |
| 381 |
} |
| 382 |
} |
| 383 |
} |
| 384 |
else if(mask_buf && opa >= LV_OPA_MAX) { |
| 385 |
if(LV_RESULT_INVALID == LV_DRAW_SW_I1_BLEND_NORMAL_TO_L8_WITH_MASK(dsc)) { |
| 386 |
for(y = 0; y < h; y++) { |
| 387 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 388 |
uint8_t chan_val = get_bit(src_buf_i1, src_x) * 255; |
| 389 |
lv_color_8_8_mix(chan_val, &dest_buf_l8[dest_x], mask_buf[src_x]); |
| 390 |
} |
| 391 |
dest_buf_l8 = drawbuf_next_row(dest_buf_l8, dest_stride); |
| 392 |
src_buf_i1 = drawbuf_next_row(src_buf_i1, src_stride); |
| 393 |
mask_buf += mask_stride; |
| 394 |
} |
| 395 |
} |
| 396 |
} |
| 397 |
else if(mask_buf && opa < LV_OPA_MAX) { |
| 398 |
if(LV_RESULT_INVALID == LV_DRAW_SW_I1_BLEND_NORMAL_TO_L8_MIX_MASK_OPA(dsc)) { |
| 399 |
for(y = 0; y < h; y++) { |
| 400 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 401 |
uint8_t chan_val = get_bit(src_buf_i1, src_x) * 255; |
| 402 |
lv_color_8_8_mix(chan_val, &dest_buf_l8[dest_x], LV_OPA_MIX2(mask_buf[src_x], opa)); |
| 403 |
} |
| 404 |
dest_buf_l8 = drawbuf_next_row(dest_buf_l8, dest_stride); |
| 405 |
src_buf_i1 = drawbuf_next_row(src_buf_i1, src_stride); |
| 406 |
mask_buf += mask_stride; |
| 407 |
} |
| 408 |
} |
| 409 |
} |
| 410 |
} |
| 411 |
else { |
| 412 |
lv_color32_t src_argb; |
| 413 |
for(y = 0; y < h; y++) { |
| 414 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 415 |
src_argb.red = get_bit(src_buf_i1, src_x) * 255; |
| 416 |
src_argb.green = src_argb.red; |
| 417 |
src_argb.blue = src_argb.red; |
| 418 |
if(mask_buf == NULL) src_argb.alpha = opa; |
| 419 |
else src_argb.alpha = LV_OPA_MIX2(mask_buf[dest_x], opa); |
| 420 |
blend_non_normal_pixel(&dest_buf_l8[dest_x], src_argb, dsc->blend_mode); |
| 421 |
} |
| 422 |
if(mask_buf) mask_buf += mask_stride; |
| 423 |
dest_buf_l8 = drawbuf_next_row(dest_buf_l8, dest_stride); |
| 424 |
src_buf_i1 = drawbuf_next_row(src_buf_i1, src_stride); |
| 425 |
} |
| 426 |
} |
| 427 |
} |
| 428 |
#endif |
| 429 |
|
| 430 |
static void LV_ATTRIBUTE_FAST_MEM l8_image_blend(lv_draw_sw_blend_image_dsc_t * dsc) |
| 431 |
{ |
| 432 |
int32_t w = dsc->dest_w; |
| 433 |
int32_t h = dsc->dest_h; |
| 434 |
lv_opa_t opa = dsc->opa; |
| 435 |
uint8_t * dest_buf_l8 = dsc->dest_buf; |
| 436 |
int32_t dest_stride = dsc->dest_stride; |
| 437 |
const uint8_t * src_buf_l8 = dsc->src_buf; |
| 438 |
int32_t src_stride = dsc->src_stride; |
| 439 |
const lv_opa_t * mask_buf = dsc->mask_buf; |
| 440 |
int32_t mask_stride = dsc->mask_stride; |
| 441 |
|
| 442 |
int32_t dest_x; |
| 443 |
int32_t src_x; |
| 444 |
int32_t y; |
| 445 |
|
| 446 |
if(dsc->blend_mode == LV_BLEND_MODE_NORMAL) { |
| 447 |
if(mask_buf == NULL && opa >= LV_OPA_MAX) { |
| 448 |
if(LV_RESULT_INVALID == LV_DRAW_SW_L8_BLEND_NORMAL_TO_L8(dsc)) { |
| 449 |
for(y = 0; y < h; y++) { |
| 450 |
lv_memcpy(dest_buf_l8, src_buf_l8, w); |
| 451 |
dest_buf_l8 = drawbuf_next_row(dest_buf_l8, dest_stride); |
| 452 |
src_buf_l8 = drawbuf_next_row(src_buf_l8, src_stride); |
| 453 |
} |
| 454 |
} |
| 455 |
} |
| 456 |
else if(mask_buf == NULL && opa < LV_OPA_MAX) { |
| 457 |
if(LV_RESULT_INVALID == LV_DRAW_SW_L8_BLEND_NORMAL_TO_L8_WITH_OPA(dsc)) { |
| 458 |
for(y = 0; y < h; y++) { |
| 459 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 460 |
lv_color_8_8_mix(src_buf_l8[src_x], &dest_buf_l8[dest_x], opa); |
| 461 |
} |
| 462 |
dest_buf_l8 = drawbuf_next_row(dest_buf_l8, dest_stride); |
| 463 |
src_buf_l8 = drawbuf_next_row(src_buf_l8, src_stride); |
| 464 |
} |
| 465 |
} |
| 466 |
} |
| 467 |
else if(mask_buf && opa >= LV_OPA_MAX) { |
| 468 |
if(LV_RESULT_INVALID == LV_DRAW_SW_L8_BLEND_NORMAL_TO_L8_WITH_MASK(dsc)) { |
| 469 |
for(y = 0; y < h; y++) { |
| 470 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 471 |
lv_color_8_8_mix(src_buf_l8[src_x], &dest_buf_l8[dest_x], mask_buf[src_x]); |
| 472 |
} |
| 473 |
dest_buf_l8 = drawbuf_next_row(dest_buf_l8, dest_stride); |
| 474 |
src_buf_l8 = drawbuf_next_row(src_buf_l8, src_stride); |
| 475 |
mask_buf += mask_stride; |
| 476 |
} |
| 477 |
} |
| 478 |
} |
| 479 |
else if(mask_buf && opa < LV_OPA_MAX) { |
| 480 |
if(LV_RESULT_INVALID == LV_DRAW_SW_L8_BLEND_NORMAL_TO_L8_MIX_MASK_OPA(dsc)) { |
| 481 |
for(y = 0; y < h; y++) { |
| 482 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 483 |
lv_color_8_8_mix(src_buf_l8[src_x], &dest_buf_l8[dest_x], LV_OPA_MIX2(mask_buf[src_x], opa)); |
| 484 |
} |
| 485 |
dest_buf_l8 = drawbuf_next_row(dest_buf_l8, dest_stride); |
| 486 |
src_buf_l8 = drawbuf_next_row(src_buf_l8, src_stride); |
| 487 |
mask_buf += mask_stride; |
| 488 |
} |
| 489 |
} |
| 490 |
} |
| 491 |
} |
| 492 |
else { |
| 493 |
lv_color32_t src_argb; |
| 494 |
for(y = 0; y < h; y++) { |
| 495 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 496 |
src_argb.red = src_buf_l8[src_x]; |
| 497 |
src_argb.green = src_buf_l8[src_x]; |
| 498 |
src_argb.blue = src_buf_l8[src_x]; |
| 499 |
if(mask_buf == NULL) src_argb.alpha = opa; |
| 500 |
else src_argb.alpha = LV_OPA_MIX2(mask_buf[dest_x], opa); |
| 501 |
blend_non_normal_pixel(&dest_buf_l8[dest_x], src_argb, dsc->blend_mode); |
| 502 |
} |
| 503 |
if(mask_buf) mask_buf += mask_stride; |
| 504 |
dest_buf_l8 = drawbuf_next_row(dest_buf_l8, dest_stride); |
| 505 |
src_buf_l8 = drawbuf_next_row(src_buf_l8, src_stride); |
| 506 |
} |
| 507 |
} |
| 508 |
} |
| 509 |
|
| 510 |
#if LV_DRAW_SW_SUPPORT_AL88 |
| 511 |
|
| 512 |
static void LV_ATTRIBUTE_FAST_MEM al88_image_blend(lv_draw_sw_blend_image_dsc_t * dsc) |
| 513 |
{ |
| 514 |
int32_t w = dsc->dest_w; |
| 515 |
int32_t h = dsc->dest_h; |
| 516 |
lv_opa_t opa = dsc->opa; |
| 517 |
uint8_t * dest_buf_l8 = dsc->dest_buf; |
| 518 |
int32_t dest_stride = dsc->dest_stride; |
| 519 |
const lv_color16a_t * src_buf_al88 = dsc->src_buf; |
| 520 |
int32_t src_stride = dsc->src_stride; |
| 521 |
const lv_opa_t * mask_buf = dsc->mask_buf; |
| 522 |
int32_t mask_stride = dsc->mask_stride; |
| 523 |
|
| 524 |
int32_t dest_x; |
| 525 |
int32_t src_x; |
| 526 |
int32_t y; |
| 527 |
|
| 528 |
if(dsc->blend_mode == LV_BLEND_MODE_NORMAL) { |
| 529 |
if(mask_buf == NULL && opa >= LV_OPA_MAX) { |
| 530 |
if(LV_RESULT_INVALID == LV_DRAW_SW_AL88_BLEND_NORMAL_TO_L8(dsc)) { |
| 531 |
for(y = 0; y < h; y++) { |
| 532 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 533 |
lv_color_8_8_mix(src_buf_al88[src_x].lumi, &dest_buf_l8[dest_x], src_buf_al88[src_x].alpha); |
| 534 |
} |
| 535 |
dest_buf_l8 = drawbuf_next_row(dest_buf_l8, dest_stride); |
| 536 |
src_buf_al88 = drawbuf_next_row(src_buf_al88, src_stride); |
| 537 |
} |
| 538 |
} |
| 539 |
} |
| 540 |
else if(mask_buf == NULL && opa < LV_OPA_MAX) { |
| 541 |
if(LV_RESULT_INVALID == LV_DRAW_SW_AL88_BLEND_NORMAL_TO_L8_WITH_OPA(dsc)) { |
| 542 |
for(y = 0; y < h; y++) { |
| 543 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 544 |
lv_color_8_8_mix(src_buf_al88[src_x].lumi, &dest_buf_l8[dest_x], LV_OPA_MIX2(src_buf_al88[src_x].alpha, opa)); |
| 545 |
} |
| 546 |
dest_buf_l8 = drawbuf_next_row(dest_buf_l8, dest_stride); |
| 547 |
src_buf_al88 = drawbuf_next_row(src_buf_al88, src_stride); |
| 548 |
} |
| 549 |
} |
| 550 |
} |
| 551 |
else if(mask_buf && opa >= LV_OPA_MAX) { |
| 552 |
if(LV_RESULT_INVALID == LV_DRAW_SW_AL88_BLEND_NORMAL_TO_L8_WITH_MASK(dsc)) { |
| 553 |
for(y = 0; y < h; y++) { |
| 554 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 555 |
lv_color_8_8_mix(src_buf_al88[src_x].lumi, &dest_buf_l8[dest_x], LV_OPA_MIX2(src_buf_al88[src_x].alpha, |
| 556 |
mask_buf[src_x])); |
| 557 |
} |
| 558 |
dest_buf_l8 = drawbuf_next_row(dest_buf_l8, dest_stride); |
| 559 |
src_buf_al88 = drawbuf_next_row(src_buf_al88, src_stride); |
| 560 |
mask_buf += mask_stride; |
| 561 |
} |
| 562 |
} |
| 563 |
} |
| 564 |
else if(mask_buf && opa < LV_OPA_MAX) { |
| 565 |
if(LV_RESULT_INVALID == LV_DRAW_SW_AL88_BLEND_NORMAL_TO_L8_MIX_MASK_OPA(dsc)) { |
| 566 |
for(y = 0; y < h; y++) { |
| 567 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 568 |
lv_color_8_8_mix(src_buf_al88[src_x].lumi, &dest_buf_l8[dest_x], LV_OPA_MIX3(src_buf_al88[src_x].alpha, mask_buf[src_x], |
| 569 |
opa)); |
| 570 |
} |
| 571 |
dest_buf_l8 = drawbuf_next_row(dest_buf_l8, dest_stride); |
| 572 |
src_buf_al88 = drawbuf_next_row(src_buf_al88, src_stride); |
| 573 |
mask_buf += mask_stride; |
| 574 |
} |
| 575 |
} |
| 576 |
} |
| 577 |
} |
| 578 |
else { |
| 579 |
lv_color32_t src_argb; |
| 580 |
for(y = 0; y < h; y++) { |
| 581 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 582 |
src_argb.red = src_buf_al88[src_x].lumi; |
| 583 |
src_argb.green = src_buf_al88[src_x].lumi; |
| 584 |
src_argb.blue = src_buf_al88[src_x].lumi; |
| 585 |
if(mask_buf == NULL) src_argb.alpha = opa; |
| 586 |
else src_argb.alpha = LV_OPA_MIX2(mask_buf[dest_x], opa); |
| 587 |
blend_non_normal_pixel(&dest_buf_l8[dest_x], src_argb, dsc->blend_mode); |
| 588 |
} |
| 589 |
if(mask_buf) mask_buf += mask_stride; |
| 590 |
dest_buf_l8 = drawbuf_next_row(dest_buf_l8, dest_stride); |
| 591 |
src_buf_al88 = drawbuf_next_row(src_buf_al88, src_stride); |
| 592 |
} |
| 593 |
} |
| 594 |
} |
| 595 |
|
| 596 |
#endif |
| 597 |
|
| 598 |
#if LV_DRAW_SW_SUPPORT_RGB565 |
| 599 |
|
| 600 |
static void LV_ATTRIBUTE_FAST_MEM rgb565_image_blend(lv_draw_sw_blend_image_dsc_t * dsc) |
| 601 |
{ |
| 602 |
int32_t w = dsc->dest_w; |
| 603 |
int32_t h = dsc->dest_h; |
| 604 |
lv_opa_t opa = dsc->opa; |
| 605 |
uint8_t * dest_buf_u8 = dsc->dest_buf; |
| 606 |
int32_t dest_stride = dsc->dest_stride; |
| 607 |
const lv_color16_t * src_buf_c16 = (const lv_color16_t *)dsc->src_buf; |
| 608 |
int32_t src_stride = dsc->src_stride; |
| 609 |
const lv_opa_t * mask_buf = dsc->mask_buf; |
| 610 |
int32_t mask_stride = dsc->mask_stride; |
| 611 |
|
| 612 |
|
| 613 |
int32_t src_x; |
| 614 |
int32_t dest_x; |
| 615 |
int32_t y; |
| 616 |
|
| 617 |
if(dsc->blend_mode == LV_BLEND_MODE_NORMAL) { |
| 618 |
if(mask_buf == NULL && opa >= LV_OPA_MAX) { |
| 619 |
if(LV_RESULT_INVALID == LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_L8(dsc)) { |
| 620 |
for(y = 0; y < h; y++) { |
| 621 |
for(src_x = 0, dest_x = 0; src_x < w; dest_x++, src_x++) { |
| 622 |
dest_buf_u8[dest_x] = lv_color16_luminance(src_buf_c16[src_x]); |
| 623 |
} |
| 624 |
dest_buf_u8 += dest_stride; |
| 625 |
src_buf_c16 = drawbuf_next_row(src_buf_c16, src_stride); |
| 626 |
} |
| 627 |
} |
| 628 |
} |
| 629 |
else if(mask_buf == NULL && opa < LV_OPA_MAX) { |
| 630 |
if(LV_RESULT_INVALID == LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_L8_WITH_OPA(dsc, dest_px_size)) { |
| 631 |
for(y = 0; y < h; y++) { |
| 632 |
for(src_x = 0, dest_x = 0; src_x < w; dest_x++, src_x++) { |
| 633 |
lv_color_8_8_mix(lv_color16_luminance(src_buf_c16[src_x]), &dest_buf_u8[dest_x], opa); |
| 634 |
} |
| 635 |
dest_buf_u8 += dest_stride; |
| 636 |
src_buf_c16 = drawbuf_next_row(src_buf_c16, src_stride); |
| 637 |
} |
| 638 |
} |
| 639 |
} |
| 640 |
else if(mask_buf && opa >= LV_OPA_MAX) { |
| 641 |
if(LV_RESULT_INVALID == LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_L8_WITH_MASK(dsc, dest_px_size)) { |
| 642 |
for(y = 0; y < h; y++) { |
| 643 |
for(src_x = 0, dest_x = 0; src_x < w; dest_x++, src_x++) { |
| 644 |
lv_color_8_8_mix(lv_color16_luminance(src_buf_c16[src_x]), &dest_buf_u8[dest_x], mask_buf[src_x]); |
| 645 |
} |
| 646 |
dest_buf_u8 += dest_stride; |
| 647 |
src_buf_c16 = drawbuf_next_row(src_buf_c16, src_stride); |
| 648 |
mask_buf += mask_stride; |
| 649 |
} |
| 650 |
} |
| 651 |
} |
| 652 |
else { |
| 653 |
if(LV_RESULT_INVALID == LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_L8_MIX_MASK_OPA(dsc, dest_px_size)) { |
| 654 |
for(y = 0; y < h; y++) { |
| 655 |
for(src_x = 0, dest_x = 0; src_x < w; dest_x++, src_x++) { |
| 656 |
lv_color_8_8_mix(lv_color16_luminance(src_buf_c16[src_x]), &dest_buf_u8[dest_x], LV_OPA_MIX2(opa, mask_buf[src_x])); |
| 657 |
} |
| 658 |
dest_buf_u8 += dest_stride; |
| 659 |
src_buf_c16 = drawbuf_next_row(src_buf_c16, src_stride); |
| 660 |
mask_buf += mask_stride; |
| 661 |
} |
| 662 |
} |
| 663 |
} |
| 664 |
} |
| 665 |
else { |
| 666 |
lv_color32_t src_argb; |
| 667 |
for(y = 0; y < h; y++) { |
| 668 |
for(src_x = 0, dest_x = 0; src_x < w; src_x++, dest_x++) { |
| 669 |
src_argb.red = (src_buf_c16[src_x].red * 2106) >> 8; |
| 670 |
src_argb.green = (src_buf_c16[src_x].green * 1037) >> 8; |
| 671 |
src_argb.blue = (src_buf_c16[src_x].blue * 2106) >> 8; |
| 672 |
if(mask_buf == NULL) src_argb.alpha = opa; |
| 673 |
else src_argb.alpha = LV_OPA_MIX2(mask_buf[src_x], opa); |
| 674 |
blend_non_normal_pixel(&dest_buf_u8[dest_x], src_argb, dsc->blend_mode); |
| 675 |
} |
| 676 |
if(mask_buf) mask_buf += mask_stride; |
| 677 |
dest_buf_u8 += dest_stride; |
| 678 |
src_buf_c16 = drawbuf_next_row(src_buf_c16, src_stride); |
| 679 |
} |
| 680 |
} |
| 681 |
} |
| 682 |
|
| 683 |
#endif |
| 684 |
|
| 685 |
#if LV_DRAW_SW_SUPPORT_RGB565_SWAPPED |
| 686 |
static void LV_ATTRIBUTE_FAST_MEM rgb565_image_blend_swapped(lv_draw_sw_blend_image_dsc_t * dsc) |
| 687 |
{ |
| 688 |
int32_t w = dsc->dest_w; |
| 689 |
int32_t h = dsc->dest_h; |
| 690 |
lv_opa_t opa = dsc->opa; |
| 691 |
uint8_t * dest_buf_u8 = dsc->dest_buf; |
| 692 |
int32_t dest_stride = dsc->dest_stride; |
| 693 |
const uint16_t * src_buf_u16 = dsc->src_buf; |
| 694 |
int32_t src_stride = dsc->src_stride; |
| 695 |
const lv_opa_t * mask_buf = dsc->mask_buf; |
| 696 |
int32_t mask_stride = dsc->mask_stride; |
| 697 |
|
| 698 |
int32_t src_x; |
| 699 |
int32_t dest_x; |
| 700 |
int32_t y; |
| 701 |
|
| 702 |
uint16_t raw; |
| 703 |
lv_color16_t px; |
| 704 |
|
| 705 |
if(dsc->blend_mode == LV_BLEND_MODE_NORMAL) { |
| 706 |
if(mask_buf == NULL && opa >= LV_OPA_MAX) { |
| 707 |
if(LV_RESULT_INVALID == LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_L8(dsc)) { |
| 708 |
for(y = 0; y < h; y++) { |
| 709 |
for(src_x = 0, dest_x = 0; src_x < w; dest_x++, src_x++) { |
| 710 |
raw = lv_color_swap_16(src_buf_u16[src_x]); |
| 711 |
px = lv_color16_from_u16(raw); |
| 712 |
dest_buf_u8[dest_x] = lv_color16_luminance(px); |
| 713 |
} |
| 714 |
dest_buf_u8 += dest_stride; |
| 715 |
src_buf_u16 = drawbuf_next_row(src_buf_u16, src_stride); |
| 716 |
} |
| 717 |
} |
| 718 |
} |
| 719 |
else if(mask_buf == NULL && opa < LV_OPA_MAX) { |
| 720 |
if(LV_RESULT_INVALID == LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_L8_WITH_OPA(dsc, dest_px_size)) { |
| 721 |
for(y = 0; y < h; y++) { |
| 722 |
for(src_x = 0, dest_x = 0; src_x < w; dest_x++, src_x++) { |
| 723 |
raw = lv_color_swap_16(src_buf_u16[src_x]); |
| 724 |
px = lv_color16_from_u16(raw); |
| 725 |
lv_color_8_8_mix(lv_color16_luminance(px), &dest_buf_u8[dest_x], opa); |
| 726 |
} |
| 727 |
dest_buf_u8 += dest_stride; |
| 728 |
src_buf_u16 = drawbuf_next_row(src_buf_u16, src_stride); |
| 729 |
} |
| 730 |
} |
| 731 |
} |
| 732 |
else if(mask_buf && opa >= LV_OPA_MAX) { |
| 733 |
if(LV_RESULT_INVALID == LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_L8_WITH_MASK(dsc, dest_px_size)) { |
| 734 |
for(y = 0; y < h; y++) { |
| 735 |
for(src_x = 0, dest_x = 0; src_x < w; dest_x++, src_x++) { |
| 736 |
raw = lv_color_swap_16(src_buf_u16[src_x]); |
| 737 |
px = lv_color16_from_u16(raw); |
| 738 |
lv_color_8_8_mix(lv_color16_luminance(px), &dest_buf_u8[dest_x], mask_buf[src_x]); |
| 739 |
} |
| 740 |
dest_buf_u8 += dest_stride; |
| 741 |
src_buf_u16 = drawbuf_next_row(src_buf_u16, src_stride); |
| 742 |
mask_buf += mask_stride; |
| 743 |
} |
| 744 |
} |
| 745 |
} |
| 746 |
else { |
| 747 |
if(LV_RESULT_INVALID == LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_L8_MIX_MASK_OPA(dsc, dest_px_size)) { |
| 748 |
for(y = 0; y < h; y++) { |
| 749 |
for(src_x = 0, dest_x = 0; src_x < w; dest_x++, src_x++) { |
| 750 |
raw = lv_color_swap_16(src_buf_u16[src_x]); |
| 751 |
px = lv_color16_from_u16(raw); |
| 752 |
lv_color_8_8_mix(lv_color16_luminance(px), &dest_buf_u8[dest_x], LV_OPA_MIX2(opa, mask_buf[src_x])); |
| 753 |
} |
| 754 |
dest_buf_u8 += dest_stride; |
| 755 |
src_buf_u16 = drawbuf_next_row(src_buf_u16, src_stride); |
| 756 |
mask_buf += mask_stride; |
| 757 |
} |
| 758 |
} |
| 759 |
} |
| 760 |
} |
| 761 |
else { |
| 762 |
lv_color32_t src_argb; |
| 763 |
for(y = 0; y < h; y++) { |
| 764 |
for(src_x = 0, dest_x = 0; src_x < w; src_x++, dest_x++) { |
| 765 |
raw = lv_color_swap_16(src_buf_u16[src_x]); |
| 766 |
px = lv_color16_from_u16(raw); |
| 767 |
src_argb.red = (px.red * 2106) >> 8; |
| 768 |
src_argb.green = (px.green * 1037) >> 8; |
| 769 |
src_argb.blue = (px.blue * 2106) >> 8; |
| 770 |
if(mask_buf == NULL) src_argb.alpha = opa; |
| 771 |
else src_argb.alpha = LV_OPA_MIX2(mask_buf[src_x], opa); |
| 772 |
blend_non_normal_pixel(&dest_buf_u8[dest_x], src_argb, dsc->blend_mode); |
| 773 |
} |
| 774 |
if(mask_buf) mask_buf += mask_stride; |
| 775 |
dest_buf_u8 += dest_stride; |
| 776 |
src_buf_u16 = drawbuf_next_row(src_buf_u16, src_stride); |
| 777 |
} |
| 778 |
} |
| 779 |
} |
| 780 |
|
| 781 |
#endif |
| 782 |
|
| 783 |
#if LV_DRAW_SW_SUPPORT_RGB888 || LV_DRAW_SW_SUPPORT_XRGB8888 |
| 784 |
|
| 785 |
static void LV_ATTRIBUTE_FAST_MEM rgb888_image_blend(lv_draw_sw_blend_image_dsc_t * dsc, |
| 786 |
const uint8_t src_px_size) |
| 787 |
{ |
| 788 |
int32_t w = dsc->dest_w; |
| 789 |
int32_t h = dsc->dest_h; |
| 790 |
lv_opa_t opa = dsc->opa; |
| 791 |
uint8_t * dest_buf_l8 = dsc->dest_buf; |
| 792 |
int32_t dest_stride = dsc->dest_stride; |
| 793 |
const uint8_t * src_buf_u8 = dsc->src_buf; |
| 794 |
int32_t src_stride = dsc->src_stride; |
| 795 |
const lv_opa_t * mask_buf = dsc->mask_buf; |
| 796 |
int32_t mask_stride = dsc->mask_stride; |
| 797 |
|
| 798 |
int32_t dest_x; |
| 799 |
int32_t src_x; |
| 800 |
int32_t y; |
| 801 |
|
| 802 |
if(dsc->blend_mode == LV_BLEND_MODE_NORMAL) { |
| 803 |
|
| 804 |
if(mask_buf == NULL && opa >= LV_OPA_MAX) { |
| 805 |
if(LV_RESULT_INVALID == LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_L8(dsc, src_px_size)) { |
| 806 |
for(y = 0; y < h; y++) { |
| 807 |
for(dest_x = 0, src_x = 0; dest_x < w; dest_x++, src_x += src_px_size) { |
| 808 |
dest_buf_l8[dest_x] = lv_color24_luminance(&src_buf_u8[src_x]); |
| 809 |
} |
| 810 |
dest_buf_l8 += dest_stride; |
| 811 |
src_buf_u8 += src_stride; |
| 812 |
} |
| 813 |
} |
| 814 |
} |
| 815 |
if(mask_buf == NULL && opa < LV_OPA_MAX) { |
| 816 |
if(LV_RESULT_INVALID == LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_L8_WITH_OPA(dsc, dest_px_size, src_px_size)) { |
| 817 |
for(y = 0; y < h; y++) { |
| 818 |
for(dest_x = 0, src_x = 0; dest_x < w; dest_x++, src_x += src_px_size) { |
| 819 |
lv_color_8_8_mix(lv_color24_luminance(&src_buf_u8[src_x]), &dest_buf_l8[dest_x], opa); |
| 820 |
} |
| 821 |
dest_buf_l8 += dest_stride; |
| 822 |
src_buf_u8 += src_stride; |
| 823 |
} |
| 824 |
} |
| 825 |
} |
| 826 |
if(mask_buf && opa >= LV_OPA_MAX) { |
| 827 |
if(LV_RESULT_INVALID == LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_L8_WITH_MASK(dsc, dest_px_size, src_px_size)) { |
| 828 |
uint32_t mask_x; |
| 829 |
for(y = 0; y < h; y++) { |
| 830 |
for(mask_x = 0, dest_x = 0, src_x = 0; dest_x < w; mask_x++, dest_x++, src_x += src_px_size) { |
| 831 |
lv_color_8_8_mix(lv_color24_luminance(&src_buf_u8[src_x]), &dest_buf_l8[dest_x], mask_buf[mask_x]); |
| 832 |
} |
| 833 |
dest_buf_l8 += dest_stride; |
| 834 |
src_buf_u8 += src_stride; |
| 835 |
mask_buf += mask_stride; |
| 836 |
} |
| 837 |
} |
| 838 |
} |
| 839 |
if(mask_buf && opa < LV_OPA_MAX) { |
| 840 |
if(LV_RESULT_INVALID == LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_L8_MIX_MASK_OPA(dsc, dest_px_size, src_px_size)) { |
| 841 |
uint32_t mask_x; |
| 842 |
for(y = 0; y < h; y++) { |
| 843 |
for(mask_x = 0, dest_x = 0, src_x = 0; dest_x < w; mask_x++, dest_x++, src_x += src_px_size) { |
| 844 |
lv_color_8_8_mix(lv_color24_luminance(&src_buf_u8[src_x]), &dest_buf_l8[dest_x], LV_OPA_MIX2(opa, mask_buf[mask_x])); |
| 845 |
} |
| 846 |
dest_buf_l8 += dest_stride; |
| 847 |
src_buf_u8 += src_stride; |
| 848 |
mask_buf += mask_stride; |
| 849 |
} |
| 850 |
} |
| 851 |
} |
| 852 |
} |
| 853 |
else { |
| 854 |
lv_color32_t src_argb; |
| 855 |
for(y = 0; y < h; y++) { |
| 856 |
for(dest_x = 0, src_x = 0; dest_x < w; dest_x++, src_x += src_px_size) { |
| 857 |
src_argb.red = src_buf_u8[src_x + 2]; |
| 858 |
src_argb.green = src_buf_u8[src_x + 1]; |
| 859 |
src_argb.blue = src_buf_u8[src_x + 0]; |
| 860 |
if(mask_buf == NULL) src_argb.alpha = opa; |
| 861 |
else src_argb.alpha = LV_OPA_MIX2(mask_buf[dest_x], opa); |
| 862 |
|
| 863 |
|
| 864 |
blend_non_normal_pixel(&dest_buf_l8[dest_x], src_argb, dsc->blend_mode); |
| 865 |
} |
| 866 |
if(mask_buf) mask_buf += mask_stride; |
| 867 |
dest_buf_l8 += dest_stride; |
| 868 |
src_buf_u8 += src_stride; |
| 869 |
} |
| 870 |
} |
| 871 |
} |
| 872 |
|
| 873 |
#endif |
| 874 |
|
| 875 |
#if LV_DRAW_SW_SUPPORT_ARGB8888 |
| 876 |
|
| 877 |
static void LV_ATTRIBUTE_FAST_MEM argb8888_image_blend(lv_draw_sw_blend_image_dsc_t * dsc) |
| 878 |
{ |
| 879 |
int32_t w = dsc->dest_w; |
| 880 |
int32_t h = dsc->dest_h; |
| 881 |
lv_opa_t opa = dsc->opa; |
| 882 |
uint8_t * dest_buf_l8 = dsc->dest_buf; |
| 883 |
int32_t dest_stride = dsc->dest_stride; |
| 884 |
const lv_color32_t * src_buf_c32 = dsc->src_buf; |
| 885 |
int32_t src_stride = dsc->src_stride; |
| 886 |
const lv_opa_t * mask_buf = dsc->mask_buf; |
| 887 |
int32_t mask_stride = dsc->mask_stride; |
| 888 |
|
| 889 |
int32_t x; |
| 890 |
int32_t y; |
| 891 |
|
| 892 |
if(dsc->blend_mode == LV_BLEND_MODE_NORMAL) { |
| 893 |
if(mask_buf == NULL && opa >= LV_OPA_MAX) { |
| 894 |
if(LV_RESULT_INVALID == LV_DRAW_SW_L8_BLEND_NORMAL_TO_L8(dsc)) { |
| 895 |
for(y = 0; y < h; y++) { |
| 896 |
for(x = 0; x < w; x++) { |
| 897 |
lv_color_8_8_mix(lv_color32_luminance(src_buf_c32[x]), &dest_buf_l8[x], src_buf_c32[x].alpha); |
| 898 |
} |
| 899 |
dest_buf_l8 = drawbuf_next_row(dest_buf_l8, dest_stride); |
| 900 |
src_buf_c32 = drawbuf_next_row(src_buf_c32, src_stride); |
| 901 |
} |
| 902 |
} |
| 903 |
} |
| 904 |
else if(mask_buf == NULL && opa < LV_OPA_MAX) { |
| 905 |
if(LV_RESULT_INVALID == LV_DRAW_SW_L8_BLEND_NORMAL_TO_L8_WITH_OPA(dsc)) { |
| 906 |
for(y = 0; y < h; y++) { |
| 907 |
for(x = 0; x < w; x++) { |
| 908 |
lv_color_8_8_mix(lv_color32_luminance(src_buf_c32[x]), &dest_buf_l8[x], LV_OPA_MIX2(src_buf_c32[x].alpha, opa)); |
| 909 |
} |
| 910 |
dest_buf_l8 = drawbuf_next_row(dest_buf_l8, dest_stride); |
| 911 |
src_buf_c32 = drawbuf_next_row(src_buf_c32, src_stride); |
| 912 |
} |
| 913 |
} |
| 914 |
} |
| 915 |
else if(mask_buf && opa >= LV_OPA_MAX) { |
| 916 |
if(LV_RESULT_INVALID == LV_DRAW_SW_L8_BLEND_NORMAL_TO_L8_WITH_MASK(dsc)) { |
| 917 |
for(y = 0; y < h; y++) { |
| 918 |
for(x = 0; x < w; x++) { |
| 919 |
lv_color_8_8_mix(lv_color32_luminance(src_buf_c32[x]), &dest_buf_l8[x], LV_OPA_MIX2(src_buf_c32[x].alpha, mask_buf[x])); |
| 920 |
} |
| 921 |
dest_buf_l8 = drawbuf_next_row(dest_buf_l8, dest_stride); |
| 922 |
src_buf_c32 = drawbuf_next_row(src_buf_c32, src_stride); |
| 923 |
mask_buf += mask_stride; |
| 924 |
} |
| 925 |
} |
| 926 |
} |
| 927 |
else if(mask_buf && opa < LV_OPA_MAX) { |
| 928 |
if(LV_RESULT_INVALID == LV_DRAW_SW_L8_BLEND_NORMAL_TO_L8_MIX_MASK_OPA(dsc)) { |
| 929 |
for(y = 0; y < h; y++) { |
| 930 |
for(x = 0; x < w; x++) { |
| 931 |
lv_color_8_8_mix(lv_color32_luminance(src_buf_c32[x]), &dest_buf_l8[x], LV_OPA_MIX3(src_buf_c32[x].alpha, opa, |
| 932 |
mask_buf[x])); |
| 933 |
} |
| 934 |
dest_buf_l8 = drawbuf_next_row(dest_buf_l8, dest_stride); |
| 935 |
src_buf_c32 = drawbuf_next_row(src_buf_c32, src_stride); |
| 936 |
mask_buf += mask_stride; |
| 937 |
} |
| 938 |
} |
| 939 |
} |
| 940 |
} |
| 941 |
else { |
| 942 |
for(y = 0; y < h; y++) { |
| 943 |
for(x = 0; x < w; x++) { |
| 944 |
lv_color32_t color_argb = src_buf_c32[x]; |
| 945 |
if(mask_buf == NULL) color_argb.alpha = LV_OPA_MIX2(color_argb.alpha, opa); |
| 946 |
else color_argb.alpha = LV_OPA_MIX3(color_argb.alpha, mask_buf[x], opa); |
| 947 |
blend_non_normal_pixel(&dest_buf_l8[x], color_argb, dsc->blend_mode); |
| 948 |
} |
| 949 |
if(mask_buf) mask_buf += mask_stride; |
| 950 |
dest_buf_l8 = drawbuf_next_row(dest_buf_l8, dest_stride); |
| 951 |
src_buf_c32 = drawbuf_next_row(src_buf_c32, src_stride); |
| 952 |
} |
| 953 |
} |
| 954 |
} |
| 955 |
|
| 956 |
#endif |
| 957 |
|
| 958 |
static inline void LV_ATTRIBUTE_FAST_MEM lv_color_8_8_mix(const uint8_t src, uint8_t * dest, uint8_t mix) |
| 959 |
{ |
| 960 |
|
| 961 |
if(mix == 0) return; |
| 962 |
|
| 963 |
if(mix >= LV_OPA_MAX) { |
| 964 |
*dest = src; |
| 965 |
} |
| 966 |
else { |
| 967 |
lv_opa_t mix_inv = 255 - mix; |
| 968 |
*dest = (uint32_t)((uint32_t)src * mix + dest[0] * mix_inv) >> 8; |
| 969 |
} |
| 970 |
} |
| 971 |
|
| 972 |
#if LV_DRAW_SW_SUPPORT_I1 |
| 973 |
|
| 974 |
static inline uint8_t LV_ATTRIBUTE_FAST_MEM get_bit(const uint8_t * buf, int32_t bit_idx) |
| 975 |
{ |
| 976 |
return (buf[bit_idx / 8] >> (7 - (bit_idx % 8))) & 1; |
| 977 |
} |
| 978 |
|
| 979 |
#endif |
| 980 |
|
| 981 |
static inline void LV_ATTRIBUTE_FAST_MEM blend_non_normal_pixel(uint8_t * dest, lv_color32_t src, lv_blend_mode_t mode) |
| 982 |
{ |
| 983 |
uint8_t res; |
| 984 |
int32_t src_lumi = lv_color32_luminance(src); |
| 985 |
switch(mode) { |
| 986 |
case LV_BLEND_MODE_ADDITIVE: |
| 987 |
res = LV_MIN(*dest + src_lumi, 255); |
| 988 |
break; |
| 989 |
case LV_BLEND_MODE_SUBTRACTIVE: |
| 990 |
res = LV_MAX(*dest - src_lumi, 0); |
| 991 |
break; |
| 992 |
case LV_BLEND_MODE_MULTIPLY: |
| 993 |
res = (*dest * src_lumi) >> 8; |
| 994 |
break; |
| 995 |
case LV_BLEND_MODE_DIFFERENCE: |
| 996 |
res = LV_ABS(*dest - src_lumi); |
| 997 |
break; |
| 998 |
default: |
| 999 |
LV_LOG_WARN("Not supported blend mode: %d", mode); |
| 1000 |
return; |
| 1001 |
} |
| 1002 |
lv_color_8_8_mix(res, dest, src.alpha); |
| 1003 |
} |
| 1004 |
|
| 1005 |
static inline void * LV_ATTRIBUTE_FAST_MEM drawbuf_next_row(const void * buf, uint32_t stride) |
| 1006 |
{ |
| 1007 |
return (void *)((uint8_t *)buf + stride); |
| 1008 |
} |
| 1009 |
|
| 1010 |
#if LV_DRAW_SW_SUPPORT_RGB565_SWAPPED |
| 1011 |
static inline lv_color16_t LV_ATTRIBUTE_FAST_MEM lv_color16_from_u16(uint16_t raw) |
| 1012 |
{ |
| 1013 |
lv_color16_t c; |
| 1014 |
c.red = (raw >> 11) & 0x1F; |
| 1015 |
c.green = (raw >> 5) & 0x3F; |
| 1016 |
c.blue = raw & 0x1F; |
| 1017 |
return c; |
| 1018 |
} |
| 1019 |
#endif |
| 1020 |
|
| 1021 |
#endif |
| 1022 |
|
| 1023 |
#endif |