⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ig_render.cpp

📁 这是DVD中伺服部分的核心代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
 * @return IG_STATUS
 */
void IGICSReset()
{
    IGToPEICSInValid();

    /* kill timers now */
    IGInfo.CompositionTimeoutPTS = 0;
    IGInfo.SelectionTimeoutPTS = 0;
    IGInfo.CompositionEnding = 0;

    OS_TimerStop(IGInfo.TimerUserSelection);
    OS_TimerStop(IGInfo.TimerAnimation);

    IGInfo.ActivePage = NULL;
    IGInfo.SelectedButton = NULL;

    /* release the current ics */
    IGFreeICS(IGInfo.ICS);
    IGInfo.ICS = NULL;
}



/**
 * IGDoICSUpdate - update the currect ICS with new Page data
 *
 * @param none
 *
 * @return IG_STATUS
 */
IG_STATUS IGDoICSUpdate(INTERACTIVE_COMPOSITION_SEGMENT *ICSUpdate, int *UpdatedActivePage)
{
    /* scan the new ics information and update pages as needed,
    if we update the current display page, the display must be cleared and the
    display must be refreshed with the new information */

    /* NOTE: the number of pages, ui model, composition timeout, selection timeout
    and user time out fields are a constant and can be taken from the Current ICS */

    /* do an error check here, this could help us spot corruption in data */

    /*  check stream and ui model */
    if ((IGInfo.ICS->StreamAndUIModel & BIT7) != (ICSUpdate->StreamAndUIModel & BIT7))
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGDoICSUpdate(): Stream Model is invalid\n"));
        IGFreeICS(ICSUpdate);
        ICSUpdate = NULL;
        return IG_STATUS_ERROR;
    }

    /* check ui model */
    if ((IGInfo.ICS->StreamAndUIModel & BIT6) != (ICSUpdate->StreamAndUIModel & BIT6))
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGDoICSUpdate(): UI Model is invalid\n"));
        IGFreeICS(ICSUpdate);
        ICSUpdate = NULL;
        return IG_STATUS_ERROR;
    }

    /* check num pages */
    if (IGInfo.ICS->NumPages != ICSUpdate->NumPages)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGDoICSUpdate(): Numpages does not match %d to %d\n", IGInfo.ICS->NumPages, ICSUpdate->NumPages));
        IGFreeICS(ICSUpdate);
        ICSUpdate = NULL;
        return IG_STATUS_ERROR;
    }

    /* check user timeout duration */
    if (IGInfo.ICS->UserTimeoutDuration != ICSUpdate->UserTimeoutDuration)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGDoICSUpdate(): The User Timeout Duration doesn't match 0x%x to 0x%x\n", IGInfo.ICS->UserTimeoutDuration, ICSUpdate->UserTimeoutDuration));
        IGFreeICS(ICSUpdate);
        ICSUpdate = NULL;
        return IG_STATUS_ERROR;
    }

    DBGPRINT(DBG_ON(DBG_TRACE), ("IGDoICSUpdate()\n"));

    /* update the composition number */
    IGInfo.ICS->CompDesc.CompositionNumber = ICSUpdate->CompDesc.CompositionNumber;

    /* the stream model MUST stay the same between updates but the CompositionTimeout and SelectionTimeout could change */
    IGInfo.ICS->CompositionTimeoutPTS = ICSUpdate->CompositionTimeoutPTS;
    IGInfo.ICS->SelectionTimeoutPTS = ICSUpdate->SelectionTimeoutPTS;
    IGInfo.SelectionTimedout = 0;

    /* now look for updates to the pages, if an update is found
    clean the memory for that page and copy the new data in    */

    /* since NumPages is constant, we will assume PageID's match
    the previous page id's, if we find a new page id or one that does not match flag
    and print this so it can be modified. */

    for (int i=0; i<IGInfo.ICS->NumPages; i++)
    {
        if (ICSUpdate->Pages[i].PageID != IGInfo.ICS->Pages[i].PageID)
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("IGDoICSUpdate(): No page ID match on 1:1 ICSUpdate\n"));
        }
        else
        {
            if (IGInfo.ActivePage)
            {
                /* does the page id match the current active page id */
                if (IGInfo.ActivePage->PageID == ICSUpdate->Pages[i].PageID)
                {
                    if (ICSUpdate->Pages[i].PageVersionNumber == (IGInfo.ActivePage->PageVersionNumber+1))
                    {
                        /* active page has been changed */
                        *UpdatedActivePage = 1;

                        /* stop timers for animation, this is allowed from 8.8.4.6.5.3.2 */
                        OS_TimerStop(IGInfo.TimerAnimation);
                    }

                    /* the selected button is not selected now */
                    IGInfo.SelectedButton = NULL;
                }

                /* copy page info into current ics page */
                IGUpdateOverOldPAGE(&ICSUpdate->Pages[i], &IGInfo.ICS->Pages[i]);
            }
        }
    }

    /*  we are done with the ics update, free all memory associated, the parts needed have been copied */
    IGFreeICS(ICSUpdate);
    ICSUpdate = NULL;

    return IG_STATUS_SUCCESS;
}

