Debian Codegraph @

lvgl/src/draw/sw/blend/lv_draw_sw_blend_to_a8.c

raw symbols SCIP
1 /**
2 * @file lv_draw_sw_blend_to_a8.c
3 *
4 */
5
6 /*********************
7 * INCLUDES
8 *********************/
9 #include "lv_draw_sw_blend_to_a8.h"
10 #if LV_USE_DRAW_SW
11
12 #if LV_DRAW_SW_SUPPORT_A8
13
14 #include "lv_draw_sw_blend_private.h"
15 #include "../../../misc/lv_math.h"
16 #include "../../../display/lv_display.h"
17 #include "../../../core/lv_refr.h"
18 #include "../../../misc/lv_color.h"
19 #include "../../../stdlib/lv_string.h"
20
21 #if LV_USE_DRAW_SW_ASM == LV_DRAW_SW_ASM_NEON
22 #include "neon/lv_blend_neon.h"
23 #elif LV_USE_DRAW_SW_ASM == LV_DRAW_SW_ASM_HELIUM
24 #include "helium/lv_blend_helium.h"
25 #elif LV_USE_DRAW_SW_ASM == LV_DRAW_SW_ASM_CUSTOM
26 #include LV_DRAW_SW_ASM_CUSTOM_INCLUDE
27 #endif
28
29 /*********************
30 * DEFINES
31 *********************/
32
33 /**********************
34 * TYPEDEFS
35 **********************/
36
37 /**********************
38 * STATIC PROTOTYPES
39 **********************/
40
41 static void /* LV_ATTRIBUTE_FAST_MEM */ a8_image_blend(lv_draw_sw_blend_image_dsc_t * dsc);
42
43 #if LV_DRAW_SW_SUPPORT_L8 || LV_DRAW_SW_SUPPORT_RGB565 || LV_DRAW_SW_SUPPORT_RGB888 || LV_DRAW_SW_SUPPORT_XRGB8888
44
45 static void LV_ATTRIBUTE_FAST_MEM mask_only_image_blend(lv_draw_sw_blend_image_dsc_t * dsc);
46
47 #endif
48
49 #if LV_DRAW_SW_SUPPORT_I1
50 static void /* LV_ATTRIBUTE_FAST_MEM */ i1_image_blend(lv_draw_sw_blend_image_dsc_t * dsc);
51
52 static inline uint8_t /* LV_ATTRIBUTE_FAST_MEM */ get_bit(const uint8_t * buf, int32_t bit_idx);
53 #endif
54
55 #if LV_DRAW_SW_SUPPORT_AL88
56 static void /* LV_ATTRIBUTE_FAST_MEM */ al88_image_blend(lv_draw_sw_blend_image_dsc_t * dsc);
57 #endif
58
59 #if LV_DRAW_SW_SUPPORT_ARGB8888
60 static void /* LV_ATTRIBUTE_FAST_MEM */ argb8888_image_blend(lv_draw_sw_blend_image_dsc_t * dsc);
61 #endif
62
63 static inline void * /* LV_ATTRIBUTE_FAST_MEM */ drawbuf_next_row(const void * buf, uint32_t stride);
64
65 /**********************
66 * STATIC VARIABLES
67 **********************/
68
69 /**********************
70 * MACROS
71 **********************/
72
73 #define BLEND_A8(dest_a, src_a) if(dest_a < src_a) dest_a = src_a
74
75 #ifndef LV_DRAW_SW_COLOR_BLEND_TO_A8
76 #define LV_DRAW_SW_COLOR_BLEND_TO_A8(...) LV_RESULT_INVALID
77 #endif
78
79 #ifndef LV_DRAW_SW_COLOR_BLEND_TO_A8_WITH_OPA
80 #define LV_DRAW_SW_COLOR_BLEND_TO_A8_WITH_OPA(...) LV_RESULT_INVALID
81 #endif
82
83 #ifndef LV_DRAW_SW_COLOR_BLEND_TO_A8_WITH_MASK
84 #define LV_DRAW_SW_COLOR_BLEND_TO_A8_WITH_MASK(...) LV_RESULT_INVALID
85 #endif
86
87 #ifndef LV_DRAW_SW_COLOR_BLEND_TO_A8_MIX_MASK_OPA
88 #define LV_DRAW_SW_COLOR_BLEND_TO_A8_MIX_MASK_OPA(...) LV_RESULT_INVALID
89 #endif
90
91 #ifndef LV_DRAW_SW_MASK_ONLY_BLEND_TO_A8
92 #define LV_DRAW_SW_MASK_ONLY_BLEND_TO_A8(...) LV_RESULT_INVALID
93 #endif
94
95 #ifndef LV_DRAW_SW_MASK_ONLY_BLEND_TO_A8_WITH_OPA
96 #define LV_DRAW_SW_MASK_ONLY_BLEND_TO_A8_WITH_OPA(...) LV_RESULT_INVALID
97 #endif
98
99 #ifndef LV_DRAW_SW_MASK_ONLY_BLEND_TO_A8_WITH_MASK
100 #define LV_DRAW_SW_MASK_ONLY_BLEND_TO_A8_WITH_MASK(...) LV_RESULT_INVALID
101 #endif
102
103 #ifndef LV_DRAW_SW_MASK_ONLY_BLEND_TO_A8_MIX_MASK_OPA
104 #define LV_DRAW_SW_MASK_ONLY_BLEND_TO_A8_MIX_MASK_OPA(...) LV_RESULT_INVALID
105 #endif
106
107 #ifndef LV_DRAW_SW_A8_BLEND_TO_A8
108 #define LV_DRAW_SW_A8_BLEND_TO_A8(...) LV_RESULT_INVALID
109 #endif
110
111 #ifndef LV_DRAW_SW_A8_BLEND_TO_A8_WITH_OPA
112 #define LV_DRAW_SW_A8_BLEND_TO_A8_WITH_OPA(...) LV_RESULT_INVALID
113 #endif
114
115 #ifndef LV_DRAW_SW_A8_BLEND_TO_A8_WITH_MASK
116 #define LV_DRAW_SW_A8_BLEND_TO_A8_WITH_MASK(...) LV_RESULT_INVALID
117 #endif
118
119 #ifndef LV_DRAW_SW_A8_BLEND_TO_A8_MIX_MASK_OPA
120 #define LV_DRAW_SW_A8_BLEND_TO_A8_MIX_MASK_OPA(...) LV_RESULT_INVALID
121 #endif
122
123 #ifndef LV_DRAW_SW_AL88_BLEND_TO_A8
124 #define LV_DRAW_SW_AL88_BLEND_TO_A8(...) LV_RESULT_INVALID
125 #endif
126
127 #ifndef LV_DRAW_SW_AL88_BLEND_TO_A8_WITH_OPA
128 #define LV_DRAW_SW_AL88_BLEND_TO_A8_WITH_OPA(...) LV_RESULT_INVALID
129 #endif
130
131 #ifndef LV_DRAW_SW_AL88_BLEND_TO_A8_WITH_MASK
132 #define LV_DRAW_SW_AL88_BLEND_TO_A8_WITH_MASK(...) LV_RESULT_INVALID
133 #endif
134
135 #ifndef LV_DRAW_SW_AL88_BLEND_TO_A8_MIX_MASK_OPA
136 #define LV_DRAW_SW_AL88_BLEND_TO_A8_MIX_MASK_OPA(...) LV_RESULT_INVALID
137 #endif
138
139 #ifndef LV_DRAW_SW_ARGB8888_BLEND_TO_A8
140 #define LV_DRAW_SW_ARGB8888_BLEND_TO_A8(...) LV_RESULT_INVALID
141 #endif
142
143 #ifndef LV_DRAW_SW_ARGB8888_BLEND_TO_A8_WITH_OPA
144 #define LV_DRAW_SW_ARGB8888_BLEND_TO_A8_WITH_OPA(...) LV_RESULT_INVALID
145 #endif
146
147 #ifndef LV_DRAW_SW_ARGB8888_BLEND_TO_A8_WITH_MASK
148 #define LV_DRAW_SW_ARGB8888_BLEND_TO_A8_WITH_MASK(...) LV_RESULT_INVALID
149 #endif
150
151 #ifndef LV_DRAW_SW_ARGB8888_BLEND_TO_A8_MIX_MASK_OPA
152 #define LV_DRAW_SW_ARGB8888_BLEND_TO_A8_MIX_MASK_OPA(...) LV_RESULT_INVALID
153 #endif
154
155
156
157 #ifndef LV_DRAW_SW_I1_BLEND_TO_A8
158 #define LV_DRAW_SW_I1_BLEND_TO_A8(...) LV_RESULT_INVALID
159 #endif
160
161 #ifndef LV_DRAW_SW_I1_BLEND_TO_A8_WITH_OPA
162 #define LV_DRAW_SW_I1_BLEND_TO_A8_WITH_OPA(...) LV_RESULT_INVALID
163 #endif
164
165 #ifndef LV_DRAW_SW_I1_BLEND_TO_A8_WITH_MASK
166 #define LV_DRAW_SW_I1_BLEND_TO_A8_WITH_MASK(...) LV_RESULT_INVALID
167 #endif
168
169 #ifndef LV_DRAW_SW_I1_BLEND_TO_A8_MIX_MASK_OPA
170 #define LV_DRAW_SW_I1_BLEND_TO_A8_MIX_MASK_OPA(...) LV_RESULT_INVALID
171 #endif
172
173 /**********************
174 * GLOBAL FUNCTIONS
175 **********************/
176
177 void LV_ATTRIBUTE_FAST_MEM lv_draw_sw_blend_color_to_a8(lv_draw_sw_blend_fill_dsc_t * dsc)
178 {
179 int32_t w = dsc->dest_w;
180 int32_t h = dsc->dest_h;
181 lv_opa_t opa = dsc->opa;
182 const lv_opa_t * mask = dsc->mask_buf;
183 int32_t mask_stride = dsc->mask_stride;
184 int32_t dest_stride = dsc->dest_stride;
185
186 int32_t x;
187 int32_t y;
188
189 LV_UNUSED(w);
190 LV_UNUSED(h);
191 LV_UNUSED(x);
192 LV_UNUSED(y);
193 LV_UNUSED(opa);
194 LV_UNUSED(mask);
195 LV_UNUSED(mask_stride);
196 LV_UNUSED(dest_stride);
197
198 /*Simple fill*/
199 if(mask == NULL && opa >= LV_OPA_MAX) {
200 if(LV_RESULT_INVALID == LV_DRAW_SW_COLOR_BLEND_TO_A8(dsc)) {
201 uint8_t * dest_buf = dsc->dest_buf;
202 for(y = 0; y < h; y++) {
203 lv_memset(dest_buf, 0xff, w);
204 dest_buf = drawbuf_next_row(dest_buf, dest_stride);
205 }
206 }
207 }
208 /*Opacity only*/
209 else if(mask == NULL && opa < LV_OPA_MAX) {
210 if(LV_RESULT_INVALID == LV_DRAW_SW_COLOR_BLEND_TO_A8_WITH_OPA(dsc)) {
211 uint8_t * dest_buf = dsc->dest_buf;
212
213 for(y = 0; y < h; y++) {
214 for(x = 0; x < w; x++) {
215 BLEND_A8(dest_buf[x], opa);
216 }
217 dest_buf = drawbuf_next_row(dest_buf, dest_stride);
218 }
219 }
220
221 }
222 /*Masked with full opacity*/
223 else if(mask && opa >= LV_OPA_MAX) {
224 if(LV_RESULT_INVALID == LV_DRAW_SW_COLOR_BLEND_TO_A8_WITH_MASK(dsc)) {
225 uint8_t * dest_buf = dsc->dest_buf;
226 for(y = 0; y < h; y++) {
227 for(x = 0; x < w; x++) {
228 BLEND_A8(dest_buf[x], mask[x]);
229 }
230 dest_buf = drawbuf_next_row(dest_buf, dest_stride);
231 mask += mask_stride;
232 }
233 }
234
235 }
236 /*Masked with opacity*/
237 else {
238 if(LV_RESULT_INVALID == LV_DRAW_SW_COLOR_BLEND_TO_A8_MIX_MASK_OPA(dsc)) {
239 uint8_t * dest_buf = dsc->dest_buf;
240 for(y = 0; y < h; y++) {
241 for(x = 0; x < w; x++) {
242 lv_opa_t opa_res = LV_OPA_MIX2(mask[x], opa);
243 BLEND_A8(dest_buf[x], opa_res);
244 }
245 dest_buf = drawbuf_next_row(dest_buf, dest_stride);
246 mask += mask_stride;
247 }
248 }
249 }
250 }
251
252 void LV_ATTRIBUTE_FAST_MEM lv_draw_sw_blend_image_to_a8(lv_draw_sw_blend_image_dsc_t * dsc)
253 {
254 switch(dsc->src_color_format) {
255 #if LV_DRAW_SW_SUPPORT_RGB565
256 case LV_COLOR_FORMAT_RGB565:
257 mask_only_image_blend(dsc);
258 break;
259 #endif
260 #if LV_DRAW_SW_SUPPORT_RGB565_SWAPPED
261 case LV_COLOR_FORMAT_RGB565_SWAPPED:
262 mask_only_image_blend(dsc);
263 break;
264 #endif
265 #if LV_DRAW_SW_SUPPORT_RGB888
266 case LV_COLOR_FORMAT_RGB888:
267 mask_only_image_blend(dsc);
268 break;
269 #endif
270 #if LV_DRAW_SW_SUPPORT_XRGB8888
271 case LV_COLOR_FORMAT_XRGB8888:
272 mask_only_image_blend(dsc);
273 break;
274 #endif
275 #if LV_DRAW_SW_SUPPORT_ARGB8888
276 case LV_COLOR_FORMAT_ARGB8888:
277 argb8888_image_blend(dsc);
278 break;
279 #endif
280 case LV_COLOR_FORMAT_A8:
281 a8_image_blend(dsc);
282 break;
283 #if LV_DRAW_SW_SUPPORT_L8
284 case LV_COLOR_FORMAT_L8:
285 mask_only_image_blend(dsc);
286 break;
287 #endif
288 #if LV_DRAW_SW_SUPPORT_AL88
289 case LV_COLOR_FORMAT_AL88:
290 al88_image_blend(dsc);
291 break;
292 #endif
293 #if LV_DRAW_SW_SUPPORT_I1
294 case LV_COLOR_FORMAT_I1:
295 i1_image_blend(dsc);
296 break;
297 #endif
298 default:
299 LV_LOG_WARN("Not supported source color format");
300 break;
301 }
302 }
303
304 /**********************
305 * STATIC FUNCTIONS
306 **********************/
307
308 static void LV_ATTRIBUTE_FAST_MEM a8_image_blend(lv_draw_sw_blend_image_dsc_t * dsc)
309 {
310 int32_t w = dsc->dest_w;
311 int32_t h = dsc->dest_h;
312 lv_opa_t opa = dsc->opa;
313 uint8_t * dest_buf_a8 = dsc->dest_buf;
314 int32_t dest_stride = dsc->dest_stride;
315 const uint8_t * src_buf_a8 = dsc->src_buf;
316 int32_t src_stride = dsc->src_stride;
317 const lv_opa_t * mask_buf = dsc->mask_buf;
318 int32_t mask_stride = dsc->mask_stride;
319
320 int32_t dest_x;
321 int32_t src_x;
322 int32_t y;
323
324 if(mask_buf == NULL && opa >= LV_OPA_MAX) {
325 if(LV_RESULT_INVALID == LV_DRAW_SW_A8_BLEND_TO_A8(dsc)) {
326 for(y = 0; y < h; y++) {
327 for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) {
328 BLEND_A8(dest_buf_a8[dest_x], src_buf_a8[src_x]);
329 }
330 dest_buf_a8 = drawbuf_next_row(dest_buf_a8, dest_stride);
331 src_buf_a8 = drawbuf_next_row(src_buf_a8, src_stride);
332 }
333 }
334 }
335 else if(mask_buf == NULL && opa < LV_OPA_MAX) {
336 if(LV_RESULT_INVALID == LV_DRAW_SW_A8_BLEND_TO_A8_WITH_OPA(dsc)) {
337 for(y = 0; y < h; y++) {
338 for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) {
339 BLEND_A8(dest_buf_a8[dest_x], LV_OPA_MIX2(opa, src_buf_a8[src_x]));
340 }
341 dest_buf_a8 = drawbuf_next_row(dest_buf_a8, dest_stride);
342 src_buf_a8 = drawbuf_next_row(src_buf_a8, src_stride);
343 }
344 }
345 }
346 else if(mask_buf && opa >= LV_OPA_MAX) {
347 if(LV_RESULT_INVALID == LV_DRAW_SW_A8_BLEND_TO_A8_WITH_MASK(dsc)) {
348 for(y = 0; y < h; y++) {
349 for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) {
350 BLEND_A8(dest_buf_a8[dest_x], LV_OPA_MIX2(mask_buf[src_x], src_buf_a8[src_x]));
351 }
352 dest_buf_a8 = drawbuf_next_row(dest_buf_a8, dest_stride);
353 src_buf_a8 = drawbuf_next_row(src_buf_a8, src_stride);
354 mask_buf += mask_stride;
355 }
356 }
357 }
358 else if(mask_buf && opa < LV_OPA_MAX) {
359 if(LV_RESULT_INVALID == LV_DRAW_SW_A8_BLEND_TO_A8_MIX_MASK_OPA(dsc)) {
360 for(y = 0; y < h; y++) {
361 for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) {
362 BLEND_A8(dest_buf_a8[dest_x], LV_OPA_MIX3(opa, mask_buf[src_x], src_buf_a8[src_x]));
363 }
364 dest_buf_a8 = drawbuf_next_row(dest_buf_a8, dest_stride);
365 src_buf_a8 = drawbuf_next_row(src_buf_a8, src_stride);
366 mask_buf += mask_stride;
367 }
368 }
369 }
370 }
371
372 #if LV_DRAW_SW_SUPPORT_L8 || LV_DRAW_SW_SUPPORT_RGB565 || LV_DRAW_SW_SUPPORT_RGB888 || LV_DRAW_SW_SUPPORT_XRGB8888
373
374 static void LV_ATTRIBUTE_FAST_MEM mask_only_image_blend(lv_draw_sw_blend_image_dsc_t * dsc)
375 {
376 int32_t w = dsc->dest_w;
377 int32_t h = dsc->dest_h;
378 lv_opa_t opa = dsc->opa;
379 uint8_t * dest_buf_u8 = dsc->dest_buf;
380 int32_t dest_stride = dsc->dest_stride;
381 const lv_opa_t * mask_buf = dsc->mask_buf;
382 int32_t mask_stride = dsc->mask_stride;
383
384 int32_t src_x;
385 int32_t dest_x;
386 int32_t y;
387
388 if(mask_buf == NULL && opa >= LV_OPA_MAX) {
389 if(LV_RESULT_INVALID == LV_DRAW_SW_MASK_ONLY_BLEND_TO_A8(dsc)) {
390 for(y = 0; y < h; y++) {
391 lv_memset(dest_buf_u8, 0xff, w);
392 dest_buf_u8 += dest_stride;
393 }
394 }
395 }
396 else if(mask_buf == NULL && opa < LV_OPA_MAX) {
397 if(LV_RESULT_INVALID == LV_DRAW_SW_MASK_ONLY_BLEND_TO_A8_WITH_OPA(dsc)) {
398 for(y = 0; y < h; y++) {
399 for(src_x = 0, dest_x = 0; src_x < w; dest_x++, src_x++) {
400 BLEND_A8(dest_buf_u8[dest_x], opa);
401 }
402 dest_buf_u8 += dest_stride;
403 }
404 }
405 }
406 else if(mask_buf && opa >= LV_OPA_MAX) {
407 if(LV_RESULT_INVALID == LV_DRAW_SW_MASK_ONLY_BLEND_TO_A8_WITH_MASK(dsc)) {
408 for(y = 0; y < h; y++) {
409 for(src_x = 0, dest_x = 0; src_x < w; dest_x++, src_x++) {
410 BLEND_A8(dest_buf_u8[dest_x], mask_buf[src_x]);
411 }
412 dest_buf_u8 += dest_stride;
413 mask_buf += mask_stride;
414 }
415 }
416 }
417 else {
418 if(LV_RESULT_INVALID == LV_DRAW_SW_MASK_ONLY_BLEND_TO_A8_MIX_MASK_OPA(dsc)) {
419 for(y = 0; y < h; y++) {
420 for(src_x = 0, dest_x = 0; src_x < w; dest_x++, src_x++) {
421 BLEND_A8(dest_buf_u8[dest_x], LV_OPA_MIX2(opa, mask_buf[src_x]));
422 }
423 dest_buf_u8 += dest_stride;
424 mask_buf += mask_stride;
425 }
426 }
427 }
428 }
429
430 #endif
431
432
433 #if LV_DRAW_SW_SUPPORT_I1
434
435 static void LV_ATTRIBUTE_FAST_MEM i1_image_blend(lv_draw_sw_blend_image_dsc_t * dsc)
436 {
437 int32_t w = dsc->dest_w;
438 int32_t h = dsc->dest_h;
439 lv_opa_t opa = dsc->opa;
440 uint8_t * dest_buf_a8 = dsc->dest_buf;
441 int32_t dest_stride = dsc->dest_stride;
442 const uint8_t * src_buf_i1 = dsc->src_buf;
443 int32_t src_stride = dsc->src_stride;
444 const lv_opa_t * mask_buf = dsc->mask_buf;
445 int32_t mask_stride = dsc->mask_stride;
446
447 int32_t dest_x;
448 int32_t src_x;
449 int32_t y;
450
451 if(mask_buf == NULL && opa >= LV_OPA_MAX) {
452 if(LV_RESULT_INVALID == LV_DRAW_SW_I1_BLEND_TO_A8(dsc)) {
453 for(y = 0; y < h; y++) {
454 for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) {
455 if(get_bit(src_buf_i1, src_x)) dest_buf_a8[dest_x] = 0xff;
456 }
457 dest_buf_a8 = drawbuf_next_row(dest_buf_a8, dest_stride);
458 src_buf_i1 = drawbuf_next_row(src_buf_i1, src_stride);
459 }
460 }
461 }
462 else if(mask_buf == NULL && opa < LV_OPA_MAX) {
463 if(LV_RESULT_INVALID == LV_DRAW_SW_I1_BLEND_TO_A8_WITH_OPA(dsc)) {
464 for(y = 0; y < h; y++) {
465 for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) {
466 if(get_bit(src_buf_i1, src_x)) {
467 BLEND_A8(dest_buf_a8[dest_x], opa);
468 }
469 }
470 dest_buf_a8 = drawbuf_next_row(dest_buf_a8, dest_stride);
471 src_buf_i1 = drawbuf_next_row(src_buf_i1, src_stride);
472 }
473 }
474 }
475 else if(mask_buf && opa >= LV_OPA_MAX) {
476 if(LV_RESULT_INVALID == LV_DRAW_SW_I1_BLEND_TO_A8_WITH_MASK(dsc)) {
477 for(y = 0; y < h; y++) {
478 for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) {
479 if(get_bit(src_buf_i1, src_x)) {
480 BLEND_A8(dest_buf_a8[dest_x], mask_buf[src_x]);
481 }
482 }
483 dest_buf_a8 = drawbuf_next_row(dest_buf_a8, dest_stride);
484 src_buf_i1 = drawbuf_next_row(src_buf_i1, src_stride);
485 mask_buf += mask_stride;
486 }
487 }
488 }
489 else if(mask_buf && opa < LV_OPA_MAX) {
490 if(LV_RESULT_INVALID == LV_DRAW_SW_I1_BLEND_TO_A8_MIX_MASK_OPA(dsc)) {
491 for(y = 0; y < h; y++) {
492 for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) {
493 if(get_bit(src_buf_i1, src_x)) {
494 lv_opa_t opa_res = LV_OPA_MIX2(mask_buf[src_x], opa);
495 BLEND_A8(dest_buf_a8[dest_x], opa_res);
496
497 }
498 }
499 dest_buf_a8 = drawbuf_next_row(dest_buf_a8, dest_stride);
500 src_buf_i1 = drawbuf_next_row(src_buf_i1, src_stride);
501 mask_buf += mask_stride;
502 }
503 }
504 }
505 }
506 #endif
507
508 #if LV_DRAW_SW_SUPPORT_AL88
509
510 static void LV_ATTRIBUTE_FAST_MEM al88_image_blend(lv_draw_sw_blend_image_dsc_t * dsc)
511 {
512 int32_t w = dsc->dest_w;
513 int32_t h = dsc->dest_h;
514 lv_opa_t opa = dsc->opa;
515 uint8_t * dest_buf_a8 = dsc->dest_buf;
516 int32_t dest_stride = dsc->dest_stride;
517 const lv_color16a_t * src_buf_al88 = dsc->src_buf;
518 int32_t src_stride = dsc->src_stride;
519 const lv_opa_t * mask_buf = dsc->mask_buf;
520 int32_t mask_stride = dsc->mask_stride;
521
522 int32_t dest_x;
523 int32_t src_x;
524 int32_t y;
525
526 if(mask_buf == NULL && opa >= LV_OPA_MAX) {
527 if(LV_RESULT_INVALID == LV_DRAW_SW_AL88_BLEND_TO_A8(dsc)) {
528 for(y = 0; y < h; y++) {
529 for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) {
530 BLEND_A8(dest_buf_a8[dest_x], src_buf_al88[src_x].alpha);
531 }
532 dest_buf_a8 = drawbuf_next_row(dest_buf_a8, dest_stride);
533 src_buf_al88 = drawbuf_next_row(src_buf_al88, src_stride);
534 }
535 }
536 }
537 else if(mask_buf == NULL && opa < LV_OPA_MAX) {
538 if(LV_RESULT_INVALID == LV_DRAW_SW_AL88_BLEND_TO_A8_WITH_OPA(dsc)) {
539 for(y = 0; y < h; y++) {
540 for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) {
541 BLEND_A8(dest_buf_a8[dest_x], LV_OPA_MIX2(src_buf_al88[src_x].alpha, opa));
542 }
543 dest_buf_a8 = drawbuf_next_row(dest_buf_a8, dest_stride);
544 src_buf_al88 = drawbuf_next_row(src_buf_al88, src_stride);
545 }
546 }
547 }
548 else if(mask_buf && opa >= LV_OPA_MAX) {
549 if(LV_RESULT_INVALID == LV_DRAW_SW_AL88_BLEND_TO_A8_WITH_MASK(dsc)) {
550 for(y = 0; y < h; y++) {
551 for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) {
552 BLEND_A8(dest_buf_a8[dest_x], LV_OPA_MIX2(src_buf_al88[src_x].alpha, mask_buf[src_x]));
553 }
554 dest_buf_a8 = drawbuf_next_row(dest_buf_a8, dest_stride);
555 src_buf_al88 = drawbuf_next_row(src_buf_al88, src_stride);
556 mask_buf += mask_stride;
557 }
558 }
559 }
560 else if(mask_buf && opa < LV_OPA_MAX) {
561 if(LV_RESULT_INVALID == LV_DRAW_SW_AL88_BLEND_TO_A8_MIX_MASK_OPA(dsc)) {
562 for(y = 0; y < h; y++) {
563 for(dest_x = 0, src_x = 0; src_x < w; dest_x++, src_x++) {
564 BLEND_A8(dest_buf_a8[dest_x], LV_OPA_MIX3(src_buf_al88[src_x].alpha, mask_buf[src_x],
565 opa));
566 }
567 dest_buf_a8 = drawbuf_next_row(dest_buf_a8, dest_stride);
568 src_buf_al88 = drawbuf_next_row(src_buf_al88, src_stride);
569 mask_buf += mask_stride;
570 }
571 }
572 }
573 }
574
575 #endif
576
577
578 #if LV_DRAW_SW_SUPPORT_ARGB8888
579
580 static void LV_ATTRIBUTE_FAST_MEM argb8888_image_blend(lv_draw_sw_blend_image_dsc_t * dsc)
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_a8 = dsc->dest_buf;
586 int32_t dest_stride = dsc->dest_stride;
587 const lv_color32_t * src_buf_c32 = 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 x;
593 int32_t y;
594
595 if(mask_buf == NULL && opa >= LV_OPA_MAX) {
596 if(LV_RESULT_INVALID == LV_DRAW_SW_A8_BLEND_TO_A8(dsc)) {
597 for(y = 0; y < h; y++) {
598 for(x = 0; x < w; x++) {
599 BLEND_A8(dest_buf_a8[x], src_buf_c32[x].alpha);
600 }
601 dest_buf_a8 = drawbuf_next_row(dest_buf_a8, dest_stride);
602 src_buf_c32 = drawbuf_next_row(src_buf_c32, src_stride);
603 }
604 }
605 }
606 else if(mask_buf == NULL && opa < LV_OPA_MAX) {
607 if(LV_RESULT_INVALID == LV_DRAW_SW_A8_BLEND_TO_A8_WITH_OPA(dsc)) {
608 for(y = 0; y < h; y++) {
609 for(x = 0; x < w; x++) {
610 BLEND_A8(dest_buf_a8[x], LV_OPA_MIX2(src_buf_c32[x].alpha, opa));
611 }
612 dest_buf_a8 = drawbuf_next_row(dest_buf_a8, dest_stride);
613 src_buf_c32 = drawbuf_next_row(src_buf_c32, src_stride);
614 }
615 }
616 }
617 else if(mask_buf && opa >= LV_OPA_MAX) {
618 if(LV_RESULT_INVALID == LV_DRAW_SW_A8_BLEND_TO_A8_WITH_MASK(dsc)) {
619 for(y = 0; y < h; y++) {
620 for(x = 0; x < w; x++) {
621 BLEND_A8(dest_buf_a8[x], LV_OPA_MIX2(src_buf_c32[x].alpha, mask_buf[x]));
622 }
623 dest_buf_a8 = drawbuf_next_row(dest_buf_a8, dest_stride);
624 src_buf_c32 = drawbuf_next_row(src_buf_c32, src_stride);
625 mask_buf += mask_stride;
626 }
627 }
628 }
629 else if(mask_buf && opa < LV_OPA_MAX) {
630 if(LV_RESULT_INVALID == LV_DRAW_SW_A8_BLEND_TO_A8_MIX_MASK_OPA(dsc)) {
631 for(y = 0; y < h; y++) {
632 for(x = 0; x < w; x++) {
633 BLEND_A8(dest_buf_a8[x], LV_OPA_MIX3(src_buf_c32[x].alpha, opa,
634 mask_buf[x]));
635 }
636 dest_buf_a8 = drawbuf_next_row(dest_buf_a8, dest_stride);
637 src_buf_c32 = drawbuf_next_row(src_buf_c32, src_stride);
638 mask_buf += mask_stride;
639 }
640 }
641 }
642 }
643
644 #endif
645
646
647 #if LV_DRAW_SW_SUPPORT_I1
648
649 static inline uint8_t LV_ATTRIBUTE_FAST_MEM get_bit(const uint8_t * buf, int32_t bit_idx)
650 {
651 return (buf[bit_idx / 8] >> (7 - (bit_idx % 8))) & 1;
652 }
653
654 #endif
655
656 static inline void * LV_ATTRIBUTE_FAST_MEM drawbuf_next_row(const void * buf, uint32_t stride)
657 {
658 return (void *)((uint8_t *)buf + stride);
659 }
660
661 #endif
662
663 #endif