summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-06-30 18:42:24 +0000
committerJens Arnold <amiconn@rockbox.org>2005-06-30 18:42:24 +0000
commita142d4d79fe84dd4e75f3cb01d25e4cee945036b (patch)
tree376eaba480f295f6fde5976ded9792bd5e6b57a9
parent3b90707fdd85a4b21258f6e11f10e15e0f668e3d (diff)
downloadrockbox-a142d4d79fe84dd4e75f3cb01d25e4cee945036b.tar.gz
rockbox-a142d4d79fe84dd4e75f3cb01d25e4cee945036b.zip
Graphics: Lowlevel block function are in IRAM now as they're called often. Switched the masking logic for better readability. Draw modes and lowlevel function types are now defined for all platforms.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6952 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/drivers/lcd-h100-remote.c32
-rw-r--r--firmware/drivers/lcd-h100.c32
-rw-r--r--firmware/drivers/lcd-recorder.c32
-rw-r--r--firmware/export/lcd.h16
4 files changed, 81 insertions, 31 deletions
diff --git a/firmware/drivers/lcd-h100-remote.c b/firmware/drivers/lcd-h100-remote.c
index bdc5799726..8112aecdb1 100644
--- a/firmware/drivers/lcd-h100-remote.c
+++ b/firmware/drivers/lcd-h100-remote.c
@@ -500,41 +500,57 @@ lcd_pixelfunc_type* lcd_remote_pixelfuncs[8] = {
500}; 500};
501 501
502static void flipblock(unsigned char *address, unsigned mask, unsigned bits) 502static void flipblock(unsigned char *address, unsigned mask, unsigned bits)
503 __attribute__ ((section(".icode")));
504static void flipblock(unsigned char *address, unsigned mask, unsigned bits)
503{ 505{
504 *address ^= (bits & mask); 506 *address ^= (bits & mask);
505} 507}
506 508
507static void bgblock(unsigned char *address, unsigned mask, unsigned bits) 509static void bgblock(unsigned char *address, unsigned mask, unsigned bits)
510 __attribute__ ((section(".icode")));
511static void bgblock(unsigned char *address, unsigned mask, unsigned bits)
508{ 512{
509 *address &= (bits | ~mask); 513 *address &= (bits | ~mask);
510} 514}
511 515
512static void fgblock(unsigned char *address, unsigned mask, unsigned bits) 516static void fgblock(unsigned char *address, unsigned mask, unsigned bits)
517 __attribute__ ((section(".icode")));
518static void fgblock(unsigned char *address, unsigned mask, unsigned bits)
513{ 519{
514 *address |= (bits & mask); 520 *address |= (bits & mask);
515} 521}
516 522
517static void solidblock(unsigned char *address, unsigned mask, unsigned bits) 523static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
524 __attribute__ ((section(".icode")));
525static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
518{ 526{
519 *address = (*address & ~mask) | (bits & mask); 527 *address = (*address & ~mask) | (bits & mask);
520} 528}
521 529
522static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits) 530static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits)
531 __attribute__ ((section(".icode")));
532static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits)
523{ 533{
524 *address ^= (~bits & mask); 534 *address ^= (~bits & mask);
525} 535}
526 536
527static void bginvblock(unsigned char *address, unsigned mask, unsigned bits) 537static void bginvblock(unsigned char *address, unsigned mask, unsigned bits)
538 __attribute__ ((section(".icode")));
539static void bginvblock(unsigned char *address, unsigned mask, unsigned bits)
528{ 540{
529 *address &= ~(bits & mask); 541 *address &= ~(bits & mask);
530} 542}
531 543
532static void fginvblock(unsigned char *address, unsigned mask, unsigned bits) 544static void fginvblock(unsigned char *address, unsigned mask, unsigned bits)
545 __attribute__ ((section(".icode")));
546static void fginvblock(unsigned char *address, unsigned mask, unsigned bits)
533{ 547{
534 *address |= (~bits & mask); 548 *address |= (~bits & mask);
535} 549}
536 550
537static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits) 551static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
552 __attribute__ ((section(".icode")));
553static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
538{ 554{
539 *address = (*address & ~mask) | (~bits & mask); 555 *address = (*address & ~mask) | (~bits & mask);
540} 556}
@@ -707,8 +723,8 @@ void lcd_remote_vline(int x, int y1, int y2)
707 dst += LCD_REMOTE_WIDTH; 723 dst += LCD_REMOTE_WIDTH;
708 mask = 0xFFu; 724 mask = 0xFFu;
709 } 725 }
710 mask_bottom &= mask; 726 mask &= mask_bottom;
711 bfunc(dst, mask_bottom, 0xFFu); 727 bfunc(dst, mask, 0xFFu);
712} 728}
713 729
714/* Draw a rectangular box */ 730/* Draw a rectangular box */
@@ -782,14 +798,14 @@ void lcd_remote_fillrect(int x, int y, int width, int height)
782 dst += LCD_REMOTE_WIDTH; 798 dst += LCD_REMOTE_WIDTH;
783 mask = 0xFFu; 799 mask = 0xFFu;
784 } 800 }
785 mask_bottom &= mask; 801 mask &= mask_bottom;
786 802
787 if (fillopt && (mask_bottom == 0xFFu)) 803 if (fillopt && (mask == 0xFFu))
788 memset(dst, bits, width); 804 memset(dst, bits, width);
789 else 805 else
790 { 806 {
791 for (i = width; i > 0; i--) 807 for (i = width; i > 0; i--)
792 bfunc(dst++, mask_bottom, 0xFFu); 808 bfunc(dst++, mask, 0xFFu);
793 } 809 }
794} 810}
795 811
@@ -871,14 +887,14 @@ void lcd_remote_bitmap_part(const unsigned char *src, int src_x, int src_y,
871 dst += LCD_REMOTE_WIDTH; 887 dst += LCD_REMOTE_WIDTH;
872 mask = 0xFFu; 888 mask = 0xFFu;
873 } 889 }
874 mask_bottom &= mask; 890 mask &= mask_bottom;
875 891
876 if (copyopt && (mask_bottom == 0xFFu)) 892 if (copyopt && (mask == 0xFFu))
877 memcpy(dst, src, width); 893 memcpy(dst, src, width);
878 else 894 else
879 { 895 {
880 for (i = width; i > 0; i--) 896 for (i = width; i > 0; i--)
881 bfunc(dst++, mask_bottom, *src++); 897 bfunc(dst++, mask, *src++);
882 } 898 }
883 } 899 }
884 else 900 else
diff --git a/firmware/drivers/lcd-h100.c b/firmware/drivers/lcd-h100.c
index 929a4fa301..3d858e2271 100644
--- a/firmware/drivers/lcd-h100.c
+++ b/firmware/drivers/lcd-h100.c
@@ -339,41 +339,57 @@ lcd_pixelfunc_type* lcd_pixelfuncs[8] = {
339}; 339};
340 340
341static void flipblock(unsigned char *address, unsigned mask, unsigned bits) 341static void flipblock(unsigned char *address, unsigned mask, unsigned bits)
342 __attribute__ ((section(".icode")));
343static void flipblock(unsigned char *address, unsigned mask, unsigned bits)
342{ 344{
343 *address ^= (bits & mask); 345 *address ^= (bits & mask);
344} 346}
345 347
346static void bgblock(unsigned char *address, unsigned mask, unsigned bits) 348static void bgblock(unsigned char *address, unsigned mask, unsigned bits)
349 __attribute__ ((section(".icode")));
350static void bgblock(unsigned char *address, unsigned mask, unsigned bits)
347{ 351{
348 *address &= (bits | ~mask); 352 *address &= (bits | ~mask);
349} 353}
350 354
351static void fgblock(unsigned char *address, unsigned mask, unsigned bits) 355static void fgblock(unsigned char *address, unsigned mask, unsigned bits)
356 __attribute__ ((section(".icode")));
357static void fgblock(unsigned char *address, unsigned mask, unsigned bits)
352{ 358{
353 *address |= (bits & mask); 359 *address |= (bits & mask);
354} 360}
355 361
356static void solidblock(unsigned char *address, unsigned mask, unsigned bits) 362static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
363 __attribute__ ((section(".icode")));
364static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
357{ 365{
358 *address = (*address & ~mask) | (bits & mask); 366 *address = (*address & ~mask) | (bits & mask);
359} 367}
360 368
361static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits) 369static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits)
370 __attribute__ ((section(".icode")));
371static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits)
362{ 372{
363 *address ^= (~bits & mask); 373 *address ^= (~bits & mask);
364} 374}
365 375
366static void bginvblock(unsigned char *address, unsigned mask, unsigned bits) 376static void bginvblock(unsigned char *address, unsigned mask, unsigned bits)
377 __attribute__ ((section(".icode")));
378static void bginvblock(unsigned char *address, unsigned mask, unsigned bits)
367{ 379{
368 *address &= ~(bits & mask); 380 *address &= ~(bits & mask);
369} 381}
370 382
371static void fginvblock(unsigned char *address, unsigned mask, unsigned bits) 383static void fginvblock(unsigned char *address, unsigned mask, unsigned bits)
384 __attribute__ ((section(".icode")));
385static void fginvblock(unsigned char *address, unsigned mask, unsigned bits)
372{ 386{
373 *address |= (~bits & mask); 387 *address |= (~bits & mask);
374} 388}
375 389
376static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits) 390static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
391 __attribute__ ((section(".icode")));
392static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
377{ 393{
378 *address = (*address & ~mask) | (~bits & mask); 394 *address = (*address & ~mask) | (~bits & mask);
379} 395}
@@ -544,8 +560,8 @@ void lcd_vline(int x, int y1, int y2)
544 dst += LCD_WIDTH; 560 dst += LCD_WIDTH;
545 mask = 0xFFu; 561 mask = 0xFFu;
546 } 562 }
547 mask_bottom &= mask; 563 mask &= mask_bottom;
548 bfunc(dst, mask_bottom, 0xFFu); 564 bfunc(dst, mask, 0xFFu);
549} 565}
550 566
551/* Draw a rectangular box */ 567/* Draw a rectangular box */
@@ -619,14 +635,14 @@ void lcd_fillrect(int x, int y, int width, int height)
619 dst += LCD_WIDTH; 635 dst += LCD_WIDTH;
620 mask = 0xFFu; 636 mask = 0xFFu;
621 } 637 }
622 mask_bottom &= mask; 638 mask &= mask_bottom;
623 639
624 if (fillopt && (mask_bottom == 0xFFu)) 640 if (fillopt && (mask == 0xFFu))
625 memset(dst, bits, width); 641 memset(dst, bits, width);
626 else 642 else
627 { 643 {
628 for (i = width; i > 0; i--) 644 for (i = width; i > 0; i--)
629 bfunc(dst++, mask_bottom, 0xFFu); 645 bfunc(dst++, mask, 0xFFu);
630 } 646 }
631} 647}
632 648
@@ -708,14 +724,14 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
708 dst += LCD_WIDTH; 724 dst += LCD_WIDTH;
709 mask = 0xFFu; 725 mask = 0xFFu;
710 } 726 }
711 mask_bottom &= mask; 727 mask &= mask_bottom;
712 728
713 if (copyopt && (mask_bottom == 0xFFu)) 729 if (copyopt && (mask == 0xFFu))
714 memcpy(dst, src, width); 730 memcpy(dst, src, width);
715 else 731 else
716 { 732 {
717 for (i = width; i > 0; i--) 733 for (i = width; i > 0; i--)
718 bfunc(dst++, mask_bottom, *src++); 734 bfunc(dst++, mask, *src++);
719 } 735 }
720 } 736 }
721 else 737 else
diff --git a/firmware/drivers/lcd-recorder.c b/firmware/drivers/lcd-recorder.c
index 6747f7fcd3..f933e6ca5c 100644
--- a/firmware/drivers/lcd-recorder.c
+++ b/firmware/drivers/lcd-recorder.c
@@ -396,41 +396,57 @@ lcd_pixelfunc_type* lcd_pixelfuncs[8] = {
396}; 396};
397 397
398static void flipblock(unsigned char *address, unsigned mask, unsigned bits) 398static void flipblock(unsigned char *address, unsigned mask, unsigned bits)
399 __attribute__ ((section(".icode")));
400static void flipblock(unsigned char *address, unsigned mask, unsigned bits)
399{ 401{
400 *address ^= (bits & mask); 402 *address ^= (bits & mask);
401} 403}
402 404
403static void bgblock(unsigned char *address, unsigned mask, unsigned bits) 405static void bgblock(unsigned char *address, unsigned mask, unsigned bits)
406 __attribute__ ((section(".icode")));
407static void bgblock(unsigned char *address, unsigned mask, unsigned bits)
404{ 408{
405 *address &= (bits | ~mask); 409 *address &= (bits | ~mask);
406} 410}
407 411
408static void fgblock(unsigned char *address, unsigned mask, unsigned bits) 412static void fgblock(unsigned char *address, unsigned mask, unsigned bits)
413 __attribute__ ((section(".icode")));
414static void fgblock(unsigned char *address, unsigned mask, unsigned bits)
409{ 415{
410 *address |= (bits & mask); 416 *address |= (bits & mask);
411} 417}
412 418
413static void solidblock(unsigned char *address, unsigned mask, unsigned bits) 419static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
420 __attribute__ ((section(".icode")));
421static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
414{ 422{
415 *address = (*address & ~mask) | (bits & mask); 423 *address = (*address & ~mask) | (bits & mask);
416} 424}
417 425
418static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits) 426static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits)
427 __attribute__ ((section(".icode")));
428static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits)
419{ 429{
420 *address ^= (~bits & mask); 430 *address ^= (~bits & mask);
421} 431}
422 432
423static void bginvblock(unsigned char *address, unsigned mask, unsigned bits) 433static void bginvblock(unsigned char *address, unsigned mask, unsigned bits)
434 __attribute__ ((section(".icode")));
435static void bginvblock(unsigned char *address, unsigned mask, unsigned bits)
424{ 436{
425 *address &= ~(bits & mask); 437 *address &= ~(bits & mask);
426} 438}
427 439
428static void fginvblock(unsigned char *address, unsigned mask, unsigned bits) 440static void fginvblock(unsigned char *address, unsigned mask, unsigned bits)
441 __attribute__ ((section(".icode")));
442static void fginvblock(unsigned char *address, unsigned mask, unsigned bits)
429{ 443{
430 *address |= (~bits & mask); 444 *address |= (~bits & mask);
431} 445}
432 446
433static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits) 447static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
448 __attribute__ ((section(".icode")));
449static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
434{ 450{
435 *address = (*address & ~mask) | (~bits & mask); 451 *address = (*address & ~mask) | (~bits & mask);
436} 452}
@@ -601,8 +617,8 @@ void lcd_vline(int x, int y1, int y2)
601 dst += LCD_WIDTH; 617 dst += LCD_WIDTH;
602 mask = 0xFFu; 618 mask = 0xFFu;
603 } 619 }
604 mask_bottom &= mask; 620 mask &= mask_bottom;
605 bfunc(dst, mask_bottom, 0xFFu); 621 bfunc(dst, mask, 0xFFu);
606} 622}
607 623
608/* Draw a rectangular box */ 624/* Draw a rectangular box */
@@ -676,14 +692,14 @@ void lcd_fillrect(int x, int y, int width, int height)
676 dst += LCD_WIDTH; 692 dst += LCD_WIDTH;
677 mask = 0xFFu; 693 mask = 0xFFu;
678 } 694 }
679 mask_bottom &= mask; 695 mask &= mask_bottom;
680 696
681 if (fillopt && (mask_bottom == 0xFFu)) 697 if (fillopt && (mask == 0xFFu))
682 memset(dst, bits, width); 698 memset(dst, bits, width);
683 else 699 else
684 { 700 {
685 for (i = width; i > 0; i--) 701 for (i = width; i > 0; i--)
686 bfunc(dst++, mask_bottom, 0xFFu); 702 bfunc(dst++, mask, 0xFFu);
687 } 703 }
688} 704}
689 705
@@ -765,14 +781,14 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
765 dst += LCD_WIDTH; 781 dst += LCD_WIDTH;
766 mask = 0xFFu; 782 mask = 0xFFu;
767 } 783 }
768 mask_bottom &= mask; 784 mask &= mask_bottom;
769 785
770 if (copyopt && (mask_bottom == 0xFFu)) 786 if (copyopt && (mask == 0xFFu))
771 memcpy(dst, src, width); 787 memcpy(dst, src, width);
772 else 788 else
773 { 789 {
774 for (i = width; i > 0; i--) 790 for (i = width; i > 0; i--)
775 bfunc(dst++, mask_bottom, *src++); 791 bfunc(dst++, mask, *src++);
776 } 792 }
777 } 793 }
778 else 794 else
diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h
index 77e79799f8..5f93e7cbc3 100644
--- a/firmware/export/lcd.h
+++ b/firmware/export/lcd.h
@@ -113,22 +113,23 @@ extern void lcd_jump_scroll(int mode); /* 0=off, 1=once, ..., ALWAYS */
113extern void lcd_jump_scroll_delay(int ms); 113extern void lcd_jump_scroll_delay(int ms);
114#endif 114#endif
115 115
116#if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR) 116/* Draw modes */
117
118/* draw modes */
119#define DRMODE_COMPLEMENT 0 117#define DRMODE_COMPLEMENT 0
120#define DRMODE_BG 1 118#define DRMODE_BG 1
121#define DRMODE_FG 2 119#define DRMODE_FG 2
122#define DRMODE_SOLID 3 120#define DRMODE_SOLID 3
123#define DRMODE_INVERSEVID 4 /* used as bit modifier for basic modes */ 121#define DRMODE_INVERSEVID 4 /* used as bit modifier for basic modes */
124 122
123/* Low-level drawing function types */
124typedef void lcd_pixelfunc_type(int x, int y); /* for b&w */
125typedef void lcd_blockfunc_type(unsigned char *address, unsigned mask, unsigned bits);
126
127#if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR)
128
125#define DRAW_PIXEL(x,y) lcd_framebuffer[(y)>>3][(x)] |= (1<<((y)&7)) 129#define DRAW_PIXEL(x,y) lcd_framebuffer[(y)>>3][(x)] |= (1<<((y)&7))
126#define CLEAR_PIXEL(x,y) lcd_framebuffer[(y)>>3][(x)] &= ~(1<<((y)&7)) 130#define CLEAR_PIXEL(x,y) lcd_framebuffer[(y)>>3][(x)] &= ~(1<<((y)&7))
127#define INVERT_PIXEL(x,y) lcd_framebuffer[(y)>>3][(x)] ^= (1<<((y)&7)) 131#define INVERT_PIXEL(x,y) lcd_framebuffer[(y)>>3][(x)] ^= (1<<((y)&7))
128 132
129typedef void lcd_pixelfunc_type(int x, int y); /* for b&w */
130typedef void lcd_blockfunc_type(unsigned char *address, unsigned mask, unsigned bits);
131
132/* Memory copy of display bitmap */ 133/* Memory copy of display bitmap */
133extern unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH]; 134extern unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH];
134 135
@@ -156,7 +157,8 @@ extern void lcd_drawrect(int x, int y, int width, int height);
156extern void lcd_fillrect(int x, int y, int width, int height); 157extern void lcd_fillrect(int x, int y, int width, int height);
157extern void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y, 158extern void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
158 int stride, int x, int y, int width, int height); 159 int stride, int x, int y, int width, int height);
159extern void lcd_bitmap(const unsigned char *src, int x, int y, int nx, int ny); 160extern void lcd_bitmap(const unsigned char *src, int x, int y, int width,
161 int height);
160extern void lcd_putsxy(int x, int y, const unsigned char *string); 162extern void lcd_putsxy(int x, int y, const unsigned char *string);
161 163
162extern void lcd_invertscroll(int x, int y); 164extern void lcd_invertscroll(int x, int y);