|
116 | 116 | #define RGB_BUS_ROTATION_270 (3) |
117 | 117 |
|
118 | 118 |
|
119 | | - __attribute__((always_inline)) static inline void rotate0(uint8_t *src, uint8_t *dst, uint32_t x_start, uint32_t y_start, uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, uint8_t bytes_per_pixel); |
120 | | - __attribute__((always_inline)) static inline void rotate_8bpp(uint8_t *src, uint8_t *dst, uint32_t x_start, uint32_t y_start, uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, uint8_t rotate); |
121 | | - __attribute__((always_inline)) static inline void rotate_16bpp(uint16_t *src, uint16_t *dst, uint32_t x_start, uint32_t y_start, uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, uint8_t rotate); |
122 | | - __attribute__((always_inline)) static inline void rotate_24bpp(uint8_t *src, uint8_t *dst, uint32_t x_start, uint32_t y_start, uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, uint8_t rotate); |
123 | | - __attribute__((always_inline)) static inline void rotate_32bpp(uint32_t *src, uint32_t *dst, uint32_t x_start, uint32_t y_start, uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, uint8_t rotate); |
| 119 | + static void rotate0(uint8_t *src, uint8_t *dst, uint32_t x_start, uint32_t y_start, |
| 120 | + uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, |
| 121 | + uint8_t bytes_per_pixel); |
124 | 122 |
|
| 123 | + static void rotate_8bpp(uint8_t *src, uint8_t *dst, uint32_t x_start, uint32_t y_start, |
| 124 | + uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, |
| 125 | + uint8_t rotate); |
125 | 126 |
|
126 | | - static void copy_pixels( |
127 | | - void *dst, void *src, uint32_t x_start, uint32_t y_start, |
128 | | - uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, |
129 | | - uint32_t bytes_per_pixel, uint8_t rotate); |
| 127 | + static void rotate_16bpp(uint16_t *src, uint16_t *dst, uint32_t x_start, uint32_t y_start, |
| 128 | + uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, |
| 129 | + uint8_t rotate); |
130 | 130 |
|
| 131 | + static void rotate_24bpp(uint8_t *src, uint8_t *dst, uint32_t x_start, uint32_t y_start, |
| 132 | + uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, |
| 133 | + uint8_t rotate); |
131 | 134 |
|
132 | | - static bool rgb_bus_trans_done_cb(esp_lcd_panel_handle_t panel, const esp_lcd_rgb_panel_event_data_t *edata, void *user_ctx) |
| 135 | + static void rotate_32bpp(uint32_t *src, uint32_t *dst, uint32_t x_start, uint32_t y_start, |
| 136 | + uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, |
| 137 | + uint8_t rotate); |
| 138 | + |
| 139 | + |
| 140 | + static void copy_pixels(void *dst, void *src, uint32_t x_start, uint32_t y_start, |
| 141 | + uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, |
| 142 | + uint32_t bytes_per_pixel, uint8_t rotate); |
| 143 | + |
| 144 | + |
| 145 | + static bool rgb_bus_trans_done_cb(esp_lcd_panel_handle_t panel, |
| 146 | + const esp_lcd_rgb_panel_event_data_t *edata, void *user_ctx) |
133 | 147 | { |
134 | 148 | LCD_UNUSED(edata); |
135 | 149 | mp_lcd_rgb_bus_obj_t *self = (mp_lcd_rgb_bus_obj_t *)user_ctx; |
|
294 | 308 |
|
295 | 309 |
|
296 | 310 | __attribute__((always_inline)) |
297 | | - static inline void copy_8bpp(uint8_t *to, const uint8_t *from) |
| 311 | + static inline void copy_8bpp(uint8_t *from, uint8_t *to) |
298 | 312 | { |
299 | 313 | *to++ = *from++; |
300 | 314 | } |
301 | 315 |
|
302 | 316 | __attribute__((always_inline)) |
303 | | - static inline void copy_16bpp(uint16_t *to, const uint16_t *from) |
| 317 | + static inline void copy_16bpp(uint16_t *from, uint16_t *to) |
304 | 318 | { |
305 | 319 | *to++ = *from++; |
306 | 320 | } |
307 | 321 |
|
308 | 322 | __attribute__((always_inline)) |
309 | | - static inline void copy_24bpp(uint8_t *to, const uint8_t *from) |
| 323 | + static inline void copy_24bpp(uint8_t *from, uint8_t *to) |
310 | 324 | { |
311 | 325 | *to++ = *from++; |
312 | 326 | *to++ = *from++; |
313 | 327 | *to++ = *from++; |
314 | 328 | } |
315 | 329 |
|
316 | 330 | __attribute__((always_inline)) |
317 | | - static inline void copy_32bpp(uint32_t *to, const uint32_t *from) |
| 331 | + static inline void copy_32bpp(uint32_t *from, uint32_t *to) |
318 | 332 | { |
319 | 333 | *to++ = *from++; |
320 | 334 | } |
|
354 | 368 | } |
355 | 369 |
|
356 | 370 |
|
357 | | - void rotate0(uint8_t *src, uint8_t *dst, uint32_t x_start, uint32_t y_start, uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, uint8_t bytes_per_pixel) |
| 371 | + void rotate0(uint8_t *src, uint8_t *dst, uint32_t x_start, uint32_t y_start, |
| 372 | + uint32_t x_end, uint32_t y_end, uint32_t dst_width, |
| 373 | + uint32_t dst_height, uint8_t bytes_per_pixel) |
358 | 374 | { |
359 | 375 | dst += ((y_start * dst_width + x_start) * bytes_per_pixel); |
360 | 376 |
|
|
372 | 388 | } |
373 | 389 | } |
374 | 390 |
|
375 | | - void rotate_8bpp(uint8_t *src, uint8_t *dst, uint32_t x_start, uint32_t y_start, uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, uint8_t rotate) |
| 391 | + void rotate_8bpp(uint8_t *src, uint8_t *dst, uint32_t x_start, uint32_t y_start, |
| 392 | + uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, |
| 393 | + uint8_t rotate) |
376 | 394 | { |
377 | | - uint32_t j; |
378 | 395 | uint32_t i; |
| 396 | + uint32_t j; |
379 | 397 |
|
380 | 398 | uint32_t src_bytes_per_line = x_end - x_start + 1; |
381 | 399 | uint32_t offset = y_start * src_bytes_per_line + x_start; |
|
384 | 402 | case RGB_BUS_ROTATION_90: |
385 | 403 | for (uint32_t y = y_start; y < y_end; y++) { |
386 | 404 | for (uint32_t x = x_start; x < x_end; x++) { |
387 | | - j = y * src_bytes_per_line + x - offset; |
388 | | - i = (dst_height - 1 - x) * dst_width + y; |
389 | | - copy_8bpp(dst + i, src + j); |
| 405 | + i = y * src_bytes_per_line + x - offset; |
| 406 | + j = (dst_height - 1 - x) * dst_width + y; |
| 407 | + copy_8bpp(src + i, dst + j); |
390 | 408 | } |
391 | 409 | } |
392 | 410 | break; |
|
400 | 418 | for (uint32_t y = y_start; y < y_end; y++) { |
401 | 419 | i = (dst_height - 1 - y) * dst_width + (dst_width - 1 - x_start); |
402 | 420 | for (uint32_t x = x_start; x < x_end; x++) { |
403 | | - copy_8bpp(dst + i, src); |
| 421 | + copy_8bpp(src, dst + i); |
404 | 422 | src++; |
405 | 423 | i--; |
406 | 424 | } |
|
411 | 429 | case RGB_BUS_ROTATION_270: |
412 | 430 | for (uint32_t y = y_start; y < y_end; y++) { |
413 | 431 | for (uint32_t x = x_start; x < x_end; x++) { |
414 | | - j = y * src_bytes_per_line + x - offset; |
415 | | - i = x * dst_width + dst_width - 1 - y; |
416 | | - copy_8bpp(dst + i, src + j); |
| 432 | + i = y * src_bytes_per_line + x - offset; |
| 433 | + j = x * dst_width + dst_width - 1 - y; |
| 434 | + copy_8bpp(src + i, dst + j); |
417 | 435 | } |
418 | 436 | } |
419 | 437 | break; |
|
429 | 447 | } |
430 | 448 |
|
431 | 449 |
|
432 | | - void rotate_16bpp(uint16_t *src, uint16_t *dst, uint32_t x_start, uint32_t y_start, uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, uint8_t rotate) |
| 450 | + void rotate_16bpp(uint16_t *src, uint16_t *dst, uint32_t x_start, uint32_t y_start, |
| 451 | + uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, |
| 452 | + uint8_t rotate) |
433 | 453 | { |
434 | | - uint32_t j; |
435 | 454 | uint32_t i; |
| 455 | + uint32_t j; |
436 | 456 |
|
437 | 457 | uint32_t src_bytes_per_line = x_end - x_start + 1; |
438 | 458 | uint32_t offset = y_start * src_bytes_per_line + x_start; |
|
441 | 461 | case RGB_BUS_ROTATION_90: |
442 | 462 | for (uint32_t y = y_start; y < y_end; y++) { |
443 | 463 | for (uint32_t x = x_start; x < x_end; x++) { |
444 | | - j = y * src_bytes_per_line + x - offset; |
445 | | - i = (dst_height - 1 - x) * dst_width + y; |
446 | | - copy_16bpp(dst + i, src + j); |
| 464 | + i = y * src_bytes_per_line + x - offset; |
| 465 | + j = (dst_height - 1 - x) * dst_width + y; |
| 466 | + copy_16bpp(src + i, dst + j); |
447 | 467 | } |
448 | 468 | } |
449 | 469 | break; |
|
457 | 477 | for (uint32_t y = y_start; y < y_end; y++) { |
458 | 478 | i = (dst_height - 1 - y) * dst_width + (dst_width - 1 - x_start); |
459 | 479 | for (uint32_t x = x_start; x < x_end; x++) { |
460 | | - copy_16bpp(dst + i, src); |
| 480 | + copy_16bpp(src, dst + i); |
461 | 481 | src++; |
462 | 482 | i--; |
463 | 483 | } |
|
468 | 488 | case RGB_BUS_ROTATION_270: |
469 | 489 | for (uint32_t y = y_start; y < y_end; y++) { |
470 | 490 | for (uint32_t x = x_start; x < x_end; x++) { |
471 | | - j = y * src_bytes_per_line + x - offset; |
472 | | - i = (x * dst_width + dst_width - 1 - y); |
473 | | - copy_16bpp(dst + i, src + j); |
| 491 | + i = y * src_bytes_per_line + x - offset; |
| 492 | + j = (x * dst_width + dst_width - 1 - y); |
| 493 | + copy_16bpp(src + i, dst + j); |
474 | 494 | } |
475 | 495 | } |
476 | 496 | break; |
|
485 | 505 | } |
486 | 506 |
|
487 | 507 |
|
488 | | - void rotate_24bpp(uint8_t *src, uint8_t *dst, uint32_t x_start, uint32_t y_start, uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, uint8_t rotate) |
| 508 | + void rotate_24bpp(uint8_t *src, uint8_t *dst, uint32_t x_start, uint32_t y_start, |
| 509 | + uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, |
| 510 | + uint8_t rotate) |
489 | 511 | { |
490 | | - uint32_t j; |
491 | 512 | uint32_t i; |
| 513 | + uint32_t j; |
492 | 514 |
|
493 | 515 | uint32_t src_bytes_per_line = (x_end - x_start + 1) * 3; |
494 | 516 | uint32_t offset = y_start * src_bytes_per_line + x_start * 3; |
|
498 | 520 | case RGB_BUS_ROTATION_90: |
499 | 521 | for (uint32_t y = y_start; y < y_end; y++) { |
500 | 522 | for (uint32_t x = x_start; x < x_end; x++) { |
501 | | - j = y * src_bytes_per_line + x * 3 - offset; |
502 | | - i = ((dst_height - 1 - x) * dst_width + y) * 3; |
503 | | - copy_24bpp(dst + i, src + j); |
| 523 | + i = y * src_bytes_per_line + x * 3 - offset; |
| 524 | + j = ((dst_height - 1 - x) * dst_width + y) * 3; |
| 525 | + copy_24bpp(src + i, dst + j); |
504 | 526 | } |
505 | 527 | } |
506 | 528 | break; |
|
514 | 536 | for (int y = y_start; y < y_end; y++) { |
515 | 537 | i = ((dst_height - 1 - y) * dst_width + (dst_width - 1 - x_start)) * 3; |
516 | 538 | for (size_t x = x_start; x < x_end; x++) { |
517 | | - copy_24bpp(dst + i, src); |
| 539 | + copy_24bpp(src, dst + i); |
518 | 540 | src += 3; |
519 | 541 | i -= 3; |
520 | 542 | } |
|
525 | 547 | case RGB_BUS_ROTATION_270: |
526 | 548 | for (uint32_t y = y_start; y < y_end; y++) { |
527 | 549 | for (uint32_t x = x_start; x < x_end; x++) { |
528 | | - j = y * src_bytes_per_line + x * 3 - offset; |
529 | | - i = (x * dst_width + dst_width - 1 - y) * 3; |
530 | | - copy_24bpp(dst + i, src + j); |
| 550 | + i = y * src_bytes_per_line + x * 3 - offset; |
| 551 | + j = (x * dst_width + dst_width - 1 - y) * 3; |
| 552 | + copy_24bpp(src + i, dst + j); |
531 | 553 | } |
532 | 554 | } |
533 | 555 | break; |
|
542 | 564 | } |
543 | 565 |
|
544 | 566 |
|
545 | | - void rotate_32bpp(uint32_t *src, uint32_t *dst, uint32_t x_start, uint32_t y_start, uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, uint8_t rotate) |
| 567 | + void rotate_32bpp(uint32_t *src, uint32_t *dst, uint32_t x_start, uint32_t y_start, |
| 568 | + uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, |
| 569 | + uint8_t rotate) |
546 | 570 | { |
547 | | - uint32_t j; |
548 | 571 | uint32_t i; |
| 572 | + uint32_t j; |
549 | 573 |
|
550 | 574 | uint32_t src_bytes_per_line = x_end - x_start + 1; |
551 | 575 | uint32_t offset = y_start * src_bytes_per_line + x_start; |
|
554 | 578 | case RGB_BUS_ROTATION_90: |
555 | 579 | for (uint32_t y = y_start; y < y_end; y++) { |
556 | 580 | for (uint32_t x = x_start; x < x_end; x++) { |
557 | | - j = y * src_bytes_per_line + x - offset; |
558 | | - i = (dst_height - 1 - x) * dst_width + y; |
559 | | - copy_32bpp(dst + i, src + j); |
| 581 | + i = y * src_bytes_per_line + x - offset; |
| 582 | + j = (dst_height - 1 - x) * dst_width + y; |
| 583 | + copy_32bpp(src + i, dst + j); |
560 | 584 | } |
561 | 585 | } |
562 | 586 | break; |
|
570 | 594 | for (uint32_t y = y_start; y < y_end; y++) { |
571 | 595 | i = (dst_height - 1 - y) * dst_width + (dst_width - 1 - x_start); |
572 | 596 | for (uint32_t x = x_start; x < x_end; x++) { |
573 | | - copy_32bpp(dst + i, src); |
| 597 | + copy_32bpp(src, dst + i); |
574 | 598 | src++; |
575 | 599 | i--; |
576 | 600 | } |
|
581 | 605 | case RGB_BUS_ROTATION_270: |
582 | 606 | for (uint32_t y = y_start; y < y_end; y++) { |
583 | 607 | for (uint32_t x = x_start; x < x_end; x++) { |
584 | | - j = y * src_bytes_per_line + x - offset; |
585 | | - i = x * dst_width + dst_width - 1 - y; |
586 | | - copy_32bpp(dst + i, src + j); |
| 608 | + i = y * src_bytes_per_line + x - offset; |
| 609 | + j = x * dst_width + dst_width - 1 - y; |
| 610 | + copy_32bpp(src + i, dst + j); |
587 | 611 | } |
588 | 612 | } |
589 | 613 | break; |
|
0 commit comments