/**
 * IGUpdateOverOldPAGE - Update the new PAGE information over the old, releasing memory where needed
 *
 * @param PAGE *NewPage - The New Page structure
 * @param PAGE *OldPage - The Old Page structure
 *
 * @return IG_STATUS
 */
IG_STATUS IGUpdateOverOldPAGE(PAGE *NewPage, PAGE *OldPage)
{
    /* get the page version number */
    OldPage->PageVersionNumber = NewPage->PageVersionNumber;                /* get page version number */
    OldPage->PageID = NewPage->PageID;                                      /* get page id */
    OldPage->UO_mask_table = NewPage->UO_mask_table;                        /* get the uo mask */
    OldPage->AnimationFrameRateCode = NewPage->AnimationFrameRateCode;      /* animation frame rate */
    OldPage->DefaultSelectedButtonIDRef = NewPage->DefaultSelectedButtonIDRef;  /* default selected button */
    OldPage->DefaultActivatedButtonIDRef = NewPage->DefaultActivatedButtonIDRef; /* default active button */
    OldPage->PaletteIDRef = NewPage->PaletteIDRef;                               /* palette id ref */

    /* clear the bogs */
    if (OldPage->NumBogs > 0)
    {
        IGFreeBogs(OldPage);
    }
    else
    {
        DBGPRINT(DBG_ON(DBG_TRACE), ("IGUpdateOverOldPAGE(): oldpage has no bogs, new page has %d\n", NewPage->NumBogs));
    }

    /* load the in effects sequence */
    OldPage->InEff.NumWindows = NewPage->InEff.NumWindows;
    OldPage->InEff.NumEffects = NewPage->InEff.NumEffects;

    /* get the window list */
    if (OldPage->InEff.NumWindows > 0)
    {
        DBGPRINT(DBG_ON(DBG_TRACE), ("IGUpdateOverOldPAGE(): Copy In Windows\n"));
        memcpy(OldPage->InEff.WindowList, NewPage->InEff.WindowList, NewPage->InEff.NumWindows * sizeof(WINDOW));
    }

    /* copy the effects list */
    if (OldPage->InEff.NumEffects > 0)
    {
        DBGPRINT(DBG_ON(DBG_TRACE), ("IGUpdateOverOldPAGE(): Copy In Effects\n"));
        memcpy(OldPage->InEff.EffectsList, NewPage->InEff.EffectsList, OldPage->InEff.NumEffects * sizeof(EFFECT));
    }

    /* get the window list */
    if (OldPage->OutEff.NumWindows > 0)
    {
        DBGPRINT(DBG_ON(DBG_TRACE), ("IGUpdateOverOldPAGE(): Copy Out Windows\n"));
        memcpy(OldPage->OutEff.WindowList, NewPage->OutEff.WindowList, NewPage->OutEff.NumWindows * sizeof(WINDOW));
    }

    /* copy the effects list */
    if (OldPage->OutEff.NumEffects > 0)
    {
        DBGPRINT(DBG_ON(DBG_TRACE), ("IGUpdateOverOldPAGE(): Copy Out Effects\n"));
        memcpy(OldPage->OutEff.EffectsList, NewPage->OutEff.EffectsList, OldPage->OutEff.NumEffects * sizeof(EFFECT));
    }

    if (OldPage->NumBogs > 0)
    {
        /* copy the bogs data */
        if (IG_STATUS_SUCCESS != IGCopyBogs(OldPage, NewPage))
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("IGUpdateOverOldPAGE(): Failed to copy bogs in IGUpdateOverOldPAGE\n"));
            return IG_STATUS_ERROR;
        }
        else
        {
            IGFreeBogs(NewPage);
        }
    }

    return IG_STATUS_SUCCESS;
}


/**
 * IGICSDrawPage - draw the page given and make it the active page
 *
 * @param BYTE PageNum - The page in the current ICS to render
 *
 * @return void
 */
IG_STATUS IGICSDrawPage(PAGE *DrawPage, int DoEffectsIn)
{
    if (DoEffectsIn && (0 == IsPopup()))
    {
        IGRenderEffectsSequence(&DrawPage->InEff);
    }

    /* enable all the buttons on the page that map to the default button selection */
    if (IGEnableDefaultButtonsOnPage(DrawPage) != IG_STATUS_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGICSDrawPage(): failed IGEnableDefaultButtonsOnPage()\n"));
        return IG_STATUS_ERROR;
    }

    /* start the user timeout duration*/
    if (0 != IGInfo.ICS->UserTimeoutDuration)
    {
        DBGPRINT(DBG_ON(DBG_TRACE), ("IGICSDrawPage(): User Timeout Exists set for %d ms\n", IGInfo.ICS->UserTimeoutDuration/90));
        OS_TimerSetMsec(IGInfo.TimerUserSelection, IGInfo.ICS->UserTimeoutDuration/90);
    }

    return IG_STATUS_SUCCESS;
}

