1 /**
2 * @file lv_draw_sw_utils.c
3 *
4 */
5
6 /*********************
7 * INCLUDES
8 *********************/
9 #include "lv_draw_sw_utils.h"
10 #if LV_USE_DRAW_SW
11
12 /*********************
13 * DEFINES
14 *********************/
15 #ifndef LV_DRAW_SW_RGB565_SWAP
16 #define LV_DRAW_SW_RGB565_SWAP(...) LV_RESULT_INVALID
17 #endif
18
19 #ifndef LV_DRAW_SW_ROTATE90_ARGB8888
20 #define LV_DRAW_SW_ROTATE90_ARGB8888(...) LV_RESULT_INVALID
21 #endif
22
23 #ifndef LV_DRAW_SW_ROTATE180_ARGB8888
24 #define LV_DRAW_SW_ROTATE180_ARGB8888(...) LV_RESULT_INVALID
25 #endif
26
27 #ifndef LV_DRAW_SW_ROTATE270_ARGB8888
28 #define LV_DRAW_SW_ROTATE270_ARGB8888(...) LV_RESULT_INVALID
29 #endif
30
31 #ifndef LV_DRAW_SW_ROTATE90_RGB888
32 #define LV_DRAW_SW_ROTATE90_RGB888(...) LV_RESULT_INVALID
33 #endif
34
35 #ifndef LV_DRAW_SW_ROTATE180_RGB888
36 #define LV_DRAW_SW_ROTATE180_RGB888(...) LV_RESULT_INVALID
37 #endif
38
39 #ifndef LV_DRAW_SW_ROTATE270_RGB888
40 #define LV_DRAW_SW_ROTATE270_RGB888(...) LV_RESULT_INVALID
41 #endif
42
43 #ifndef LV_DRAW_SW_ROTATE90_RGB565
44 #define LV_DRAW_SW_ROTATE90_RGB565(...) LV_RESULT_INVALID
45 #endif
46
47 #ifndef LV_DRAW_SW_ROTATE180_RGB565
48 #define LV_DRAW_SW_ROTATE180_RGB565(...) LV_RESULT_INVALID
49 #endif
50
51 #ifndef LV_DRAW_SW_ROTATE270_RGB565
52 #define LV_DRAW_SW_ROTATE270_RGB565(...) LV_RESULT_INVALID
53 #endif
54
55 #ifndef LV_DRAW_SW_ROTATE90_L8
56 #define LV_DRAW_SW_ROTATE90_L8(...) LV_RESULT_INVALID
57 #endif
58
59 #ifndef LV_DRAW_SW_ROTATE180_L8
60 #define LV_DRAW_SW_ROTATE180_L8(...) LV_RESULT_INVALID
61 #endif
62
63 #ifndef LV_DRAW_SW_ROTATE270_L8
64 #define LV_DRAW_SW_ROTATE270_L8(...) LV_RESULT_INVALID
65 #endif
66
67 /**********************
68 * TYPEDEFS
69 **********************/
70
71 /**********************
72 * STATIC PROTOTYPES
73 **********************/
74
75 #if LV_DRAW_SW_SUPPORT_ARGB8888 || LV_DRAW_SW_SUPPORT_XRGB8888
76 static void rotate90_argb8888(const uint32_t * src, uint32_t * dst, int32_t src_width, int32_t src_height,
77 int32_t src_stride,
78 int32_t dst_stride);
79 static void rotate180_argb8888(const uint32_t * src, uint32_t * dst, int32_t width, int32_t height, int32_t src_stride,
80 int32_t dest_stride);
81 static void rotate270_argb8888(const uint32_t * src, uint32_t * dst, int32_t src_width, int32_t src_height,
82 int32_t src_stride,
83 int32_t dst_stride);
84 #endif
85 #if LV_DRAW_SW_SUPPORT_RGB888
86 static void rotate90_rgb888(const uint8_t * src, uint8_t * dst, int32_t src_width, int32_t src_height,
87 int32_t src_stride,
88 int32_t dst_stride);
89 static void rotate180_rgb888(const uint8_t * src, uint8_t * dst, int32_t width, int32_t height, int32_t src_stride,
90 int32_t dest_stride);
91 static void rotate270_rgb888(const uint8_t * src, uint8_t * dst, int32_t width, int32_t height, int32_t src_stride,
92 int32_t dst_stride);
93 #endif
94 #if LV_DRAW_SW_SUPPORT_RGB565
95 static void rotate90_rgb565(const uint16_t * src, uint16_t * dst, int32_t src_width, int32_t src_height,
96 int32_t src_stride,
97 int32_t dst_stride);
98 static void rotate180_rgb565(const uint16_t * src, uint16_t * dst, int32_t width, int32_t height, int32_t src_stride,
99 int32_t dest_stride);
100 static void rotate270_rgb565(const uint16_t * src, uint16_t * dst, int32_t src_width, int32_t src_height,
101 int32_t src_stride,
102 int32_t dst_stride);
103 #endif
104
105 #if LV_DRAW_SW_SUPPORT_L8
106
107 static void rotate90_l8(const uint8_t * src, uint8_t * dst, int32_t src_width, int32_t src_height,
108 int32_t src_stride,
109 int32_t dst_stride);
110 static void rotate180_l8(const uint8_t * src, uint8_t * dst, int32_t width, int32_t height, int32_t src_stride,
111 int32_t dest_stride);
112 static void rotate270_l8(const uint8_t * src, uint8_t * dst, int32_t src_width, int32_t src_height,
113 int32_t src_stride,
114 int32_t dst_stride);
115 #endif
116
117 /**********************
118 * STATIC VARIABLES
119 **********************/
120
121 /**********************
122 * MACROS
123 **********************/
124
125 /**********************
126 * GLOBAL FUNCTIONS
127 **********************/
128
lv_draw_sw_i1_to_argb8888(const void * buf_i1,void * buf_argb8888,uint32_t width,uint32_t height,uint32_t buf_i1_stride,uint32_t buf_argb8888_stride,uint32_t index0_color,uint32_t index1_color)129 void lv_draw_sw_i1_to_argb8888(const void * buf_i1, void * buf_argb8888, uint32_t width, uint32_t height,
130 uint32_t buf_i1_stride, uint32_t buf_argb8888_stride, uint32_t index0_color, uint32_t index1_color)
131 {
132 /*Extract the bits of I1 px_map and convert them to ARGB8888*/
133 const uint8_t * src = buf_i1;
134 uint32_t * dst = buf_argb8888;
135 uint32_t i1_row_byte_count = width / 8;
136 for(uint32_t row = 0; row < height; row++) {
137 uint32_t * dst_p = dst;
138 for(uint32_t i = 0; i < i1_row_byte_count; i++) {
139 /*From MSB to LSB (pixel 0 to pixel 7 in a byte)*/
140 for(int32_t bit = 7; bit >= 0; bit--) {
141 *dst_p++ = ((src[i] >> bit) & 1) ? index1_color : index0_color;
142 }
143 }
144 src += buf_i1_stride;
145 dst += buf_argb8888_stride / 4;
146 }
147 }
148
lv_draw_sw_rgb565_swap(void * buf,uint32_t buf_size_px)149 void lv_draw_sw_rgb565_swap(void * buf, uint32_t buf_size_px)
150 {
151 if(LV_DRAW_SW_RGB565_SWAP(buf, buf_size_px) == LV_RESULT_OK) return;
152
153 uint32_t u32_cnt = buf_size_px / 2;
154 uint16_t * buf16 = buf;
155 uint32_t * buf32 = buf;
156
157 while(u32_cnt >= 8) {
158 buf32[0] = ((buf32[0] & 0xff00ff00) >> 8) | ((buf32[0] & 0x00ff00ff) << 8);
159 buf32[1] = ((buf32[1] & 0xff00ff00) >> 8) | ((buf32[1] & 0x00ff00ff) << 8);
160 buf32[2] = ((buf32[2] & 0xff00ff00) >> 8) | ((buf32[2] & 0x00ff00ff) << 8);
161 buf32[3] = ((buf32[3] & 0xff00ff00) >> 8) | ((buf32[3] & 0x00ff00ff) << 8);
162 buf32[4] = ((buf32[4] & 0xff00ff00) >> 8) | ((buf32[4] & 0x00ff00ff) << 8);
163 buf32[5] = ((buf32[5] & 0xff00ff00) >> 8) | ((buf32[5] & 0x00ff00ff) << 8);
164 buf32[6] = ((buf32[6] & 0xff00ff00) >> 8) | ((buf32[6] & 0x00ff00ff) << 8);
165 buf32[7] = ((buf32[7] & 0xff00ff00) >> 8) | ((buf32[7] & 0x00ff00ff) << 8);
166 buf32 += 8;
167 u32_cnt -= 8;
168 }
169
170 while(u32_cnt) {
171 *buf32 = ((*buf32 & 0xff00ff00) >> 8) | ((*buf32 & 0x00ff00ff) << 8);
172 buf32++;
173 u32_cnt--;
174 }
175
176 if(buf_size_px & 0x1) {
177 uint32_t e = buf_size_px - 1;
178 buf16[e] = ((buf16[e] & 0xff00) >> 8) | ((buf16[e] & 0x00ff) << 8);
179 }
180
181 }
182
lv_draw_sw_i1_invert(void * buf,uint32_t buf_size)183 void lv_draw_sw_i1_invert(void * buf, uint32_t buf_size)
184 {
185 if(buf == NULL) return;
186
187 uint8_t * byte_buf = (uint8_t *)buf;
188 uint32_t i;
189
190 /*Make the buffer aligned*/
191 while(((uintptr_t)(byte_buf) & (sizeof(int) - 1)) && buf_size > 0) {
192 *byte_buf = ~(*byte_buf);
193 byte_buf++;
194 buf_size--;
195 }
196
197 if(buf_size >= sizeof(uint32_t)) {
198 uint32_t * aligned_addr = (uint32_t *)byte_buf;
199 uint32_t word_count = buf_size / 4;
200
201 for(i = 0; i < word_count; ++i) {
202 aligned_addr[i] = ~aligned_addr[i];
203 }
204
205 byte_buf = (uint8_t *)(aligned_addr + word_count);
206 buf_size = buf_size % sizeof(uint32_t);
207 }
208
209 for(i = 0; i < buf_size; ++i) {
210 byte_buf[i] = ~byte_buf[i];
211 }
212 }
213
lv_draw_sw_i1_convert_to_vtiled(const void * buf,uint32_t buf_size,uint32_t width,uint32_t height,void * out_buf,uint32_t out_buf_size,bool bit_order_lsb)214 void lv_draw_sw_i1_convert_to_vtiled(const void * buf, uint32_t buf_size, uint32_t width, uint32_t height,
215 void * out_buf,
216 uint32_t out_buf_size, bool bit_order_lsb)
217 {
218 LV_ASSERT(buf && out_buf);
219 LV_ASSERT(width % 8 == 0 && height % 8 == 0);
220 LV_ASSERT(buf_size >= (width / 8) * height);
221 LV_ASSERT(out_buf_size >= buf_size);
222
223 lv_memset(out_buf, 0, out_buf_size);
224
225 const uint8_t * src_buf = (uint8_t *)buf;
226 uint8_t * dst_buf = (uint8_t *)out_buf;
227
228 for(uint32_t y = 0; y < height; y++) {
229 for(uint32_t x = 0; x < width; x++) {
230 uint32_t src_index = y * width + x;
231 uint32_t dst_index = x * height + y;
232 uint8_t bit = (src_buf[src_index / 8] >> (7 - (src_index % 8))) & 0x01;
233 if(bit_order_lsb) {
234 dst_buf[dst_index / 8] |= (bit << (dst_index % 8));
235 }
236 else {
237 dst_buf[dst_index / 8] |= (bit << (7 - (dst_index % 8)));
238 }
239 }
240 }
241 }
242
lv_draw_sw_rotate(const void * src,void * dest,int32_t src_width,int32_t src_height,int32_t src_stride,int32_t dest_stride,lv_display_rotation_t rotation,lv_color_format_t color_format)243 void lv_draw_sw_rotate(const void * src, void * dest, int32_t src_width, int32_t src_height, int32_t src_stride,
244 int32_t dest_stride, lv_display_rotation_t rotation, lv_color_format_t color_format)
245 {
246 if(rotation == LV_DISPLAY_ROTATION_90) {
247 switch(color_format) {
248 #if LV_DRAW_SW_SUPPORT_L8
249 case LV_COLOR_FORMAT_L8:
250 rotate90_l8(src, dest, src_width, src_height, src_stride, dest_stride);
251 break;
252 #endif
253 #if LV_DRAW_SW_SUPPORT_RGB565
254 case LV_COLOR_FORMAT_RGB565:
255 rotate90_rgb565(src, dest, src_width, src_height, src_stride, dest_stride);
256 break;
257 #endif
258 #if LV_DRAW_SW_SUPPORT_RGB888
259 case LV_COLOR_FORMAT_RGB888:
260 rotate90_rgb888(src, dest, src_width, src_height, src_stride, dest_stride);
261 break;
262 #endif
263 #if LV_DRAW_SW_SUPPORT_ARGB8888 || LV_DRAW_SW_SUPPORT_XRGB8888
264 case LV_COLOR_FORMAT_XRGB8888:
265 case LV_COLOR_FORMAT_ARGB8888:
266 rotate90_argb8888(src, dest, src_width, src_height, src_stride, dest_stride);
267 break;
268 #endif
269 default:
270 break;
271 }
272
273 return;
274 }
275
276 if(rotation == LV_DISPLAY_ROTATION_180) {
277 switch(color_format) {
278 #if LV_DRAW_SW_SUPPORT_L8
279 case LV_COLOR_FORMAT_L8:
280 rotate180_l8(src, dest, src_width, src_height, src_stride, dest_stride);
281 break;
282 #endif
283 #if LV_DRAW_SW_SUPPORT_RGB565
284 case LV_COLOR_FORMAT_RGB565:
285 rotate180_rgb565(src, dest, src_width, src_height, src_stride, dest_stride);
286 break;
287 #endif
288 #if LV_DRAW_SW_SUPPORT_RGB888
289 case LV_COLOR_FORMAT_RGB888:
290 rotate180_rgb888(src, dest, src_width, src_height, src_stride, dest_stride);
291 break;
292 #endif
293 #if LV_DRAW_SW_SUPPORT_ARGB8888 || LV_DRAW_SW_SUPPORT_XRGB8888
294 case LV_COLOR_FORMAT_XRGB8888:
295 case LV_COLOR_FORMAT_ARGB8888:
296 rotate180_argb8888(src, dest, src_width, src_height, src_stride, dest_stride);
297 break;
298 #endif
299 default:
300 break;
301 }
302
303 return;
304 }
305
306 if(rotation == LV_DISPLAY_ROTATION_270) {
307 switch(color_format) {
308 #if LV_DRAW_SW_SUPPORT_L8
309 case LV_COLOR_FORMAT_L8:
310 rotate270_l8(src, dest, src_width, src_height, src_stride, dest_stride);
311 break;
312 #endif
313 #if LV_DRAW_SW_SUPPORT_RGB565
314 case LV_COLOR_FORMAT_RGB565:
315 rotate270_rgb565(src, dest, src_width, src_height, src_stride, dest_stride);
316 break;
317 #endif
318 #if LV_DRAW_SW_SUPPORT_RGB888
319 case LV_COLOR_FORMAT_RGB888:
320 rotate270_rgb888(src, dest, src_width, src_height, src_stride, dest_stride);
321 break;
322 #endif
323 #if LV_DRAW_SW_SUPPORT_ARGB8888 || LV_DRAW_SW_SUPPORT_XRGB8888
324 case LV_COLOR_FORMAT_XRGB8888:
325 case LV_COLOR_FORMAT_ARGB8888:
326 rotate270_argb8888(src, dest, src_width, src_height, src_stride, dest_stride);
327 break;
328 #endif
329 default:
330 break;
331 }
332
333 return;
334 }
335 }
336
337 /**********************
338 * STATIC FUNCTIONS
339 **********************/
340
341 #if LV_DRAW_SW_SUPPORT_ARGB8888 || LV_DRAW_SW_SUPPORT_XRGB8888
342
rotate270_argb8888(const uint32_t * src,uint32_t * dst,int32_t src_width,int32_t src_height,int32_t src_stride,int32_t dst_stride)343 static void rotate270_argb8888(const uint32_t * src, uint32_t * dst, int32_t src_width, int32_t src_height,
344 int32_t src_stride,
345 int32_t dst_stride)
346 {
347 if(LV_RESULT_OK == LV_DRAW_SW_ROTATE90_ARGB8888(src, dst, src_width, src_height, src_stride, dst_stride)) {
348 return ;
349 }
350
351 src_stride /= sizeof(uint32_t);
352 dst_stride /= sizeof(uint32_t);
353
354 for(int32_t x = 0; x < src_width; ++x) {
355 int32_t dstIndex = x * dst_stride;
356 int32_t srcIndex = x;
357 for(int32_t y = 0; y < src_height; ++y) {
358 dst[dstIndex + (src_height - y - 1)] = src[srcIndex];
359 srcIndex += src_stride;
360 }
361 }
362 }
363
rotate180_argb8888(const uint32_t * src,uint32_t * dst,int32_t width,int32_t height,int32_t src_stride,int32_t dest_stride)364 static void rotate180_argb8888(const uint32_t * src, uint32_t * dst, int32_t width, int32_t height, int32_t src_stride,
365 int32_t dest_stride)
366 {
367 LV_UNUSED(dest_stride);
368 if(LV_RESULT_OK == LV_DRAW_SW_ROTATE180_ARGB8888(src, dst, src_width, src_height, src_stride, dst_stride)) {
369 return ;
370 }
371
372 src_stride /= sizeof(uint32_t);
373 dest_stride /= sizeof(uint32_t);
374
375 for(int32_t y = 0; y < height; ++y) {
376 int32_t dstIndex = (height - y - 1) * dest_stride;
377 int32_t srcIndex = y * src_stride;
378 for(int32_t x = 0; x < width; ++x) {
379 dst[dstIndex + width - x - 1] = src[srcIndex + x];
380 }
381 }
382 }
383
rotate90_argb8888(const uint32_t * src,uint32_t * dst,int32_t src_width,int32_t src_height,int32_t src_stride,int32_t dst_stride)384 static void rotate90_argb8888(const uint32_t * src, uint32_t * dst, int32_t src_width, int32_t src_height,
385 int32_t src_stride, int32_t dst_stride)
386 {
387 if(LV_RESULT_OK == LV_DRAW_SW_ROTATE270_ARGB8888(src, dst, src_width, src_height, src_stride, dst_stride)) {
388 return ;
389 }
390
391 src_stride /= sizeof(uint32_t);
392 dst_stride /= sizeof(uint32_t);
393
394 for(int32_t x = 0; x < src_width; ++x) {
395 int32_t dstIndex = (src_width - x - 1);
396 int32_t srcIndex = x;
397 for(int32_t y = 0; y < src_height; ++y) {
398 dst[dstIndex * dst_stride + y] = src[srcIndex];
399 srcIndex += src_stride;
400 }
401 }
402 }
403
404 #endif
405
406 #if LV_DRAW_SW_SUPPORT_RGB888
407
rotate90_rgb888(const uint8_t * src,uint8_t * dst,int32_t src_width,int32_t src_height,int32_t src_stride,int32_t dst_stride)408 static void rotate90_rgb888(const uint8_t * src, uint8_t * dst, int32_t src_width, int32_t src_height,
409 int32_t src_stride,
410 int32_t dst_stride)
411 {
412 if(LV_RESULT_OK == LV_DRAW_SW_ROTATE90_RGB888(src, dst, src_width, src_height, src_stride, dst_stride)) {
413 return ;
414 }
415
416 for(int32_t x = 0; x < src_width; ++x) {
417 for(int32_t y = 0; y < src_height; ++y) {
418 int32_t srcIndex = y * src_stride + x * 3;
419 int32_t dstIndex = (src_width - x - 1) * dst_stride + y * 3;
420 dst[dstIndex] = src[srcIndex]; /*Red*/
421 dst[dstIndex + 1] = src[srcIndex + 1]; /*Green*/
422 dst[dstIndex + 2] = src[srcIndex + 2]; /*Blue*/
423 }
424 }
425 }
426
rotate180_rgb888(const uint8_t * src,uint8_t * dst,int32_t width,int32_t height,int32_t src_stride,int32_t dest_stride)427 static void rotate180_rgb888(const uint8_t * src, uint8_t * dst, int32_t width, int32_t height, int32_t src_stride,
428 int32_t dest_stride)
429 {
430 if(LV_RESULT_OK == LV_DRAW_SW_ROTATE180_RGB888(src, dst, src_width, src_height, src_stride, dst_stride)) {
431 return ;
432 }
433
434 for(int32_t y = 0; y < height; ++y) {
435 for(int32_t x = 0; x < width; ++x) {
436 int32_t srcIndex = y * src_stride + x * 3;
437 int32_t dstIndex = (height - y - 1) * dest_stride + (width - x - 1) * 3;
438 dst[dstIndex] = src[srcIndex];
439 dst[dstIndex + 1] = src[srcIndex + 1];
440 dst[dstIndex + 2] = src[srcIndex + 2];
441 }
442 }
443 }
444
rotate270_rgb888(const uint8_t * src,uint8_t * dst,int32_t width,int32_t height,int32_t src_stride,int32_t dst_stride)445 static void rotate270_rgb888(const uint8_t * src, uint8_t * dst, int32_t width, int32_t height, int32_t src_stride,
446 int32_t dst_stride)
447 {
448 if(LV_RESULT_OK == LV_DRAW_SW_ROTATE270_RGB888(src, dst, src_width, src_height, src_stride, dst_stride)) {
449 return ;
450 }
451
452 for(int32_t x = 0; x < width; ++x) {
453 for(int32_t y = 0; y < height; ++y) {
454 int32_t srcIndex = y * src_stride + x * 3;
455 int32_t dstIndex = x * dst_stride + (height - y - 1) * 3;
456 dst[dstIndex] = src[srcIndex]; /*Red*/
457 dst[dstIndex + 1] = src[srcIndex + 1]; /*Green*/
458 dst[dstIndex + 2] = src[srcIndex + 2]; /*Blue*/
459 }
460 }
461 }
462
463 #endif
464
465 #if LV_DRAW_SW_SUPPORT_RGB565
466
rotate270_rgb565(const uint16_t * src,uint16_t * dst,int32_t src_width,int32_t src_height,int32_t src_stride,int32_t dst_stride)467 static void rotate270_rgb565(const uint16_t * src, uint16_t * dst, int32_t src_width, int32_t src_height,
468 int32_t src_stride,
469 int32_t dst_stride)
470 {
471 if(LV_RESULT_OK == LV_DRAW_SW_ROTATE90_RGB565(src, dst, src_width, src_height, src_stride, dst_stride)) {
472 return ;
473 }
474
475 src_stride /= sizeof(uint16_t);
476 dst_stride /= sizeof(uint16_t);
477
478 for(int32_t x = 0; x < src_width; ++x) {
479 int32_t dstIndex = x * dst_stride;
480 int32_t srcIndex = x;
481 for(int32_t y = 0; y < src_height; ++y) {
482 dst[dstIndex + (src_height - y - 1)] = src[srcIndex];
483 srcIndex += src_stride;
484 }
485 }
486 }
487
rotate180_rgb565(const uint16_t * src,uint16_t * dst,int32_t width,int32_t height,int32_t src_stride,int32_t dest_stride)488 static void rotate180_rgb565(const uint16_t * src, uint16_t * dst, int32_t width, int32_t height, int32_t src_stride,
489 int32_t dest_stride)
490 {
491 if(LV_RESULT_OK == LV_DRAW_SW_ROTATE180_RGB565(src, dst, width, height, src_stride)) {
492 return ;
493 }
494
495 src_stride /= sizeof(uint16_t);
496 dest_stride /= sizeof(uint16_t);
497
498 for(int32_t y = 0; y < height; ++y) {
499 int32_t dstIndex = (height - y - 1) * dest_stride;
500 int32_t srcIndex = y * src_stride;
501 for(int32_t x = 0; x < width; ++x) {
502 dst[dstIndex + width - x - 1] = src[srcIndex + x];
503 }
504 }
505 }
506
rotate90_rgb565(const uint16_t * src,uint16_t * dst,int32_t src_width,int32_t src_height,int32_t src_stride,int32_t dst_stride)507 static void rotate90_rgb565(const uint16_t * src, uint16_t * dst, int32_t src_width, int32_t src_height,
508 int32_t src_stride,
509 int32_t dst_stride)
510 {
511 if(LV_RESULT_OK == LV_DRAW_SW_ROTATE270_RGB565(src, dst, src_width, src_height, src_stride, dst_stride)) {
512 return ;
513 }
514
515 src_stride /= sizeof(uint16_t);
516 dst_stride /= sizeof(uint16_t);
517
518 for(int32_t x = 0; x < src_width; ++x) {
519 int32_t dstIndex = (src_width - x - 1);
520 int32_t srcIndex = x;
521 for(int32_t y = 0; y < src_height; ++y) {
522 dst[dstIndex * dst_stride + y] = src[srcIndex];
523 srcIndex += src_stride;
524 }
525 }
526 }
527
528 #endif
529
530
531 #if LV_DRAW_SW_SUPPORT_L8
532
rotate90_l8(const uint8_t * src,uint8_t * dst,int32_t src_width,int32_t src_height,int32_t src_stride,int32_t dst_stride)533 static void rotate90_l8(const uint8_t * src, uint8_t * dst, int32_t src_width, int32_t src_height,
534 int32_t src_stride,
535 int32_t dst_stride)
536 {
537 if(LV_RESULT_OK == LV_DRAW_SW_ROTATE270_L8(src, dst, src_width, src_height, src_stride, dst_stride)) {
538 return ;
539 }
540
541 for(int32_t x = 0; x < src_width; ++x) {
542 int32_t dstIndex = (src_width - x - 1);
543 int32_t srcIndex = x;
544 for(int32_t y = 0; y < src_height; ++y) {
545 dst[dstIndex * dst_stride + y] = src[srcIndex];
546 srcIndex += src_stride;
547 }
548 }
549 }
550
rotate180_l8(const uint8_t * src,uint8_t * dst,int32_t width,int32_t height,int32_t src_stride,int32_t dest_stride)551 static void rotate180_l8(const uint8_t * src, uint8_t * dst, int32_t width, int32_t height, int32_t src_stride,
552 int32_t dest_stride)
553 {
554 if(LV_RESULT_OK == LV_DRAW_SW_ROTATE180_L8(src, dst, width, height, src_stride)) {
555 return ;
556 }
557
558 for(int32_t y = 0; y < height; ++y) {
559 int32_t dstIndex = (height - y - 1) * dest_stride;
560 int32_t srcIndex = y * src_stride;
561 for(int32_t x = 0; x < width; ++x) {
562 dst[dstIndex + width - x - 1] = src[srcIndex + x];
563 }
564 }
565 }
566
rotate270_l8(const uint8_t * src,uint8_t * dst,int32_t src_width,int32_t src_height,int32_t src_stride,int32_t dst_stride)567 static void rotate270_l8(const uint8_t * src, uint8_t * dst, int32_t src_width, int32_t src_height,
568 int32_t src_stride,
569 int32_t dst_stride)
570 {
571 if(LV_RESULT_OK == LV_DRAW_SW_ROTATE90_L8(src, dst, src_width, src_height, src_stride, dst_stride)) {
572 return ;
573 }
574
575 for(int32_t x = 0; x < src_width; ++x) {
576 int32_t dstIndex = x * dst_stride;
577 int32_t srcIndex = x;
578 for(int32_t y = 0; y < src_height; ++y) {
579 dst[dstIndex + (src_height - y - 1)] = src[srcIndex];
580 srcIndex += src_stride;
581 }
582 }
583 }
584
585 #endif
586
587 #endif /*LV_USE_DRAW_SW*/
588