Changeset 1fd7700 in mainline for fb/fb.c


Ignore:
Timestamp:
2006-06-07T14:12:53Z (20 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
70178b74
Parents:
b7e9c34
Message:

Added animation to fb, fb running status shown.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fb/fb.c

    rb7e9c34 r1fd7700  
    8282        int cursor_shown;
    8383} viewport_t;
     84
     85#define MAX_ANIM_LEN    8
     86#define MAX_ANIMATIONS  4
     87typedef 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;
     96static animation_t animations[MAX_ANIMATIONS];
     97static int anims_enabled;
    8498
    8599/** Maximum number of saved pixmaps
     
    321335        int i;
    322336
    323 for (i=0; i < MAX_VIEWPORTS; i++) {
     337        for (i=0; i < MAX_VIEWPORTS; i++) {
    324338                if (!viewports[i].initialized)
    325339                        break;
     
    702716}
    703717
     718/** Tick animation one step forward */
     719static 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
     737static 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
    704829/** Handler for messages concerning pixmap handling */
    705830static int pixmap_handle(ipc_callid_t callid, ipc_call_t *call, int vp)
     
    774899
    775900        while (1) {
    776                 if (vport->cursor_shown)
     901                if (vport->cursor_active || anims_enabled)
    777902                        callid = async_get_call_timeout(&call,250000);
    778903                else
     
    781906                if (!callid) {
    782907                        cursor_blink(vp);
     908                        anims_tick();
    783909                        continue;
    784910                }
     
    786912                        continue;
    787913                if (pixmap_handle(callid, &call, vp))
     914                        continue;
     915                if (anim_handle(callid, &call, vp))
    788916                        continue;
    789917
Note: See TracChangeset for help on using the changeset viewer.