/**
 * IGEnableDefaultButtonsOnPage - render the buttons to the screen that match the default button ids
 *
 * @param PAGE *Page - The page that contains the BOGs->Buttons to render
 *
 * @return void
 */
IG_STATUS IGEnableDefaultButtonsOnPage(PAGE *Page)
{
    /* if we are always on or if popup's are on and enabled, draw the display update */
    if ((IsPopup() == 0) || (IsPopup() && IGInfo.fPopupEnabled))
    {
        for (int i=0; i<Page->NumBogs; i++)
        {
            for (int j=0; j<Page->Bogs[i].NumButtons; j++)
            {
                /* match the bog 7default to a button */
                if (Page->Bogs[i].Buttons[j].ButtonID <= MAX_BUTTONID_VALUE)
                {
                    if (Page->Bogs[i].Buttons[j].ButtonID == Page->Bogs[i].DefaultValidButtonIDRef)
                    {
                        /* this is refernced by the bog as a default so it's BUTTON_ENABLED */
                        DBGPRINT(DBG_ON(DBG_TRACE), ("IGEnableDefaultButtonsOnPage(): Enabling Bog[%d].Button[%d].ButtonID=%d\n",
                            i, j, Page->Bogs[i].Buttons[j].ButtonID));
                        Page->Bogs[i].Buttons[j].ButtonState = BUTTON_ENABLED;
                        Page->Bogs[i].Buttons[j].CurrentDisplayObjectIDRef = Page->Bogs[i].Buttons[j].NormalStartObjectIDRef;

                        IGGraphicsRenderButton(&Page->Bogs[i].Buttons[j], 0);
                    }
                    else
                    {
                        /* make the button disabled */
                        Page->Bogs[i].Buttons[j].ButtonState = BUTTON_DISABLED;
                        Page->Bogs[i].Buttons[j].CurrentDisplayObjectIDRef = 0xFFFF;
                    }
                }
            }
        }
    }

    return IG_STATUS_SUCCESS;
}


/**
 * IGDoButtonSelection - render the buttons to the screen that match the default button ids
 *
 * @param PAGE *Page - The page that contains the BOGs->Buttons to render
 *
 * @return void
 */
IG_STATUS IGDoButtonSelection(PAGE *Page, USHORT PSR10)
{
    /* get the selected button */
    IG_STATUS ButtonStates = IGPSR10Procedure(Page, PSR10);
    if (IG_STATUS_BUTTONS_DISABLED == ButtonStates)
    {
        DBGPRINT(DBG_ON(DBG_TRACE), ("IGFirstPageRender(): no buttons on this page will be enabled\n"));
        IGDisableAllButtonsOnPage(Page);
        return IG_STATUS_SUCCESS;
    }

    /* draw the first frame of the selected button, if there is one */
    if (IGInfo.SelectedButton)
    {
        /* if the default button on this page has auto action, do the activation */
        if (IGInfo.SelectedButton->AutoActionFlag)
        {
            IGInfo.SelectedButton->ButtonState = BUTTON_ACTIVE;

            /* send PE activation message */
            ACTIVATION_INFO *Info = (ACTIVATION_INFO *)OS_MemAlloc(sizeof(ACTIVATION_INFO));
            if (Info != NULL)
            {
                Info->Page = IGInfo.ActivePage;
                Info->Button = IGInfo.SelectedButton;
                Info->ICS = IGInfo.ICS;
            }
            else
            {
                DBGPRINT(DBG_ON(DBG_ERROR), ("IGFirstPageRender(): failed to get memory for activation\n"));
            }

            IGToPEButtonActivate(IGInfo.SelectedButton, Info);
        }
        else
        {
            /* draw the button */
            IGGraphicsRenderButton(IGInfo.SelectedButton, 0);
        }
    }

    return IG_STATUS_SUCCESS;
}


/**
 * IGPSR10Procedure - handle PSR10 selection for the page given (current page)
 *
 * @param PAGE *Page - The page that contains the BOGs->Buttons to render
 *
 * @return void
 */
IG_STATUS IGPSR10Procedure(PAGE *Page, ULONG PSR10)
{
    if (NULL == Page)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGPSR10Procedure(): Null Page Ptr\n"));
        return IG_STATUS_ERROR_NULL_PTR;
    }

    /* spec section 5.9.8.2 check if the defaultselectedbuttonid is valid on the page */
    BUTTON *FindButton = NULL;

    /* search the bogs for a butotn id matching the defaultselectedbuttonid */
    if (IG_STATUS_SUCCESS == IGDefaultSelectionIsButtonID(Page, &FindButton))
    {
        DBGPRINT(DBG_ON(DBG_TRACE), ("IGPSR10Procedure(): Case 1\n"));
        if (BUTTON_DISABLED == FindButton->ButtonState)
        {
            OS_SemGive(IGInfo.ICSLock);
            return IG_STATUS_SUCCESS;
        }

        /* this is our new button selected */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -