| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#include "lv_draw_sw_blend_to_i1.h" |
| 10 |
#if LV_USE_DRAW_SW |
| 11 |
|
| 12 |
#include "lv_draw_sw_blend_private.h" |
| 13 |
#include "../../../misc/lv_math.h" |
| 14 |
#include "../../../display/lv_display.h" |
| 15 |
#include "../../../core/lv_refr.h" |
| 16 |
#include "../../../misc/lv_color.h" |
| 17 |
#include "../../../stdlib/lv_string.h" |
| 18 |
|
| 19 |
#if LV_USE_DRAW_SW_ASM == LV_DRAW_SW_ASM_NEON |
| 20 |
#include "neon/lv_blend_neon.h" |
| 21 |
#elif LV_USE_DRAW_SW_ASM == LV_DRAW_SW_ASM_HELIUM |
| 22 |
#include "helium/lv_blend_helium.h" |
| 23 |
#elif LV_USE_DRAW_SW_ASM == LV_DRAW_SW_ASM_CUSTOM |
| 24 |
#include LV_DRAW_SW_ASM_CUSTOM_INCLUDE |
| 25 |
#endif |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
static void i1_image_blend(lv_draw_sw_blend_image_dsc_t * dsc); |
| 40 |
|
| 41 |
#if LV_DRAW_SW_SUPPORT_L8 |
| 42 |
static void l8_image_blend(lv_draw_sw_blend_image_dsc_t * dsc); |
| 43 |
#endif |
| 44 |
|
| 45 |
#if LV_DRAW_SW_SUPPORT_AL88 |
| 46 |
static void al88_image_blend(lv_draw_sw_blend_image_dsc_t * dsc); |
| 47 |
#endif |
| 48 |
|
| 49 |
#if LV_DRAW_SW_SUPPORT_RGB565 |
| 50 |
static void rgb565_image_blend(lv_draw_sw_blend_image_dsc_t * dsc); |
| 51 |
#endif |
| 52 |
|
| 53 |
#if LV_DRAW_SW_SUPPORT_RGB565_SWAPPED |
| 54 |
static void rgb565_swapped_image_blend(lv_draw_sw_blend_image_dsc_t * dsc); |
| 55 |
#endif |
| 56 |
|
| 57 |
#if LV_DRAW_SW_SUPPORT_RGB888 || LV_DRAW_SW_SUPPORT_XRGB8888 |
| 58 |
static void rgb888_image_blend(lv_draw_sw_blend_image_dsc_t * dsc, |
| 59 |
const uint8_t src_px_size); |
| 60 |
#endif |
| 61 |
|
| 62 |
#if LV_DRAW_SW_SUPPORT_ARGB8888 |
| 63 |
static void argb8888_image_blend(lv_draw_sw_blend_image_dsc_t * dsc); |
| 64 |
#endif |
| 65 |
|
| 66 |
static inline void lv_color_8_8_mix(const uint8_t src, uint8_t * dest, uint8_t mix); |
| 67 |
|
| 68 |
static inline void blend_non_normal_pixel(uint8_t * dest_buf, int32_t dest_x, |
| 69 |
lv_color32_t src, |
| 70 |
lv_blend_mode_t mode); |
| 71 |
|
| 72 |
|
| 73 |
static inline void set_bit(uint8_t * buf, int32_t bit_idx); |
| 74 |
|
| 75 |
static inline void clear_bit(uint8_t * buf, int32_t bit_idx); |
| 76 |
|
| 77 |
static inline uint8_t get_bit(const uint8_t * buf, int32_t bit_idx); |
| 78 |
|
| 79 |
static inline void * drawbuf_next_row(const void * buf, uint32_t stride); |
| 80 |
|
| 81 |
#if LV_DRAW_SW_SUPPORT_RGB565_SWAPPED |
| 82 |
static inline lv_color16_t lv_color16_from_u16(uint16_t raw); |
| 83 |
#endif |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
#define I1_LUM_THRESHOLD LV_DRAW_SW_I1_LUM_THRESHOLD |
| 94 |
|
| 95 |
#ifndef LV_DRAW_SW_I1_BLEND_NORMAL_TO_I1 |
| 96 |
#define LV_DRAW_SW_I1_BLEND_NORMAL_TO_I1(...) LV_RESULT_INVALID |
| 97 |
#endif |
| 98 |
|
| 99 |
#ifndef LV_DRAW_SW_I1_BLEND_NORMAL_TO_I1_WITH_OPA |
| 100 |
#define LV_DRAW_SW_I1_BLEND_NORMAL_TO_I1_WITH_OPA(...) LV_RESULT_INVALID |
| 101 |
#endif |
| 102 |
|
| 103 |
#ifndef LV_DRAW_SW_I1_BLEND_NORMAL_TO_I1_WITH_MASK |
| 104 |
#define LV_DRAW_SW_I1_BLEND_NORMAL_TO_I1_WITH_MASK(...) LV_RESULT_INVALID |
| 105 |
#endif |
| 106 |
|
| 107 |
#ifndef LV_DRAW_SW_I1_BLEND_NORMAL_TO_I1_MIX_MASK_OPA |
| 108 |
#define LV_DRAW_SW_I1_BLEND_NORMAL_TO_I1_MIX_MASK_OPA(...) LV_RESULT_INVALID |
| 109 |
#endif |
| 110 |
|
| 111 |
#ifndef LV_DRAW_SW_COLOR_BLEND_TO_I1 |
| 112 |
#define LV_DRAW_SW_COLOR_BLEND_TO_I1(...) LV_RESULT_INVALID |
| 113 |
#endif |
| 114 |
|
| 115 |
#ifndef LV_DRAW_SW_COLOR_BLEND_TO_I1_WITH_OPA |
| 116 |
#define LV_DRAW_SW_COLOR_BLEND_TO_I1_WITH_OPA(...) LV_RESULT_INVALID |
| 117 |
#endif |
| 118 |
|
| 119 |
#ifndef LV_DRAW_SW_COLOR_BLEND_TO_I1_WITH_MASK |
| 120 |
#define LV_DRAW_SW_COLOR_BLEND_TO_I1_WITH_MASK(...) LV_RESULT_INVALID |
| 121 |
#endif |
| 122 |
|
| 123 |
#ifndef LV_DRAW_SW_COLOR_BLEND_TO_I1_MIX_MASK_OPA |
| 124 |
#define LV_DRAW_SW_COLOR_BLEND_TO_I1_MIX_MASK_OPA(...) LV_RESULT_INVALID |
| 125 |
#endif |
| 126 |
|
| 127 |
#ifndef LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_I1 |
| 128 |
#define LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_I1(...) LV_RESULT_INVALID |
| 129 |
#endif |
| 130 |
|
| 131 |
#ifndef LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_I1_WITH_OPA |
| 132 |
#define LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_I1_WITH_OPA(...) LV_RESULT_INVALID |
| 133 |
#endif |
| 134 |
|
| 135 |
#ifndef LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_I1_WITH_MASK |
| 136 |
#define LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_I1_WITH_MASK(...) LV_RESULT_INVALID |
| 137 |
#endif |
| 138 |
|
| 139 |
#ifndef LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_I1_MIX_MASK_OPA |
| 140 |
#define LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_I1_MIX_MASK_OPA(...) LV_RESULT_INVALID |
| 141 |
#endif |
| 142 |
|
| 143 |
#ifndef LV_DRAW_SW_RGB565_SWAPPED_BLEND_NORMAL_TO_I1 |
| 144 |
#define LV_DRAW_SW_RGB565_SWAPPED_BLEND_NORMAL_TO_I1(...) LV_RESULT_INVALID |
| 145 |
#endif |
| 146 |
|
| 147 |
#ifndef LV_DRAW_SW_RGB565_SWAPPED_BLEND_NORMAL_TO_I1_WITH_OPA |
| 148 |
#define LV_DRAW_SW_RGB565_SWAPPED_BLEND_NORMAL_TO_I1_WITH_OPA(...) LV_RESULT_INVALID |
| 149 |
#endif |
| 150 |
|
| 151 |
#ifndef LV_DRAW_SW_RGB565_SWAPPED_BLEND_NORMAL_TO_I1_WITH_MASK |
| 152 |
#define LV_DRAW_SW_RGB565_SWAPPED_BLEND_NORMAL_TO_I1_WITH_MASK(...) LV_RESULT_INVALID |
| 153 |
#endif |
| 154 |
|
| 155 |
#ifndef LV_DRAW_SW_RGB565_SWAPPED_BLEND_NORMAL_TO_I1_MIX_MASK_OPA |
| 156 |
#define LV_DRAW_SW_RGB565_SWAPPED_BLEND_NORMAL_TO_I1_MIX_MASK_OPA(...) LV_RESULT_INVALID |
| 157 |
#endif |
| 158 |
|
| 159 |
#ifndef LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_I1 |
| 160 |
#define LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_I1(...) LV_RESULT_INVALID |
| 161 |
#endif |
| 162 |
|
| 163 |
#ifndef LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_I1_WITH_OPA |
| 164 |
#define LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_I1_WITH_OPA(...) LV_RESULT_INVALID |
| 165 |
#endif |
| 166 |
|
| 167 |
#ifndef LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_I1_WITH_MASK |
| 168 |
#define LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_I1_WITH_MASK(...) LV_RESULT_INVALID |
| 169 |
#endif |
| 170 |
|
| 171 |
#ifndef LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_I1_MIX_MASK_OPA |
| 172 |
#define LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_I1_MIX_MASK_OPA(...) LV_RESULT_INVALID |
| 173 |
#endif |
| 174 |
|
| 175 |
#ifndef LV_DRAW_SW_L8_BLEND_NORMAL_TO_I1 |
| 176 |
#define LV_DRAW_SW_L8_BLEND_NORMAL_TO_I1(...) LV_RESULT_INVALID |
| 177 |
#endif |
| 178 |
|
| 179 |
#ifndef LV_DRAW_SW_L8_BLEND_NORMAL_TO_I1_WITH_OPA |
| 180 |
#define LV_DRAW_SW_L8_BLEND_NORMAL_TO_I1_WITH_OPA(...) LV_RESULT_INVALID |
| 181 |
#endif |
| 182 |
|
| 183 |
#ifndef LV_DRAW_SW_L8_BLEND_NORMAL_TO_I1_WITH_MASK |
| 184 |
#define LV_DRAW_SW_L8_BLEND_NORMAL_TO_I1_WITH_MASK(...) LV_RESULT_INVALID |
| 185 |
#endif |
| 186 |
|
| 187 |
#ifndef LV_DRAW_SW_L8_BLEND_NORMAL_TO_I1_MIX_MASK_OPA |
| 188 |
#define LV_DRAW_SW_L8_BLEND_NORMAL_TO_I1_MIX_MASK_OPA(...) LV_RESULT_INVALID |
| 189 |
#endif |
| 190 |
|
| 191 |
#ifndef LV_DRAW_SW_AL88_BLEND_NORMAL_TO_I1 |
| 192 |
#define LV_DRAW_SW_AL88_BLEND_NORMAL_TO_I1(...) LV_RESULT_INVALID |
| 193 |
#endif |
| 194 |
|
| 195 |
#ifndef LV_DRAW_SW_AL88_BLEND_NORMAL_TO_I1_WITH_OPA |
| 196 |
#define LV_DRAW_SW_AL88_BLEND_NORMAL_TO_I1_WITH_OPA(...) LV_RESULT_INVALID |
| 197 |
#endif |
| 198 |
|
| 199 |
#ifndef LV_DRAW_SW_AL88_BLEND_NORMAL_TO_I1_WITH_MASK |
| 200 |
#define LV_DRAW_SW_AL88_BLEND_NORMAL_TO_I1_WITH_MASK(...) LV_RESULT_INVALID |
| 201 |
#endif |
| 202 |
|
| 203 |
#ifndef LV_DRAW_SW_AL88_BLEND_NORMAL_TO_I1_MIX_MASK_OPA |
| 204 |
#define LV_DRAW_SW_AL88_BLEND_NORMAL_TO_I1_MIX_MASK_OPA(...) LV_RESULT_INVALID |
| 205 |
#endif |
| 206 |
|
| 207 |
#ifndef LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_I1 |
| 208 |
#define LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_I1(...) LV_RESULT_INVALID |
| 209 |
#endif |
| 210 |
|
| 211 |
#ifndef LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_I1_WITH_OPA |
| 212 |
#define LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_I1_WITH_OPA(...) LV_RESULT_INVALID |
| 213 |
#endif |
| 214 |
|
| 215 |
#ifndef LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_I1_WITH_MASK |
| 216 |
#define LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_I1_WITH_MASK(...) LV_RESULT_INVALID |
| 217 |
#endif |
| 218 |
|
| 219 |
#ifndef LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_I1_MIX_MASK_OPA |
| 220 |
#define LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_I1_MIX_MASK_OPA(...) LV_RESULT_INVALID |
| 221 |
#endif |
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
void LV_ATTRIBUTE_FAST_MEM lv_draw_sw_blend_color_to_i1(lv_draw_sw_blend_fill_dsc_t * dsc) |
| 228 |
{ |
| 229 |
int32_t w = dsc->dest_w; |
| 230 |
int32_t h = dsc->dest_h; |
| 231 |
lv_opa_t opa = dsc->opa; |
| 232 |
const lv_opa_t * mask = dsc->mask_buf; |
| 233 |
int32_t mask_stride = dsc->mask_stride; |
| 234 |
int32_t dest_stride = dsc->dest_stride; |
| 235 |
|
| 236 |
uint8_t src_color = lv_color_luminance(dsc->color) / (I1_LUM_THRESHOLD + 1); |
| 237 |
uint8_t * dest_buf = dsc->dest_buf; |
| 238 |
|
| 239 |
int32_t bit_ofs = dsc->relative_area.x1 % 8; |
| 240 |
|
| 241 |
|
| 242 |
if(mask == NULL && opa >= LV_OPA_MAX) { |
| 243 |
if(LV_RESULT_INVALID == LV_DRAW_SW_COLOR_BLEND_TO_I1(dsc)) { |
| 244 |
for(int32_t y = 0; y < h; y++) { |
| 245 |
for(int32_t x = 0; x < w; x++) { |
| 246 |
if(src_color) { |
| 247 |
set_bit(dest_buf, x + bit_ofs); |
| 248 |
} |
| 249 |
else { |
| 250 |
clear_bit(dest_buf, x + bit_ofs); |
| 251 |
} |
| 252 |
} |
| 253 |
dest_buf = drawbuf_next_row(dest_buf, dest_stride); |
| 254 |
} |
| 255 |
} |
| 256 |
} |
| 257 |
|
| 258 |
else if(mask == NULL && opa < LV_OPA_MAX) { |
| 259 |
if(LV_RESULT_INVALID == LV_DRAW_SW_COLOR_BLEND_TO_I1_WITH_OPA(dsc)) { |
| 260 |
for(int32_t y = 0; y < h; y++) { |
| 261 |
for(int32_t x = 0; x < w; x++) { |
| 262 |
uint8_t * dest_bit = &dest_buf[(x + bit_ofs) / 8]; |
| 263 |
uint8_t current_bit = (*dest_bit >> (7 - ((x + bit_ofs) % 8))) & 0x01; |
| 264 |
uint8_t new_bit = (opa * src_color + (255 - opa) * current_bit) / 255; |
| 265 |
if(new_bit) { |
| 266 |
set_bit(dest_buf, x + bit_ofs); |
| 267 |
} |
| 268 |
else { |
| 269 |
clear_bit(dest_buf, x + bit_ofs); |
| 270 |
} |
| 271 |
} |
| 272 |
dest_buf = drawbuf_next_row(dest_buf, dest_stride); |
| 273 |
} |
| 274 |
} |
| 275 |
} |
| 276 |
|
| 277 |
else if(mask && opa >= LV_OPA_MAX) { |
| 278 |
if(LV_RESULT_INVALID == LV_DRAW_SW_COLOR_BLEND_TO_I1_WITH_MASK(dsc)) { |
| 279 |
for(int32_t y = 0; y < h; y++) { |
| 280 |
for(int32_t x = 0; x < w; x++) { |
| 281 |
uint8_t mask_val = mask[x]; |
| 282 |
if(mask_val == LV_OPA_TRANSP) continue; |
| 283 |
if(mask_val == LV_OPA_COVER) { |
| 284 |
if(src_color) { |
| 285 |
set_bit(dest_buf, x + bit_ofs); |
| 286 |
} |
| 287 |
else { |
| 288 |
clear_bit(dest_buf, x + bit_ofs); |
| 289 |
} |
| 290 |
} |
| 291 |
else { |
| 292 |
uint8_t * dest_bit = &dest_buf[(x + bit_ofs) / 8]; |
| 293 |
uint8_t current_bit = (*dest_bit >> (7 - ((x + bit_ofs) % 8))) & 0x01; |
| 294 |
uint8_t new_bit = (mask_val * src_color + (255 - mask_val) * current_bit) / 255; |
| 295 |
if(new_bit) { |
| 296 |
set_bit(dest_buf, x + bit_ofs); |
| 297 |
} |
| 298 |
else { |
| 299 |
clear_bit(dest_buf, x + bit_ofs); |
| 300 |
} |
| 301 |
} |
| 302 |
} |
| 303 |
dest_buf = drawbuf_next_row(dest_buf, dest_stride); |
| 304 |
mask += mask_stride; |
| 305 |
} |
| 306 |
} |
| 307 |
} |
| 308 |
|
| 309 |
else { |
| 310 |
if(LV_RESULT_INVALID == LV_DRAW_SW_COLOR_BLEND_TO_I1_MIX_MASK_OPA(dsc)) { |
| 311 |
for(int32_t y = 0; y < h; y++) { |
| 312 |
for(int32_t x = 0; x < w; x++) { |
| 313 |
uint8_t mask_val = mask[x]; |
| 314 |
if(mask_val == LV_OPA_TRANSP) continue; |
| 315 |
uint8_t * dest_bit = &dest_buf[(x + bit_ofs) / 8]; |
| 316 |
uint8_t current_bit = (*dest_bit >> (7 - ((x + bit_ofs) % 8))) & 0x01; |
| 317 |
uint8_t blended_opa = (mask_val * opa) / 255; |
| 318 |
uint8_t new_bit = (blended_opa * src_color + (255 - blended_opa) * current_bit) / 255; |
| 319 |
if(new_bit) { |
| 320 |
set_bit(dest_buf, x + bit_ofs); |
| 321 |
} |
| 322 |
else { |
| 323 |
clear_bit(dest_buf, x + bit_ofs); |
| 324 |
} |
| 325 |
} |
| 326 |
dest_buf = drawbuf_next_row(dest_buf, dest_stride); |
| 327 |
mask += mask_stride; |
| 328 |
} |
| 329 |
} |
| 330 |
} |
| 331 |
} |
| 332 |
|
| 333 |
void LV_ATTRIBUTE_FAST_MEM lv_draw_sw_blend_image_to_i1(lv_draw_sw_blend_image_dsc_t * dsc) |
| 334 |
{ |
| 335 |
switch(dsc->src_color_format) { |
| 336 |
#if LV_DRAW_SW_SUPPORT_RGB565 |
| 337 |
case LV_COLOR_FORMAT_RGB565: |
| 338 |
rgb565_image_blend(dsc); |
| 339 |
break; |
| 340 |
#endif |
| 341 |
#if LV_DRAW_SW_SUPPORT_RGB565_SWAPPED |
| 342 |
case LV_COLOR_FORMAT_RGB565_SWAPPED: |
| 343 |
rgb565_swapped_image_blend(dsc); |
| 344 |
break; |
| 345 |
#endif |
| 346 |
#if LV_DRAW_SW_SUPPORT_RGB888 |
| 347 |
case LV_COLOR_FORMAT_RGB888: |
| 348 |
rgb888_image_blend(dsc, 3); |
| 349 |
break; |
| 350 |
#endif |
| 351 |
#if LV_DRAW_SW_SUPPORT_XRGB8888 |
| 352 |
case LV_COLOR_FORMAT_XRGB8888: |
| 353 |
rgb888_image_blend(dsc, 4); |
| 354 |
break; |
| 355 |
#endif |
| 356 |
#if LV_DRAW_SW_SUPPORT_ARGB8888 |
| 357 |
case LV_COLOR_FORMAT_ARGB8888: |
| 358 |
argb8888_image_blend(dsc); |
| 359 |
break; |
| 360 |
#endif |
| 361 |
#if LV_DRAW_SW_SUPPORT_L8 |
| 362 |
case LV_COLOR_FORMAT_L8: |
| 363 |
l8_image_blend(dsc); |
| 364 |
break; |
| 365 |
#endif |
| 366 |
#if LV_DRAW_SW_SUPPORT_AL88 |
| 367 |
case LV_COLOR_FORMAT_AL88: |
| 368 |
al88_image_blend(dsc); |
| 369 |
break; |
| 370 |
#endif |
| 371 |
case LV_COLOR_FORMAT_I1: |
| 372 |
i1_image_blend(dsc); |
| 373 |
break; |
| 374 |
default: |
| 375 |
LV_LOG_WARN("Not supported source color format"); |
| 376 |
break; |
| 377 |
} |
| 378 |
} |
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
static void LV_ATTRIBUTE_FAST_MEM i1_image_blend(lv_draw_sw_blend_image_dsc_t * dsc) |
| 385 |
{ |
| 386 |
int32_t w = dsc->dest_w; |
| 387 |
int32_t h = dsc->dest_h; |
| 388 |
lv_opa_t opa = dsc->opa; |
| 389 |
uint8_t * dest_buf_i1 = dsc->dest_buf; |
| 390 |
int32_t dest_stride = dsc->dest_stride; |
| 391 |
const uint8_t * src_buf_i1 = dsc->src_buf; |
| 392 |
int32_t src_stride = dsc->src_stride; |
| 393 |
const lv_opa_t * mask_buf = dsc->mask_buf; |
| 394 |
int32_t mask_stride = dsc->mask_stride; |
| 395 |
|
| 396 |
int32_t dest_x; |
| 397 |
int32_t src_x; |
| 398 |
int32_t y; |
| 399 |
|
| 400 |
int32_t bit_ofs = dsc->relative_area.x1 % 8; |
| 401 |
|
| 402 |
if(dsc->blend_mode == LV_BLEND_MODE_NORMAL) { |
| 403 |
if(mask_buf == NULL && opa >= LV_OPA_MAX) { |
| 404 |
if(LV_RESULT_INVALID == LV_DRAW_SW_I1_BLEND_NORMAL_TO_I1(dsc)) { |
| 405 |
for(y = 0; y < h; y++) { |
| 406 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 407 |
if(get_bit(src_buf_i1, src_x)) { |
| 408 |
set_bit(dest_buf_i1, dest_x + bit_ofs); |
| 409 |
} |
| 410 |
else { |
| 411 |
clear_bit(dest_buf_i1, dest_x + bit_ofs); |
| 412 |
} |
| 413 |
} |
| 414 |
dest_buf_i1 = drawbuf_next_row(dest_buf_i1, dest_stride); |
| 415 |
src_buf_i1 = drawbuf_next_row(src_buf_i1, src_stride); |
| 416 |
} |
| 417 |
} |
| 418 |
} |
| 419 |
else if(mask_buf == NULL && opa < LV_OPA_MAX) { |
| 420 |
if(LV_RESULT_INVALID == LV_DRAW_SW_I1_BLEND_NORMAL_TO_I1_WITH_OPA(dsc)) { |
| 421 |
for(y = 0; y < h; y++) { |
| 422 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 423 |
uint8_t src = get_bit(src_buf_i1, src_x); |
| 424 |
uint8_t dest = get_bit(dest_buf_i1, dest_x + bit_ofs); |
| 425 |
uint8_t blended = (src * opa + dest * (255 - opa)); |
| 426 |
if(blended > I1_LUM_THRESHOLD) { |
| 427 |
set_bit(dest_buf_i1, dest_x + bit_ofs); |
| 428 |
} |
| 429 |
else { |
| 430 |
clear_bit(dest_buf_i1, dest_x + bit_ofs); |
| 431 |
} |
| 432 |
} |
| 433 |
dest_buf_i1 = drawbuf_next_row(dest_buf_i1, dest_stride); |
| 434 |
src_buf_i1 = drawbuf_next_row(src_buf_i1, src_stride); |
| 435 |
} |
| 436 |
} |
| 437 |
} |
| 438 |
else if(mask_buf && opa >= LV_OPA_MAX) { |
| 439 |
if(LV_RESULT_INVALID == LV_DRAW_SW_I1_BLEND_NORMAL_TO_I1_WITH_MASK(dsc)) { |
| 440 |
for(y = 0; y < h; y++) { |
| 441 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 442 |
uint8_t mask_val = mask_buf[src_x]; |
| 443 |
uint8_t src = get_bit(src_buf_i1, src_x); |
| 444 |
uint8_t dest = get_bit(dest_buf_i1, dest_x + bit_ofs); |
| 445 |
uint8_t blended = (src * mask_val + dest * (255 - mask_val)); |
| 446 |
if(blended > I1_LUM_THRESHOLD) { |
| 447 |
set_bit(dest_buf_i1, dest_x + bit_ofs); |
| 448 |
} |
| 449 |
else { |
| 450 |
clear_bit(dest_buf_i1, dest_x + bit_ofs); |
| 451 |
} |
| 452 |
} |
| 453 |
dest_buf_i1 = drawbuf_next_row(dest_buf_i1, dest_stride); |
| 454 |
src_buf_i1 = drawbuf_next_row(src_buf_i1, src_stride); |
| 455 |
mask_buf += mask_stride; |
| 456 |
} |
| 457 |
} |
| 458 |
} |
| 459 |
else if(mask_buf && opa < LV_OPA_MAX) { |
| 460 |
if(LV_RESULT_INVALID == LV_DRAW_SW_I1_BLEND_NORMAL_TO_I1_MIX_MASK_OPA(dsc)) { |
| 461 |
for(y = 0; y < h; y++) { |
| 462 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 463 |
uint8_t mask_val = mask_buf[src_x]; |
| 464 |
if(mask_val == LV_OPA_TRANSP) continue; |
| 465 |
uint8_t src = get_bit(src_buf_i1, src_x); |
| 466 |
uint8_t dest = get_bit(dest_buf_i1, dest_x + bit_ofs); |
| 467 |
uint8_t blend_opa = LV_OPA_MIX2(mask_val, opa); |
| 468 |
uint8_t blended = (src * blend_opa + dest * (255 - blend_opa)); |
| 469 |
if(blended > I1_LUM_THRESHOLD) { |
| 470 |
set_bit(dest_buf_i1, dest_x + bit_ofs); |
| 471 |
} |
| 472 |
else { |
| 473 |
clear_bit(dest_buf_i1, dest_x + bit_ofs); |
| 474 |
} |
| 475 |
} |
| 476 |
dest_buf_i1 = drawbuf_next_row(dest_buf_i1, dest_stride); |
| 477 |
src_buf_i1 = drawbuf_next_row(src_buf_i1, src_stride); |
| 478 |
mask_buf += mask_stride; |
| 479 |
} |
| 480 |
} |
| 481 |
} |
| 482 |
} |
| 483 |
else { |
| 484 |
lv_color32_t src_argb; |
| 485 |
for(y = 0; y < h; y++) { |
| 486 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 487 |
src_argb.red = get_bit(src_buf_i1, src_x) * 255; |
| 488 |
src_argb.green = src_argb.red; |
| 489 |
src_argb.blue = src_argb.red; |
| 490 |
if(mask_buf == NULL) src_argb.alpha = opa; |
| 491 |
else src_argb.alpha = LV_OPA_MIX2(mask_buf[dest_x], opa); |
| 492 |
blend_non_normal_pixel(dest_buf_i1, dest_x + bit_ofs, src_argb, dsc->blend_mode); |
| 493 |
} |
| 494 |
if(mask_buf) mask_buf += mask_stride; |
| 495 |
dest_buf_i1 = drawbuf_next_row(dest_buf_i1, dest_stride); |
| 496 |
src_buf_i1 = drawbuf_next_row(src_buf_i1, src_stride); |
| 497 |
} |
| 498 |
} |
| 499 |
} |
| 500 |
|
| 501 |
#if LV_DRAW_SW_SUPPORT_L8 |
| 502 |
static void LV_ATTRIBUTE_FAST_MEM l8_image_blend(lv_draw_sw_blend_image_dsc_t * dsc) |
| 503 |
{ |
| 504 |
int32_t w = dsc->dest_w; |
| 505 |
int32_t h = dsc->dest_h; |
| 506 |
lv_opa_t opa = dsc->opa; |
| 507 |
uint8_t * dest_buf_i1 = dsc->dest_buf; |
| 508 |
int32_t dest_stride = dsc->dest_stride; |
| 509 |
const uint8_t * src_buf_l8 = dsc->src_buf; |
| 510 |
int32_t src_stride = dsc->src_stride; |
| 511 |
const lv_opa_t * mask_buf = dsc->mask_buf; |
| 512 |
int32_t mask_stride = dsc->mask_stride; |
| 513 |
|
| 514 |
int32_t src_x, dest_x; |
| 515 |
int32_t y; |
| 516 |
|
| 517 |
int32_t bit_ofs = dsc->relative_area.x1 % 8; |
| 518 |
|
| 519 |
if(dsc->blend_mode == LV_BLEND_MODE_NORMAL) { |
| 520 |
if(mask_buf == NULL && opa >= LV_OPA_MAX) { |
| 521 |
if(LV_RESULT_INVALID == LV_DRAW_SW_L8_BLEND_NORMAL_TO_I1(dsc)) { |
| 522 |
for(y = 0; y < h; y++) { |
| 523 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 524 |
if(src_buf_l8[src_x] > I1_LUM_THRESHOLD) { |
| 525 |
set_bit(dest_buf_i1, dest_x + bit_ofs); |
| 526 |
} |
| 527 |
else { |
| 528 |
clear_bit(dest_buf_i1, dest_x + bit_ofs); |
| 529 |
} |
| 530 |
} |
| 531 |
dest_buf_i1 = drawbuf_next_row(dest_buf_i1, dest_stride); |
| 532 |
src_buf_l8 = drawbuf_next_row(src_buf_l8, src_stride); |
| 533 |
} |
| 534 |
} |
| 535 |
} |
| 536 |
else if(mask_buf == NULL && opa < LV_OPA_MAX) { |
| 537 |
if(LV_RESULT_INVALID == LV_DRAW_SW_L8_BLEND_NORMAL_TO_I1_WITH_OPA(dsc)) { |
| 538 |
for(y = 0; y < h; y++) { |
| 539 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 540 |
uint8_t dest_val = get_bit(dest_buf_i1, dest_x + bit_ofs) * 255; |
| 541 |
lv_color_8_8_mix(src_buf_l8[src_x], &dest_val, opa); |
| 542 |
if(dest_val > I1_LUM_THRESHOLD) { |
| 543 |
set_bit(dest_buf_i1, dest_x + bit_ofs); |
| 544 |
} |
| 545 |
else { |
| 546 |
clear_bit(dest_buf_i1, dest_x + bit_ofs); |
| 547 |
} |
| 548 |
} |
| 549 |
dest_buf_i1 = drawbuf_next_row(dest_buf_i1, dest_stride); |
| 550 |
src_buf_l8 = drawbuf_next_row(src_buf_l8, src_stride); |
| 551 |
} |
| 552 |
} |
| 553 |
} |
| 554 |
else if(mask_buf && opa >= LV_OPA_MAX) { |
| 555 |
if(LV_RESULT_INVALID == LV_DRAW_SW_L8_BLEND_NORMAL_TO_I1_WITH_MASK(dsc)) { |
| 556 |
for(y = 0; y < h; y++) { |
| 557 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 558 |
uint8_t src_luminance = src_buf_l8[src_x]; |
| 559 |
uint8_t dest_val = get_bit(dest_buf_i1, dest_x + bit_ofs) * 255; |
| 560 |
lv_color_8_8_mix(src_luminance, &dest_val, mask_buf[src_x]); |
| 561 |
if(dest_val > I1_LUM_THRESHOLD) { |
| 562 |
set_bit(dest_buf_i1, dest_x + bit_ofs); |
| 563 |
} |
| 564 |
else { |
| 565 |
clear_bit(dest_buf_i1, dest_x + bit_ofs); |
| 566 |
} |
| 567 |
} |
| 568 |
dest_buf_i1 = drawbuf_next_row(dest_buf_i1, dest_stride); |
| 569 |
src_buf_l8 = drawbuf_next_row(src_buf_l8, src_stride); |
| 570 |
mask_buf += mask_stride; |
| 571 |
} |
| 572 |
} |
| 573 |
} |
| 574 |
else if(mask_buf && opa < LV_OPA_MAX) { |
| 575 |
if(LV_RESULT_INVALID == LV_DRAW_SW_L8_BLEND_NORMAL_TO_I1_MIX_MASK_OPA(dsc)) { |
| 576 |
for(y = 0; y < h; y++) { |
| 577 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 578 |
uint8_t src_luminance = src_buf_l8[src_x]; |
| 579 |
uint8_t dest_val = get_bit(dest_buf_i1, dest_x + bit_ofs) * 255; |
| 580 |
lv_color_8_8_mix(src_luminance, &dest_val, LV_OPA_MIX2(mask_buf[src_x], opa)); |
| 581 |
if(dest_val > I1_LUM_THRESHOLD) { |
| 582 |
set_bit(dest_buf_i1, dest_x + bit_ofs); |
| 583 |
} |
| 584 |
else { |
| 585 |
clear_bit(dest_buf_i1, dest_x + bit_ofs); |
| 586 |
} |
| 587 |
} |
| 588 |
dest_buf_i1 = drawbuf_next_row(dest_buf_i1, dest_stride); |
| 589 |
src_buf_l8 = drawbuf_next_row(src_buf_l8, src_stride); |
| 590 |
mask_buf += mask_stride; |
| 591 |
} |
| 592 |
} |
| 593 |
} |
| 594 |
} |
| 595 |
else { |
| 596 |
lv_color32_t src_argb; |
| 597 |
for(y = 0; y < h; y++) { |
| 598 |
for(src_x = 0; src_x < w; src_x++) { |
| 599 |
src_argb.red = src_buf_l8[src_x]; |
| 600 |
src_argb.green = src_buf_l8[src_x]; |
| 601 |
src_argb.blue = src_buf_l8[src_x]; |
| 602 |
if(mask_buf == NULL) src_argb.alpha = opa; |
| 603 |
else src_argb.alpha = LV_OPA_MIX2(mask_buf[src_x], opa); |
| 604 |
blend_non_normal_pixel(dest_buf_i1, src_x + bit_ofs, src_argb, dsc->blend_mode); |
| 605 |
} |
| 606 |
if(mask_buf) mask_buf += mask_stride; |
| 607 |
dest_buf_i1 = drawbuf_next_row(dest_buf_i1, dest_stride); |
| 608 |
src_buf_l8 = drawbuf_next_row(src_buf_l8, src_stride); |
| 609 |
} |
| 610 |
} |
| 611 |
} |
| 612 |
#endif |
| 613 |
|
| 614 |
#if LV_DRAW_SW_SUPPORT_AL88 |
| 615 |
static void LV_ATTRIBUTE_FAST_MEM al88_image_blend(lv_draw_sw_blend_image_dsc_t * dsc) |
| 616 |
{ |
| 617 |
int32_t w = dsc->dest_w; |
| 618 |
int32_t h = dsc->dest_h; |
| 619 |
lv_opa_t opa = dsc->opa; |
| 620 |
uint8_t * dest_buf_i1 = dsc->dest_buf; |
| 621 |
int32_t dest_stride = dsc->dest_stride; |
| 622 |
const lv_color16a_t * src_buf_al88 = dsc->src_buf; |
| 623 |
int32_t src_stride = dsc->src_stride; |
| 624 |
const lv_opa_t * mask_buf = dsc->mask_buf; |
| 625 |
int32_t mask_stride = dsc->mask_stride; |
| 626 |
|
| 627 |
int32_t dest_x; |
| 628 |
int32_t src_x; |
| 629 |
int32_t y; |
| 630 |
|
| 631 |
int32_t bit_ofs = dsc->relative_area.x1 % 8; |
| 632 |
|
| 633 |
if(dsc->blend_mode == LV_BLEND_MODE_NORMAL) { |
| 634 |
if(mask_buf == NULL && opa >= LV_OPA_MAX) { |
| 635 |
if(LV_RESULT_INVALID == LV_DRAW_SW_AL88_BLEND_NORMAL_TO_I1(dsc)) { |
| 636 |
for(y = 0; y < h; y++) { |
| 637 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 638 |
uint8_t dest_val = get_bit(dest_buf_i1, dest_x + bit_ofs) * 255; |
| 639 |
lv_color_8_8_mix(src_buf_al88[src_x].lumi, &dest_val, src_buf_al88[src_x].alpha); |
| 640 |
if(dest_val > I1_LUM_THRESHOLD) { |
| 641 |
set_bit(dest_buf_i1, dest_x + bit_ofs); |
| 642 |
} |
| 643 |
else { |
| 644 |
clear_bit(dest_buf_i1, dest_x + bit_ofs); |
| 645 |
} |
| 646 |
} |
| 647 |
dest_buf_i1 = drawbuf_next_row(dest_buf_i1, dest_stride); |
| 648 |
src_buf_al88 = drawbuf_next_row(src_buf_al88, src_stride); |
| 649 |
} |
| 650 |
} |
| 651 |
} |
| 652 |
else if(mask_buf == NULL && opa < LV_OPA_MAX) { |
| 653 |
if(LV_RESULT_INVALID == LV_DRAW_SW_AL88_BLEND_NORMAL_TO_I1_WITH_OPA(dsc)) { |
| 654 |
for(y = 0; y < h; y++) { |
| 655 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 656 |
uint8_t dest_val = get_bit(dest_buf_i1, dest_x + bit_ofs) * 255; |
| 657 |
lv_color_8_8_mix(src_buf_al88[src_x].lumi, &dest_val, LV_OPA_MIX2(src_buf_al88[src_x].alpha, opa)); |
| 658 |
if(dest_val > I1_LUM_THRESHOLD) { |
| 659 |
set_bit(dest_buf_i1, dest_x + bit_ofs); |
| 660 |
} |
| 661 |
else { |
| 662 |
clear_bit(dest_buf_i1, dest_x + bit_ofs); |
| 663 |
} |
| 664 |
} |
| 665 |
dest_buf_i1 = drawbuf_next_row(dest_buf_i1, dest_stride); |
| 666 |
src_buf_al88 = drawbuf_next_row(src_buf_al88, src_stride); |
| 667 |
} |
| 668 |
} |
| 669 |
} |
| 670 |
else if(mask_buf && opa >= LV_OPA_MAX) { |
| 671 |
if(LV_RESULT_INVALID == LV_DRAW_SW_AL88_BLEND_NORMAL_TO_I1_WITH_MASK(dsc)) { |
| 672 |
for(y = 0; y < h; y++) { |
| 673 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 674 |
uint8_t dest_val = get_bit(dest_buf_i1, dest_x + bit_ofs) * 255; |
| 675 |
lv_color_8_8_mix(src_buf_al88[src_x].lumi, &dest_val, LV_OPA_MIX2(src_buf_al88[src_x].alpha, mask_buf[src_x])); |
| 676 |
if(dest_val > I1_LUM_THRESHOLD) { |
| 677 |
set_bit(dest_buf_i1, dest_x + bit_ofs); |
| 678 |
} |
| 679 |
else { |
| 680 |
clear_bit(dest_buf_i1, dest_x + bit_ofs); |
| 681 |
} |
| 682 |
} |
| 683 |
dest_buf_i1 = drawbuf_next_row(dest_buf_i1, dest_stride); |
| 684 |
src_buf_al88 = drawbuf_next_row(src_buf_al88, src_stride); |
| 685 |
mask_buf += mask_stride; |
| 686 |
} |
| 687 |
} |
| 688 |
} |
| 689 |
else if(mask_buf && opa < LV_OPA_MAX) { |
| 690 |
if(LV_RESULT_INVALID == LV_DRAW_SW_AL88_BLEND_NORMAL_TO_I1_MIX_MASK_OPA(dsc)) { |
| 691 |
for(y = 0; y < h; y++) { |
| 692 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 693 |
uint8_t dest_val = get_bit(dest_buf_i1, dest_x + bit_ofs) * 255; |
| 694 |
lv_color_8_8_mix(src_buf_al88[src_x].lumi, &dest_val, LV_OPA_MIX3(src_buf_al88[src_x].alpha, mask_buf[src_x], opa)); |
| 695 |
if(dest_val > I1_LUM_THRESHOLD) { |
| 696 |
set_bit(dest_buf_i1, dest_x + bit_ofs); |
| 697 |
} |
| 698 |
else { |
| 699 |
clear_bit(dest_buf_i1, dest_x + bit_ofs); |
| 700 |
} |
| 701 |
} |
| 702 |
dest_buf_i1 = drawbuf_next_row(dest_buf_i1, dest_stride); |
| 703 |
src_buf_al88 = drawbuf_next_row(src_buf_al88, src_stride); |
| 704 |
mask_buf += mask_stride; |
| 705 |
} |
| 706 |
} |
| 707 |
} |
| 708 |
} |
| 709 |
else { |
| 710 |
lv_color32_t src_argb; |
| 711 |
for(y = 0; y < h; y++) { |
| 712 |
for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) { |
| 713 |
src_argb.red = src_buf_al88[src_x].lumi; |
| 714 |
src_argb.green = src_buf_al88[src_x].lumi; |
| 715 |
src_argb.blue = src_buf_al88[src_x].lumi; |
| 716 |
if(mask_buf == NULL) src_argb.alpha = LV_OPA_MIX2(src_buf_al88[src_x].alpha, opa); |
| 717 |
else src_argb.alpha = LV_OPA_MIX3(src_buf_al88[src_x].alpha, mask_buf[src_x], opa); |
| 718 |
blend_non_normal_pixel(dest_buf_i1, dest_x + bit_ofs, src_argb, dsc->blend_mode); |
| 719 |
} |
| 720 |
if(mask_buf) mask_buf += mask_stride; |
| 721 |
dest_buf_i1 = drawbuf_next_row(dest_buf_i1, dest_stride); |
| 722 |
src_buf_al88 = drawbuf_next_row(src_buf_al88, src_stride); |
| 723 |
} |
| 724 |
} |
| 725 |
} |
| 726 |
#endif |
| 727 |
|
| 728 |
#if LV_DRAW_SW_SUPPORT_ARGB8888 |
| 729 |
static void LV_ATTRIBUTE_FAST_MEM argb8888_image_blend(lv_draw_sw_blend_image_dsc_t * dsc) |
| 730 |
{ |
| 731 |
int32_t w = dsc->dest_w; |
| 732 |
int32_t h = dsc->dest_h; |
| 733 |
lv_opa_t opa = dsc->opa; |
| 734 |
uint8_t * dest_buf_i1 = dsc->dest_buf; |
| 735 |
int32_t dest_stride = dsc->dest_stride; |
| 736 |
const lv_color32_t * src_buf_c32 = dsc->src_buf; |
| 737 |
int32_t src_stride = dsc->src_stride; |
| 738 |
const lv_opa_t * mask_buf = dsc->mask_buf; |
| 739 |
int32_t mask_stride = dsc->mask_stride; |
| 740 |
|
| 741 |
int32_t x; |
| 742 |
int32_t y; |
| 743 |
|
| 744 |
int32_t bit_ofs = dsc->relative_area.x1 % 8; |
| 745 |
|
| 746 |
if(dsc->blend_mode == LV_BLEND_MODE_NORMAL) { |
| 747 |
if(mask_buf == NULL && opa >= LV_OPA_MAX) { |
| 748 |
if(LV_RESULT_INVALID == LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_I1(dsc)) { |
| 749 |
for(y = 0; y < h; y++) { |
| 750 |
for(x = 0; x < w; x++) { |
| 751 |
uint8_t src = lv_color32_luminance(src_buf_c32[x]); |
| 752 |
uint8_t dest = get_bit(dest_buf_i1, x + bit_ofs) * 255; |
| 753 |
lv_color_8_8_mix(src, &dest, src_buf_c32[x].alpha); |
| 754 |
if(dest > I1_LUM_THRESHOLD) { |
| 755 |
set_bit(dest_buf_i1, x + bit_ofs); |
| 756 |
} |
| 757 |
else { |
| 758 |
clear_bit(dest_buf_i1, x + bit_ofs); |
| 759 |
} |
| 760 |
} |
| 761 |
dest_buf_i1 = drawbuf_next_row(dest_buf_i1, dest_stride); |
| 762 |
src_buf_c32 = drawbuf_next_row(src_buf_c32, src_stride); |
| 763 |
} |
| 764 |
} |
| 765 |
} |
| 766 |
else if(mask_buf == NULL && opa < LV_OPA_MAX) { |
| 767 |
if(LV_RESULT_INVALID == LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_I1_WITH_OPA(dsc)) { |
| 768 |
for(y = 0; y < h; y++) { |
| 769 |
for(x = 0; x < w; x++) { |
| 770 |
uint8_t src = lv_color32_luminance(src_buf_c32[x]); |
| 771 |
uint8_t dest = get_bit(dest_buf_i1, x + bit_ofs) * 255; |
| 772 |
lv_color_8_8_mix(src, &dest, LV_OPA_MIX2(opa, src_buf_c32[x].alpha)); |
| 773 |
if(dest > I1_LUM_THRESHOLD) { |
| 774 |
set_bit(dest_buf_i1, x + bit_ofs); |
| 775 |
} |
| 776 |
else { |
| 777 |
clear_bit(dest_buf_i1, x + bit_ofs); |
| 778 |
} |
| 779 |
} |
| 780 |
dest_buf_i1 = drawbuf_next_row(dest_buf_i1, dest_stride); |
| 781 |
src_buf_c32 = drawbuf_next_row(src_buf_c32, src_stride); |
| 782 |
} |
| 783 |
} |
| 784 |
} |
| 785 |
else if(mask_buf && opa >= LV_OPA_MAX) { |
| 786 |
if(LV_RESULT_INVALID == LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_I1_WITH_MASK(dsc)) { |
| 787 |
for(y = 0; y < h; y++) { |
| 788 |
for(x = 0; x < w; x++) { |
| 789 |
uint8_t src = lv_color32_luminance(src_buf_c32[x]); |
| 790 |
uint8_t dest = get_bit(dest_buf_i1, x + bit_ofs) * 255; |
| 791 |
lv_color_8_8_mix(src, &dest, LV_OPA_MIX2(mask_buf[x], src_buf_c32[x].alpha)); |
| 792 |
if(dest > I1_LUM_THRESHOLD) { |
| 793 |
set_bit(dest_buf_i1, x + bit_ofs); |
| 794 |
} |
| 795 |
else { |
| 796 |
clear_bit(dest_buf_i1, x + bit_ofs); |
| 797 |
} |
| 798 |
} |
| 799 |
dest_buf_i1 = drawbuf_next_row(dest_buf_i1, dest_stride); |
| 800 |
src_buf_c32 = drawbuf_next_row(src_buf_c32, src_stride); |
| 801 |
mask_buf += mask_stride; |
| 802 |
} |
| 803 |
} |
| 804 |
} |
| 805 |
else if(mask_buf && opa < LV_OPA_MAX) { |
| 806 |
if(LV_RESULT_INVALID == LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_I1_MIX_MASK_OPA(dsc)) { |
| 807 |
for(y = 0; y < h; y++) { |
| 808 |
for(x = 0; x < w; x++) { |
| 809 |
uint8_t src = lv_color32_luminance(src_buf_c32[x]); |
| 810 |
uint8_t dest = get_bit(dest_buf_i1, x + bit_ofs) * 255; |
| 811 |
lv_color_8_8_mix(src, &dest, LV_OPA_MIX3(opa, mask_buf[x], src_buf_c32[x].alpha)); |
| 812 |
if(dest > I1_LUM_THRESHOLD) { |
| 813 |
set_bit(dest_buf_i1, x + bit_ofs); |
| 814 |
} |
| 815 |
else { |
| 816 |
clear_bit(dest_buf_i1, x + bit_ofs); |
| 817 |
} |
| 818 |
} |
| 819 |
dest_buf_i1 = drawbuf_next_row(dest_buf_i1, dest_stride); |
| 820 |
src_buf_c32 = drawbuf_next_row(src_buf_c32, src_stride); |
| 821 |
mask_buf += mask_stride; |
| 822 |
} |
| 823 |
} |
| 824 |
} |
| 825 |
} |
| 826 |
else { |
| 827 |
for(y = 0; y < h; y++) { |
| 828 |
for(x = 0; x < w; x++) { |
| 829 |
lv_color32_t color_argb = src_buf_c32[x]; |
| 830 |
if(mask_buf == NULL) color_argb.alpha = LV_OPA_MIX2(color_argb.alpha, opa); |
| 831 |
else color_argb.alpha = LV_OPA_MIX3(color_argb.alpha, mask_buf[x], opa); |
| 832 |
blend_non_normal_pixel(dest_buf_i1, x + bit_ofs, color_argb, dsc->blend_mode); |
| 833 |
} |
| 834 |
if(mask_buf) mask_buf += mask_stride; |
| 835 |
dest_buf_i1 = drawbuf_next_row(dest_buf_i1, dest_stride); |
| 836 |
src_buf_c32 = drawbuf_next_row(src_buf_c32, src_stride); |
| 837 |
} |
| 838 |
} |
| 839 |
} |
| 840 |
#endif |
| 841 |
|
| 842 |
#if LV_DRAW_SW_SUPPORT_RGB888 || LV_DRAW_SW_SUPPORT_XRGB8888 |
| 843 |
static void LV_ATTRIBUTE_FAST_MEM rgb888_image_blend(lv_draw_sw_blend_image_dsc_t * dsc, |
| 844 |
const uint8_t src_px_size) |
| 845 |
{ |
| 846 |
int32_t w = dsc->dest_w; |
| 847 |
int32_t h = dsc->dest_h; |
| 848 |
lv_opa_t opa = dsc->opa; |
| 849 |
uint8_t * dest_buf_i1 = dsc->dest_buf; |
| 850 |
int32_t dest_stride = dsc->dest_stride; |
| 851 |
const uint8_t * src_buf_rgb888 = dsc->src_buf; |
| 852 |
int32_t src_stride = dsc->src_stride; |
| 853 |
const lv_opa_t * mask_buf = dsc->mask_buf; |
| 854 |
int32_t mask_stride = dsc->mask_stride; |
| 855 |
|
| 856 |
int32_t dest_x; |
| 857 |
int32_t src_x; |
| 858 |
int32_t y; |
| 859 |
|
| 860 |
int32_t bit_ofs = dsc->relative_area.x1 % 8; |
| 861 |
|
| 862 |
|
| 863 |
if(dsc->blend_mode == LV_BLEND_MODE_NORMAL) { |
| 864 |
|
| 865 |
if(mask_buf == NULL && opa >= LV_OPA_MAX) { |
| 866 |
if(LV_RESULT_INVALID == LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_I1(dsc)) { |
| 867 |
for(y = 0; y < h; y++) { |
| 868 |
for(dest_x = 0, src_x = 0; dest_x < w; dest_x++, src_x += src_px_size) { |
| 869 |
uint8_t src = lv_color24_luminance(&src_buf_rgb888[src_x]); |
| 870 |
if(src > I1_LUM_THRESHOLD) { |
| 871 |
set_bit(dest_buf_i1, dest_x + bit_ofs); |
| 872 |
} |
| 873 |
else { |
| 874 |
clear_bit(dest_buf_i1, dest_x + bit_ofs); |
| 875 |
} |
| 876 |
} |
| 877 |
dest_buf_i1 = drawbuf_next_row(dest_buf_i1, dest_stride); |
| 878 |
src_buf_rgb888 = drawbuf_next_row(src_buf_rgb888, src_stride); |
| 879 |
} |
| 880 |
} |
| 881 |
} |
| 882 |
else if(mask_buf == NULL && opa < LV_OPA_MAX) { |
| 883 |
if(LV_RESULT_INVALID == LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_I1_WITH_OPA(dsc)) { |
| 884 |
for(y = 0; y < h; y++) { |
| 885 |
for(dest_x = 0, src_x = 0; dest_x < w; dest_x++, src_x += src_px_size) { |
| 886 |
uint8_t src = lv_color24_luminance(&src_buf_rgb888[src_x]); |
| 887 |
uint8_t dest = get_bit(dest_buf_i1, dest_x + bit_ofs) * 255; |
| 888 |
lv_color_8_8_mix(src, &dest, opa); |
| 889 |
if(dest > I1_LUM_THRESHOLD) { |
| 890 |
set_bit(dest_buf_i1, dest_x + bit_ofs); |
| 891 |
} |
| 892 |
else { |
| 893 |
clear_bit(dest_buf_i1, dest_x + bit_ofs); |
| 894 |
} |
| 895 |
} |
| 896 |
dest_buf_i1 = drawbuf_next_row(dest_buf_i1, dest_stride); |
| 897 |
src_buf_rgb888 = drawbuf_next_row(src_buf_rgb888, src_stride); |
| 898 |
} |
| 899 |
} |
| 900 |
} |
| 901 |
else if(mask_buf && opa >= LV_OPA_MAX) { |
| 902 |
if(LV_RESULT_INVALID == LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_I1_WITH_MASK(dsc)) { |
| 903 |
uint32_t mask_x; |
| 904 |
for(y = 0; y < h; y++) { |
| 905 |
for(mask_x = 0, dest_x = 0, src_x = 0; dest_x < w; mask_x++, dest_x++, src_x += src_px_size) { |
| 906 |
uint8_t src = lv_color24_luminance(&src_buf_rgb888[src_x]); |
| 907 |
uint8_t dest = get_bit(dest_buf_i1, dest_x + bit_ofs) * 255; |
| 908 |
lv_color_8_8_mix(src, &dest, mask_buf[mask_x]); |
| 909 |
if(dest > I1_LUM_THRESHOLD) { |
| 910 |
set_bit(dest_buf_i1, dest_x + bit_ofs); |
| 911 |
} |
| 912 |
else { |
| 913 |
clear_bit(dest_buf_i1, dest_x + bit_ofs); |
| 914 |
} |
| 915 |
} |
| 916 |
dest_buf_i1 = drawbuf_next_row(dest_buf_i1, dest_stride); |
| 917 |
src_buf_rgb888 = drawbuf_next_row(src_buf_rgb888, src_stride); |
| 918 |
mask_buf += mask_stride; |
| 919 |
} |
| 920 |
} |
| 921 |
} |
| 922 |
else if(mask_buf && opa < LV_OPA_MAX) { |
| 923 |
if(LV_RESULT_INVALID == LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_I1_MIX_MASK_OPA(dsc)) { |
| 924 |
uint32_t mask_x; |
| 925 |
for(y = 0; y < h; y++) { |
| 926 |
for(mask_x = 0, dest_x = 0, src_x = 0; dest_x < w; mask_x++, dest_x++, src_x += src_px_size) { |
| 927 |
uint8_t src = lv_color24_luminance(&src_buf_rgb888[src_x]); |
| 928 |
uint8_t dest = get_bit(dest_buf_i1, dest_x + bit_ofs) * 255; |
| 929 |
lv_color_8_8_mix(src, &dest, LV_OPA_MIX2(mask_buf[mask_x], opa)); |
| 930 |
if(dest > I1_LUM_THRESHOLD) { |
| 931 |
set_bit(dest_buf_i1, dest_x + bit_ofs); |
| 932 |
} |
| 933 |
else { |
| 934 |
clear_bit(dest_buf_i1, dest_x + bit_ofs); |
| 935 |
} |
| 936 |
} |
| 937 |
dest_buf_i1 = drawbuf_next_row(dest_buf_i1, dest_stride); |
| 938 |
src_buf_rgb888 = drawbuf_next_row(src_buf_rgb888, src_stride); |
| 939 |
mask_buf += mask_stride; |
| 940 |
} |
| 941 |
} |
| 942 |
} |
| 943 |
else { |
| 944 |
lv_color32_t src_argb; |
| 945 |
for(y = 0; y < h; y++) { |
| 946 |
for(dest_x = 0, src_x = 0; dest_x < w; dest_x++, src_x += src_px_size) { |
| 947 |
src_argb.red = src_buf_rgb888[src_x + 2]; |
| 948 |
src_argb.green = src_buf_rgb888[src_x + 1]; |
| 949 |
src_argb.blue = src_buf_rgb888[src_x + 0]; |
| 950 |
if(mask_buf == NULL) src_argb.alpha = opa; |
| 951 |
else src_argb.alpha = LV_OPA_MIX2(mask_buf[dest_x], opa); |
| 952 |
|
| 953 |
blend_non_normal_pixel(dest_buf_i1, dest_x + bit_ofs, src_argb, dsc->blend_mode); |
| 954 |
} |
| 955 |
if(mask_buf) mask_buf += mask_stride; |
| 956 |
dest_buf_i1 = drawbuf_next_row(dest_buf_i1, dest_stride); |
| 957 |
src_buf_rgb888 = drawbuf_next_row(src_buf_rgb888, src_stride); |
| 958 |
} |
| 959 |
} |
| 960 |
} |
| 961 |
} |
| 962 |
#endif |
| 963 |
|
| 964 |
#if LV_DRAW_SW_SUPPORT_RGB565 |
| 965 |
static void LV_ATTRIBUTE_FAST_MEM rgb565_image_blend(lv_draw_sw_blend_image_dsc_t * dsc) |
| 966 |
{ |
| 967 |
int32_t w = dsc->dest_w; |
| 968 |
int32_t h = dsc->dest_h; |
| 969 |
lv_opa_t opa = dsc->opa; |
| 970 |
uint8_t * dest_buf_u8 = dsc->dest_buf; |
| 971 |
int32_t dest_stride = dsc->dest_stride; |
| 972 |
const lv_color16_t * src_buf_c16 = (const lv_color16_t *)dsc->src_buf; |
| 973 |
int32_t src_stride = dsc->src_stride; |
| 974 |
const lv_opa_t * mask_buf = dsc->mask_buf; |
| 975 |
int32_t mask_stride = dsc->mask_stride; |
| 976 |
int32_t bit_ofs = dsc->relative_area.x1 % 8; |
| 977 |
|
| 978 |
int32_t src_x; |
| 979 |
int32_t dest_x; |
| 980 |
int32_t y; |
| 981 |
|
| 982 |
if(dsc->blend_mode == LV_BLEND_MODE_NORMAL) { |
| 983 |
if(mask_buf == NULL && opa >= LV_OPA_MAX) { |
| 984 |
if(LV_RESULT_INVALID == LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_I1(dsc)) { |
| 985 |
for(y = 0; y < h; y++) { |
| 986 |
|
| 987 |
for(src_x = 0, dest_x = 0; src_x < w; dest_x++, src_x++) { |
| 988 |
uint8_t src = lv_color16_luminance(src_buf_c16[src_x]); |
| 989 |
if(src > I1_LUM_THRESHOLD) { |
| 990 |
set_bit(dest_buf_u8, dest_x + bit_ofs); |
| 991 |
} |
| 992 |
else { |
| 993 |
clear_bit(dest_buf_u8, dest_x + bit_ofs); |
| 994 |
} |
| 995 |
} |
| 996 |
dest_buf_u8 = drawbuf_next_row(dest_buf_u8, dest_stride); |
| 997 |
src_buf_c16 = drawbuf_next_row(src_buf_c16, src_stride); |
| 998 |
} |
| 999 |
} |
| 1000 |
} |
| 1001 |
else if(mask_buf == NULL && opa < LV_OPA_MAX) { |
| 1002 |
if(LV_RESULT_INVALID == LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_I1_WITH_OPA(dsc)) { |
| 1003 |
for(y = 0; y < h; y++) { |
| 1004 |
for(src_x = 0, dest_x = 0; src_x < w; dest_x++, src_x++) { |
| 1005 |
uint8_t src = lv_color16_luminance(src_buf_c16[src_x]); |
| 1006 |
uint8_t dest = get_bit(dest_buf_u8, dest_x + bit_ofs) * 255; |
| 1007 |
lv_color_8_8_mix(src, &dest, opa); |
| 1008 |
if(dest > I1_LUM_THRESHOLD) { |
| 1009 |
set_bit(dest_buf_u8, dest_x + bit_ofs); |
| 1010 |
} |
| 1011 |
else { |
| 1012 |
clear_bit(dest_buf_u8, dest_x + bit_ofs); |
| 1013 |
} |
| 1014 |
} |
| 1015 |
dest_buf_u8 = drawbuf_next_row(dest_buf_u8, dest_stride); |
| 1016 |
src_buf_c16 = drawbuf_next_row(src_buf_c16, src_stride); |
| 1017 |
} |
| 1018 |
} |
| 1019 |
} |
| 1020 |
else if(mask_buf && opa >= LV_OPA_MAX) { |
| 1021 |
if(LV_RESULT_INVALID == LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_I1_WITH_MASK(dsc)) { |
| 1022 |
uint32_t mask_x; |
| 1023 |
for(y = 0; y < h; y++) { |
| 1024 |
for(mask_x = 0, dest_x = 0, src_x = 0; dest_x < w; mask_x++, dest_x++, src_x++) { |
| 1025 |
uint8_t src = lv_color16_luminance(src_buf_c16[src_x]); |
| 1026 |
uint8_t dest = get_bit(dest_buf_u8, dest_x + bit_ofs) * 255; |
| 1027 |
lv_color_8_8_mix(src, &dest, mask_buf[mask_x]); |
| 1028 |
if(dest > I1_LUM_THRESHOLD) { |
| 1029 |
set_bit(dest_buf_u8, dest_x + bit_ofs); |
| 1030 |
} |
| 1031 |
else { |
| 1032 |
clear_bit(dest_buf_u8, dest_x + bit_ofs); |
| 1033 |
} |
| 1034 |
} |
| 1035 |
dest_buf_u8 = drawbuf_next_row(dest_buf_u8, dest_stride); |
| 1036 |
src_buf_c16 = drawbuf_next_row(src_buf_c16, src_stride); |
| 1037 |
mask_buf += mask_stride; |
| 1038 |
} |
| 1039 |
} |
| 1040 |
} |
| 1041 |
else if(mask_buf && opa < LV_OPA_MAX) { |
| 1042 |
if(LV_RESULT_INVALID == LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_I1_MIX_MASK_OPA(dsc)) { |
| 1043 |
uint32_t mask_x; |
| 1044 |
for(y = 0; y < h; y++) { |
| 1045 |
for(mask_x = 0, dest_x = 0, src_x = 0; dest_x < w; mask_x++, dest_x++, src_x++) { |
| 1046 |
uint8_t src = lv_color16_luminance(src_buf_c16[src_x]); |
| 1047 |
uint8_t dest = get_bit(dest_buf_u8, dest_x + bit_ofs) * 255; |
| 1048 |
lv_color_8_8_mix(src, &dest, LV_OPA_MIX2(mask_buf[mask_x], opa)); |
| 1049 |
if(dest > I1_LUM_THRESHOLD) { |
| 1050 |
set_bit(dest_buf_u8, dest_x + bit_ofs); |
| 1051 |
} |
| 1052 |
else { |
| 1053 |
clear_bit(dest_buf_u8, dest_x + bit_ofs); |
| 1054 |
} |
| 1055 |
} |
| 1056 |
dest_buf_u8 = drawbuf_next_row(dest_buf_u8, dest_stride); |
| 1057 |
src_buf_c16 = drawbuf_next_row(src_buf_c16, src_stride); |
| 1058 |
mask_buf += mask_stride; |
| 1059 |
} |
| 1060 |
} |
| 1061 |
} |
| 1062 |
} |
| 1063 |
else { |
| 1064 |
lv_color32_t src_argb; |
| 1065 |
for(y = 0; y < h; y++) { |
| 1066 |
for(src_x = 0, dest_x = 0; src_x < w; src_x++, dest_x++) { |
| 1067 |
src_argb.red = (src_buf_c16[src_x].red * 2106) >> 8; |
| 1068 |
src_argb.green = (src_buf_c16[src_x].green * 1037) >> 8; |
| 1069 |
src_argb.blue = (src_buf_c16[src_x].blue * 2106) >> 8; |
| 1070 |
if(mask_buf == NULL) src_argb.alpha = opa; |
| 1071 |
else src_argb.alpha = LV_OPA_MIX2(mask_buf[src_x], opa); |
| 1072 |
|
| 1073 |
blend_non_normal_pixel(dest_buf_u8, dest_x + bit_ofs, src_argb, dsc->blend_mode); |
| 1074 |
} |
| 1075 |
if(mask_buf) mask_buf += mask_stride; |
| 1076 |
dest_buf_u8 = drawbuf_next_row(dest_buf_u8, dest_stride); |
| 1077 |
src_buf_c16 = drawbuf_next_row(src_buf_c16, src_stride); |
| 1078 |
} |
| 1079 |
} |
| 1080 |
} |
| 1081 |
#endif |
| 1082 |
|
| 1083 |
#if LV_DRAW_SW_SUPPORT_RGB565_SWAPPED |
| 1084 |
static void LV_ATTRIBUTE_FAST_MEM rgb565_swapped_image_blend(lv_draw_sw_blend_image_dsc_t * dsc) |
| 1085 |
{ |
| 1086 |
int32_t w = dsc->dest_w; |
| 1087 |
int32_t h = dsc->dest_h; |
| 1088 |
lv_opa_t opa = dsc->opa; |
| 1089 |
uint8_t * dest_buf_u8 = dsc->dest_buf; |
| 1090 |
int32_t dest_stride = dsc->dest_stride; |
| 1091 |
const uint16_t * src_buf_u16 = dsc->src_buf; |
| 1092 |
int32_t src_stride = dsc->src_stride; |
| 1093 |
const lv_opa_t * mask_buf = dsc->mask_buf; |
| 1094 |
int32_t mask_stride = dsc->mask_stride; |
| 1095 |
int32_t bit_ofs = dsc->relative_area.x1 % 8; |
| 1096 |
|
| 1097 |
int32_t src_x; |
| 1098 |
int32_t dest_x; |
| 1099 |
int32_t y; |
| 1100 |
lv_color16_t px; |
| 1101 |
|
| 1102 |
|
| 1103 |
if(dsc->blend_mode == LV_BLEND_MODE_NORMAL) { |
| 1104 |
if(mask_buf == NULL && opa >= LV_OPA_MAX) { |
| 1105 |
if(LV_RESULT_INVALID == LV_DRAW_SW_RGB565_SWAPPED_BLEND_NORMAL_TO_I1(dsc)) { |
| 1106 |
for(y = 0; y < h; y++) { |
| 1107 |
|
| 1108 |
for(src_x = 0, dest_x = 0; src_x < w; dest_x++, src_x++) { |
| 1109 |
px = lv_color16_from_u16(lv_color_swap_16(src_buf_u16[src_x])); |
| 1110 |
uint8_t src = lv_color16_luminance(px); |
| 1111 |
if(src > I1_LUM_THRESHOLD) { |
| 1112 |
set_bit(dest_buf_u8, dest_x + bit_ofs); |
| 1113 |
} |
| 1114 |
else { |
| 1115 |
clear_bit(dest_buf_u8, dest_x + bit_ofs); |
| 1116 |
} |
| 1117 |
} |
| 1118 |
dest_buf_u8 = drawbuf_next_row(dest_buf_u8, dest_stride); |
| 1119 |
src_buf_u16 = drawbuf_next_row(src_buf_u16, src_stride); |
| 1120 |
} |
| 1121 |
} |
| 1122 |
} |
| 1123 |
else if(mask_buf == NULL && opa < LV_OPA_MAX) { |
| 1124 |
if(LV_RESULT_INVALID == LV_DRAW_SW_RGB565_SWAPPED_BLEND_NORMAL_TO_I1_WITH_OPA(dsc)) { |
| 1125 |
for(y = 0; y < h; y++) { |
| 1126 |
for(src_x = 0, dest_x = 0; src_x < w; dest_x++, src_x++) { |
| 1127 |
px = lv_color16_from_u16(lv_color_swap_16(src_buf_u16[src_x])); |
| 1128 |
uint8_t src = lv_color16_luminance(px); |
| 1129 |
uint8_t dest = get_bit(dest_buf_u8, dest_x + bit_ofs) * 255; |
| 1130 |
lv_color_8_8_mix(src, &dest, opa); |
| 1131 |
if(dest > I1_LUM_THRESHOLD) { |
| 1132 |
set_bit(dest_buf_u8, dest_x + bit_ofs); |
| 1133 |
} |
| 1134 |
else { |
| 1135 |
clear_bit(dest_buf_u8, dest_x + bit_ofs); |
| 1136 |
} |
| 1137 |
} |
| 1138 |
dest_buf_u8 = drawbuf_next_row(dest_buf_u8, dest_stride); |
| 1139 |
src_buf_u16 = drawbuf_next_row(src_buf_u16, src_stride); |
| 1140 |
} |
| 1141 |
} |
| 1142 |
} |
| 1143 |
else if(mask_buf && opa >= LV_OPA_MAX) { |
| 1144 |
if(LV_RESULT_INVALID == LV_DRAW_SW_RGB565_SWAPPED_BLEND_NORMAL_TO_I1_WITH_MASK(dsc)) { |
| 1145 |
uint32_t mask_x; |
| 1146 |
for(y = 0; y < h; y++) { |
| 1147 |
for(mask_x = 0, dest_x = 0, src_x = 0; dest_x < w; mask_x++, dest_x++, src_x++) { |
| 1148 |
px = lv_color16_from_u16(lv_color_swap_16(src_buf_u16[src_x])); |
| 1149 |
uint8_t src = lv_color16_luminance(px); |
| 1150 |
uint8_t dest = get_bit(dest_buf_u8, dest_x + bit_ofs) * 255; |
| 1151 |
lv_color_8_8_mix(src, &dest, mask_buf[mask_x]); |
| 1152 |
if(dest > I1_LUM_THRESHOLD) { |
| 1153 |
set_bit(dest_buf_u8, dest_x + bit_ofs); |
| 1154 |
} |
| 1155 |
else { |
| 1156 |
clear_bit(dest_buf_u8, dest_x + bit_ofs); |
| 1157 |
} |
| 1158 |
} |
| 1159 |
dest_buf_u8 = drawbuf_next_row(dest_buf_u8, dest_stride); |
| 1160 |
src_buf_u16 = drawbuf_next_row(src_buf_u16, src_stride); |
| 1161 |
mask_buf += mask_stride; |
| 1162 |
} |
| 1163 |
} |
| 1164 |
} |
| 1165 |
else if(mask_buf && opa < LV_OPA_MAX) { |
| 1166 |
if(LV_RESULT_INVALID == LV_DRAW_SW_RGB565_SWAPPED_BLEND_NORMAL_TO_I1_MIX_MASK_OPA(dsc)) { |
| 1167 |
uint32_t mask_x; |
| 1168 |
for(y = 0; y < h; y++) { |
| 1169 |
for(mask_x = 0, dest_x = 0, src_x = 0; dest_x < w; mask_x++, dest_x++, src_x++) { |
| 1170 |
px = lv_color16_from_u16(lv_color_swap_16(src_buf_u16[src_x])); |
| 1171 |
uint8_t src = lv_color16_luminance(px); |
| 1172 |
uint8_t dest = get_bit(dest_buf_u8, dest_x + bit_ofs) * 255; |
| 1173 |
lv_color_8_8_mix(src, &dest, LV_OPA_MIX2(mask_buf[mask_x], opa)); |
| 1174 |
if(dest > I1_LUM_THRESHOLD) { |
| 1175 |
set_bit(dest_buf_u8, dest_x + bit_ofs); |
| 1176 |
} |
| 1177 |
else { |
| 1178 |
clear_bit(dest_buf_u8, dest_x + bit_ofs); |
| 1179 |
} |
| 1180 |
} |
| 1181 |
dest_buf_u8 = drawbuf_next_row(dest_buf_u8, dest_stride); |
| 1182 |
src_buf_u16 = drawbuf_next_row(src_buf_u16, src_stride); |
| 1183 |
mask_buf += mask_stride; |
| 1184 |
} |
| 1185 |
} |
| 1186 |
} |
| 1187 |
} |
| 1188 |
else { |
| 1189 |
lv_color32_t src_argb; |
| 1190 |
for(y = 0; y < h; y++) { |
| 1191 |
for(src_x = 0, dest_x = 0; src_x < w; src_x++, dest_x++) { |
| 1192 |
px = lv_color16_from_u16(lv_color_swap_16(src_buf_u16[src_x])); |
| 1193 |
src_argb.red = (px.red * 2106) >> 8; |
| 1194 |
src_argb.green = (px.green * 1037) >> 8; |
| 1195 |
src_argb.blue = (px.blue * 2106) >> 8; |
| 1196 |
if(mask_buf == NULL) src_argb.alpha = opa; |
| 1197 |
else src_argb.alpha = LV_OPA_MIX2(mask_buf[src_x], opa); |
| 1198 |
|
| 1199 |
blend_non_normal_pixel(dest_buf_u8, dest_x + bit_ofs, src_argb, dsc->blend_mode); |
| 1200 |
} |
| 1201 |
if(mask_buf) mask_buf += mask_stride; |
| 1202 |
dest_buf_u8 = drawbuf_next_row(dest_buf_u8, dest_stride); |
| 1203 |
src_buf_u16 = drawbuf_next_row(src_buf_u16, src_stride); |
| 1204 |
} |
| 1205 |
} |
| 1206 |
} |
| 1207 |
#endif |
| 1208 |
|
| 1209 |
static inline void LV_ATTRIBUTE_FAST_MEM blend_non_normal_pixel(uint8_t * dest_buf, int32_t dest_x, lv_color32_t src, |
| 1210 |
lv_blend_mode_t mode) |
| 1211 |
{ |
| 1212 |
uint8_t res; |
| 1213 |
int32_t src_lumi = lv_color32_luminance(src); |
| 1214 |
uint8_t dest_lumi = get_bit(dest_buf, dest_x) * 255; |
| 1215 |
switch(mode) { |
| 1216 |
case LV_BLEND_MODE_ADDITIVE: |
| 1217 |
res = LV_MIN(dest_lumi + src_lumi, 255); |
| 1218 |
break; |
| 1219 |
case LV_BLEND_MODE_SUBTRACTIVE: |
| 1220 |
res = LV_MAX(dest_lumi - src_lumi, 0); |
| 1221 |
break; |
| 1222 |
case LV_BLEND_MODE_MULTIPLY: |
| 1223 |
res = (dest_lumi * src_lumi) >> 8; |
| 1224 |
break; |
| 1225 |
case LV_BLEND_MODE_DIFFERENCE: |
| 1226 |
res = LV_ABS(dest_lumi - src_lumi); |
| 1227 |
break; |
| 1228 |
default: |
| 1229 |
LV_LOG_WARN("Not supported blend mode: %d", mode); |
| 1230 |
return; |
| 1231 |
} |
| 1232 |
|
| 1233 |
lv_color_8_8_mix(res, &dest_lumi, src.alpha); |
| 1234 |
if(dest_lumi > I1_LUM_THRESHOLD) { |
| 1235 |
set_bit(dest_buf, dest_x); |
| 1236 |
} |
| 1237 |
else { |
| 1238 |
clear_bit(dest_buf, dest_x); |
| 1239 |
} |
| 1240 |
} |
| 1241 |
|
| 1242 |
static inline void LV_ATTRIBUTE_FAST_MEM lv_color_8_8_mix(const uint8_t src, uint8_t * dest, uint8_t mix) |
| 1243 |
{ |
| 1244 |
|
| 1245 |
if(mix == 0) return; |
| 1246 |
|
| 1247 |
if(mix >= LV_OPA_MAX) { |
| 1248 |
*dest = src; |
| 1249 |
} |
| 1250 |
else { |
| 1251 |
lv_opa_t mix_inv = 255 - mix; |
| 1252 |
*dest = (uint32_t)((uint32_t)src * mix + dest[0] * mix_inv) >> 8; |
| 1253 |
} |
| 1254 |
} |
| 1255 |
|
| 1256 |
static inline void * LV_ATTRIBUTE_FAST_MEM drawbuf_next_row(const void * buf, uint32_t stride) |
| 1257 |
{ |
| 1258 |
return (void *)((uint8_t *)buf + stride); |
| 1259 |
} |
| 1260 |
|
| 1261 |
static inline void LV_ATTRIBUTE_FAST_MEM set_bit(uint8_t * buf, int32_t bit_idx) |
| 1262 |
{ |
| 1263 |
buf[bit_idx / 8] |= (1 << (7 - (bit_idx % 8))); |
| 1264 |
} |
| 1265 |
|
| 1266 |
static inline void LV_ATTRIBUTE_FAST_MEM clear_bit(uint8_t * buf, int32_t bit_idx) |
| 1267 |
{ |
| 1268 |
buf[bit_idx / 8] &= ~(1 << (7 - (bit_idx % 8))); |
| 1269 |
} |
| 1270 |
|
| 1271 |
static inline uint8_t LV_ATTRIBUTE_FAST_MEM get_bit(const uint8_t * buf, int32_t bit_idx) |
| 1272 |
{ |
| 1273 |
return (buf[bit_idx / 8] >> (7 - (bit_idx % 8))) & 1; |
| 1274 |
} |
| 1275 |
|
| 1276 |
#if LV_DRAW_SW_SUPPORT_RGB565_SWAPPED |
| 1277 |
static inline lv_color16_t LV_ATTRIBUTE_FAST_MEM lv_color16_from_u16(uint16_t raw) |
| 1278 |
{ |
| 1279 |
lv_color16_t c; |
| 1280 |
c.red = (raw >> 11) & 0x1F; |
| 1281 |
c.green = (raw >> 5) & 0x3F; |
| 1282 |
c.blue = raw & 0x1F; |
| 1283 |
return c; |
| 1284 |
} |
| 1285 |
#endif |
| 1286 |
|
| 1287 |
#endif |