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

📄 ig_render.cpp

📁 这是DVD中伺服部分的核心代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:

/**
 * IGButtonEnable - A button was pushed by the user, notify IG and send up a new button if a new button is selected
 *
 * @param IG_HANDLE handle - handle to the IG module
 * @param USHORT ButtonID - Button ID to enable
 *
 * @return IG_STATUS
 */
IG_STATUS IGButtonEnable(IG_HANDLE handle, USHORT ButtonID)
{
    if ((PVOID)IG_HANDLE_VALUE != handle)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGButtonEnable(): IG_STATUS_INVALID_HANDLE\n"));
        return IG_STATUS_INVALID_HANDLE;
    }

    if (IG_STATE_RUNNING != IGInfo.CurrentState)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGButtonEnable(): IG_STATUS_NOT_RUNNING\n"));
        return IG_STATUS_NOT_RUNNING;
    }

    DBGPRINT(DBG_ON(DBG_TRACE), ("IGButtonEnable(): ButtonID=%d\n", ButtonID));

    /* take the semaphore */
    OS_SemTake(IGInfo.ICSLock, OS_WAIT_FOREVER);

    if (NULL == IGInfo.ActivePage)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGButtonEnable(): There is no active page\n"));
        OS_SemGive(IGInfo.ICSLock);
        return IG_STATUS_ICS_VALID_ERROR;
    }

    if (0 == IGInfo.ActivePage->NumBogs)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGButtonEnable(): There are no Bogs on this page\n"));
        OS_SemGive(IGInfo.ICSLock);
        return IG_STATUS_ICS_VALID_ERROR;
    }

    /* search */
    for (int i=0; i<IGInfo.ActivePage->NumBogs; i++)
    {
        /* are there buttons in this bog? */
        if (IGInfo.ActivePage->Bogs[i].NumButtons > 0)
        {
            for (int j=0; j<IGInfo.ActivePage->Bogs[i].NumButtons; j++)
            {
                if (IGInfo.ActivePage->Bogs[i].Buttons[j].ButtonID == ButtonID)
                {
                    if (IGInfo.ActivePage->Bogs[i].Buttons[j].ButtonState == BUTTON_DISABLED)
                    {
                        if (IGInfo.SelectedButton)
                        {
                            /* get bog index of selected button */
                            USHORT BogIndex = IGGetBogIndex(IGInfo.ActivePage, IGInfo.SelectedButton->ButtonID);

                            /* if the selectedbutton is active and the newly enabled button is in
                            the same bog, disable the selected button and flag a button hint (10.4.3.4 (E)) */
                            if ((BogIndex == i) && (BUTTON_ACTIVE == IGInfo.SelectedButton->ButtonState))
                            {
                                /* the button hint is the current selected button,
                                * we can use this later to reinstate the button as selected
                                * or enabled */
                                IGInfo.ButtonHint = &IGInfo.ActivePage->Bogs[i].Buttons[j];

                                /* now no selected button */
                                IGInfo.SelectedButton->ButtonState = BUTTON_DISABLED;
                                IGInfo.SelectedButton->CurrentDisplayObjectIDRef = 0xFFFF;

                                /* found the button, make sure all other buttons in this bog are disabled except the newly selected button */
                                IGDisableBog(&IGInfo.ActivePage->Bogs[i], IGInfo.ActivePage->Bogs[i].NumButtons, ButtonID);
                                goto foundbutton;
                            }
                        }

                        /* found the button, make sure all other buttons in this bog are disabled except the newly selected button */
                        IGDisableBog(&IGInfo.ActivePage->Bogs[i], IGInfo.ActivePage->Bogs[i].NumButtons, ButtonID);

                        IGInfo.ActivePage->Bogs[i].Buttons[j].ButtonState = BUTTON_ENABLED;
                        IGInfo.ActivePage->Bogs[i].Buttons[j].CurrentDisplayObjectIDRef =
                        IGInfo.ActivePage->Bogs[i].Buttons[j].NormalStartObjectIDRef;

                        /* show the button */
                        OS_SemTake(IGInfo.BlitLock, OS_WAIT_FOREVER);
                        IGGraphicsRenderButton(&IGInfo.ActivePage->Bogs[i].Buttons[j], 0);
                        OS_SemGive(IGInfo.BlitLock);

                        goto foundbutton;
                    }
                }
            }
        }
    }

foundbutton:

    /* give the semaphore back */
    OS_SemGive(IGInfo.ICSLock);

    return IG_STATUS_SUCCESS;
}

/**
 * IGPopupOn - Turn on the Popup menu
 *
 * @param IG_HANDLE handle - handle to the IG module
 *
 * @return IG_STATUS
 */
