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