- Timestamp:
- 2006-06-07T14:12:53Z (20 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 70178b74
- Parents:
- b7e9c34
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fb/fb.c
rb7e9c34 r1fd7700 82 82 int cursor_shown; 83 83 } viewport_t; 84 85 #define MAX_ANIM_LEN 8 86 #define MAX_ANIMATIONS 4 87 typedef struct { 88 int initialized; 89 int enabled; 90 unsigned int vp; 91 92 unsigned int pos; 93 unsigned int animlen; 94 unsigned int pixmaps[MAX_ANIM_LEN]; 95 } animation_t; 96 static animation_t animations[MAX_ANIMATIONS]; 97 static int anims_enabled; 84 98 85 99 /** Maximum number of saved pixmaps … … 321 335 int i; 322 336 323 for (i=0; i < MAX_VIEWPORTS; i++) {337 for (i=0; i < MAX_VIEWPORTS; i++) { 324 338 if (!viewports[i].initialized) 325 339 break; … … 702 716 } 703 717 718 /** Tick animation one step forward */ 719 static void anims_tick(void) 720 { 721 int i; 722 static int counts = 0; 723 724 /* Limit redrawing */ 725 counts = (counts+1) % 8; 726 if (counts) 727 return; 728 729 for (i=0; i < MAX_ANIMATIONS; i++) { 730 if (!animations[i].animlen || !animations[i].initialized || !animations[i].enabled) 731 continue; 732 draw_pixmap(animations[i].vp, animations[i].pixmaps[animations[i].pos]); 733 animations[i].pos = (animations[i].pos+1) % animations[i].animlen; 734 } 735 } 736 737 static int anim_handle(ipc_callid_t callid, ipc_call_t *call, int vp) 738 { 739 int handled = 1; 740 int retval = 0; 741 int i,nvp; 742 int newval; 743 744 switch (IPC_GET_METHOD(*call)) { 745 case FB_ANIM_CREATE: 746 nvp = IPC_GET_ARG1(*call); 747 if (nvp == -1) 748 nvp = vp; 749 if (nvp >= MAX_VIEWPORTS || nvp < 0 || !viewports[nvp].initialized) { 750 retval = EINVAL; 751 break; 752 } 753 for (i=0; i < MAX_ANIMATIONS; i++) { 754 if (! animations[i].initialized) 755 break; 756 } 757 if (i == MAX_ANIMATIONS) { 758 retval = ELIMIT; 759 break; 760 } 761 animations[i].initialized = 1; 762 animations[i].animlen = 0; 763 animations[i].pos = 0; 764 animations[i].enabled = 0; 765 animations[i].vp = nvp; 766 retval = i; 767 break; 768 case FB_ANIM_DROP: 769 i = IPC_GET_ARG1(*call); 770 if (nvp >= MAX_ANIMATIONS || i < 0) { 771 retval = EINVAL; 772 break; 773 } 774 animations[i].initialized = 0; 775 break; 776 case FB_ANIM_ADDPIXMAP: 777 i = IPC_GET_ARG1(*call); 778 if (i >= MAX_ANIMATIONS || i < 0 || !animations[i].initialized) { 779 retval = EINVAL; 780 break; 781 } 782 if (animations[i].animlen == MAX_ANIM_LEN) { 783 retval = ELIMIT; 784 break; 785 } 786 newval = IPC_GET_ARG2(*call); 787 if (newval < 0 || newval > MAX_PIXMAPS || !pixmaps[newval].data) { 788 retval = EINVAL; 789 break; 790 } 791 animations[i].pixmaps[animations[i].animlen++] = newval; 792 break; 793 case FB_ANIM_CHGVP: 794 i = IPC_GET_ARG1(*call); 795 if (i >= MAX_ANIMATIONS || i < 0) { 796 retval = EINVAL; 797 break; 798 } 799 nvp = IPC_GET_ARG2(*call); 800 if (nvp == -1) 801 nvp = vp; 802 if (nvp >= MAX_VIEWPORTS || nvp < 0 || !viewports[nvp].initialized) { 803 retval = EINVAL; 804 break; 805 } 806 animations[i].vp = nvp; 807 break; 808 case FB_ANIM_START: 809 case FB_ANIM_STOP: 810 i = IPC_GET_ARG1(*call); 811 if (i >= MAX_ANIMATIONS || i < 0) { 812 retval = EINVAL; 813 break; 814 } 815 newval = (IPC_GET_METHOD(*call) == FB_ANIM_START); 816 if (newval ^ animations[i].enabled) { 817 animations[i].enabled = newval; 818 anims_enabled += newval ? 1 : -1; 819 } 820 break; 821 default: 822 handled = 0; 823 } 824 if (handled) 825 ipc_answer_fast(callid, retval, 0, 0); 826 return handled; 827 } 828 704 829 /** Handler for messages concerning pixmap handling */ 705 830 static int pixmap_handle(ipc_callid_t callid, ipc_call_t *call, int vp) … … 774 899 775 900 while (1) { 776 if (vport->cursor_ shown)901 if (vport->cursor_active || anims_enabled) 777 902 callid = async_get_call_timeout(&call,250000); 778 903 else … … 781 906 if (!callid) { 782 907 cursor_blink(vp); 908 anims_tick(); 783 909 continue; 784 910 } … … 786 912 continue; 787 913 if (pixmap_handle(callid, &call, vp)) 914 continue; 915 if (anim_handle(callid, &call, vp)) 788 916 continue; 789 917
Note:
See TracChangeset
for help on using the changeset viewer.