IG_STATUS IGPopupOn(IG_HANDLE handle)
{
    IG_PAGE_SELECT_EVENT_INFO PageSelectInfo;

    if ((PVOID)IG_HANDLE_VALUE != handle)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGPopupOn(): Return IG_STATUS_INVALID_HANDLE\n"));
        return IG_STATUS_INVALID_HANDLE;
    }

    if (IG_STATE_RUNNING != IGInfo.CurrentState)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGPopupOn(): Return IG_STATUS_NOT_RUNNING\n"));
        return IG_STATUS_NOT_RUNNING;
    }

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

    /* take the semaphore */
    OS_SemTake(IGInfo.ICSLock, OS_WAIT_FOREVER);

    /* Display pop-up menu on the screen if this is a valid Interactive Graphics whose
     * user_interface_model indicates Pop-up In all other cases this function is simply ignored.
     * NOTE: BIT6 indicates Pop-up model */

    if (NULL != IGInfo.ICS)
    {
        if (IsPopup())
        {
            /* set the active page to page id 0 */
            if (IGInfo.ICS->NumPages > 0)
            {
                if (NULL == &IGInfo.ICS->Pages[0])
                {
                    return (IG_STATUS_ERROR);
                }

                IGInfo.ActivePage = &IGInfo.ICS->Pages[0];

                /* set the active page into PSR11 */
                PageSelectInfo.pPage = IGInfo.ActivePage;
                IGToPEPageSelect(&PageSelectInfo);

                /* say that popup is enabled, must set this before calling IGICSDrawPage() */
                IGInfo.fPopupEnabled = TRUE;

                OS_SemTake(IGInfo.BlitLock, OS_WAIT_FOREVER);

                /* enables buttons and tells PE of page selection */
                IGICSDrawPage(IGInfo.ActivePage, 1);

                /* PSR10 procedure and button selection */
                IGDoButtonSelection(IGInfo.ActivePage, (USHORT)(PageSelectInfo.PSR10));

                /* set the palette */
                IGGraphicsSetPalette(&IGPalettes[IGInfo.ActivePage->PaletteIDRef]);
                OS_SemGive(IGInfo.BlitLock);

                /* start any animation if there is one to start */
                IGStartAnimation(IGInfo.ActivePage);

                /* set the flipping region to be full screen */
                if (IGInfo.CoordsHalfWidth == 0)
                {
                    IGGraphicsSetFlipRegion(0, 0, IGInfo.IGDFBInfo.ScreenWidth, IGInfo.IGDFBInfo.ScreenHeight);
                }
                else
                {
                    IGGraphicsSetFlipRegion(0, 0, IGInfo.IGDFBInfo.ScreenWidth/2, IGInfo.IGDFBInfo.ScreenHeight/2);
                }

                OS_TimerSet(IGInfo.TimerFlip, 1);
                OS_TaskYield();

                /* set level up */
                if (DFB_OK != IGInfo.IGDFBInfo.DispLayer->SetLevel(IGInfo.IGDFBInfo.DispLayer, IG_DISPLAY_LEVEL))
                {
                    DBGPRINT(DBG_ON(DBG_ERROR), ("IGPopupOn: Failed to set the level to IG_DISPLAY_LEVEL\n"));
                }
            }
            else
            {
                DBGPRINT(DBG_ON(DBG_ERROR), ("IGPopupOn(): Page 0 doesn't exist for popup\n"));
            }
        }
    }

    /* give the semaphore back */
    OS_SemGive(IGInfo.ICSLock);

    return (IG_STATUS_SUCCESS);
}


/**
 * IGPopupOff - Turn off the Popup menu
 *
 * @param IG_HANDLE handle - handle to the IG module
 *
 * @return IG_STATUS
 */
IG_STATUS IGPopupOff(IG_HANDLE handle)
{
    if ((PVOID)IG_HANDLE_VALUE != handle)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGPopupOff(): IG_STATUS_INVALID_HANDLE\n"));
        return IG_STATUS_INVALID_HANDLE;
    }

    if (IG_STATE_RUNNING != IGInfo.CurrentState)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGPopupOff(): IG_STATUS_NOT_RUNNING\n"));
        return IG_STATUS_NOT_RUNNING;
    }

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

    /* take the semaphore */
    OS_SemTake(IGInfo.ICSLock, OS_WAIT_FOREVER);

    /* Hide pop-up menu if this is a valid Interactive Graphics whose
     * user_interface_model indicates Popup. In all other cases this function is simply ignored.
     * NOTE: IsPopup() != 0 means we are in a popup menu */
    if (NULL != IGInfo.ICS)
    {
        if (IsPopup())
        {
            /* blu-ray 8.8.4.7.2.2 reference for following operations */
            OS_TimerStop(IGInfo.TimerAnimation);

            /* clear display */
            if (IGInfo.fPopupEnabled)
            {
                OS_SemTake(IGInfo.BlitLock, OS_WAIT_FOREVER);

                /* do the out effects sequence */
                if (IGInfo.ActivePage && (IGInfo.ActivePage->OutEff.NumEffects > 0))
                {
                    IGRenderEffectsSequence(&IGInfo.ActivePage->OutEff);

                    /* force fullscreen flip */
                    if (IGInfo.IGDFBInfo.PrimarySurface->Flip(IGInfo.IGDFBInfo.PrimarySurface, NULL, DSFLIP_NONE) != DFB_OK)
                    {
                        DBGPRINT(DBG_ON(DBG_ERROR), ("Failed to flip surface\n"));
                    }
                }
                else
                {
                    IGGraphicsClearScreen();

                    /* force fullscreen flip */
                    if (IGInfo.IGDFBInfo.PrimarySurface->Flip(IGInfo.IGDFBInfo.PrimarySurface, NULL, DSFLIP_NONE) != DFB_OK)
                    {
                        DBGPRINT(DBG_ON(DBG_ERROR), ("Failed to flip surface\n"));
                    }
                }

                OS_SemGive(IGInfo.BlitLock);

                /* set level off */
                if (DFB_OK != IGInfo.IGDFBInfo.DispLayer->SetLevel(IGInfo.IGDFBInfo.DispLayer, IG_DISPLAY_NO_SHOW))
                {
                    DBGPRINT(DBG_ON(DBG_ERROR), ("IGPopupOff: Failed to set the level to IG_DISPLAY_NO_SHOW (-1)\n"));
                }
            }
            else
            {
                /* flip */
                OS_TimerSet(IGInfo.TimerFlip, 1);
                OS_TaskYield();

                /* set level off */
                if (DFB_OK != IGInfo.IGDFBInfo.DispLayer->SetLevel(IGInfo.IGDFBInfo.DispLayer, IG_DISPLAY_NO_SHOW))
                {
                    DBGPRINT(DBG_ON(DBG_ERROR), ("IGPopupOff: Failed to set the level to IG_DISPLAY_NO_SHOW (-1)\n"));
                }
            }

            /* set the current button as just enabled (in case it was selected), then we have no current selected button */
            if (IGInfo.SelectedButton)
            {
                IGInfo.SelectedButton->ButtonState = BUTTON_ENABLED;
                IGInfo.SelectedButton = NULL;

                /* sending null button to clear PSR */
                IGToPEButtonSelect(IGInfo.SelectedButton);  /* BUTTON is NULL */
            }

            /* no more active page */
            if (IGInfo.ActivePage)
            {
                IGInfo.ActivePage = NULL;

                /* fire a page select here to the PE */
                IG_PAGE_SELECT_EVENT_INFO PageSelectInfo;
                PageSelectInfo.pPage = IGInfo.ActivePage;
                IGToPEPageSelect(&PageSelectInfo); /* PAGE is null */
            }

            /* turn off popup flag */
            IGInfo.fPopupEnabled = FALSE;
        }
    }

    /* give the semaphore back */
    OS_SemGive(IGInfo.ICSLock);

    return (IG_STATUS_SUCCESS);
}

/**
 * IGIsPopupOn -- Return the Popup Menu On/Off State.
 *
 * @param IG_HANDLE handle - handle to the IG module
 *
 * @retval
 *      FALSE - Pop up is OFF
 *      TRUE  - Pop up is ON
 */
BOOLEAN IGIsPopupOn(IG_HANDLE handle)
{
    BOOLEAN fIsOn = FALSE;  /* default to not on */

    if (handle != (PVOID)IG_HANDLE_VALUE)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGIsPopupOn(): IG_STATUS_INVALID_HANDLE\n"));
        return (FALSE);
    }

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

    /* take the semaphore */
    OS_SemTake(IGInfo.ICSLock, OS_WAIT_FOREVER);

    if (IG_STATE_RUNNING == IGInfo.CurrentState)
    {
        if (IGInfo.ICS != NULL)
        {
            if (IsPopup())
            {
                /* pop-up UI model */
                fIsOn = IGInfo.fPopupEnabled;
            }
        }
    }

    /* give the semaphore back */
    OS_SemGive(IGInfo.ICSLock);

    return (fIsOn);
}

/**
 * IGIsButtonSelected -- Check if there is an IG button currently selected.
 *
 * @param IG_HANDLE handle - handle to the IG module
 *

⌨️ 快捷键说明

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