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

📄 ig_render.cpp

📁 这是DVD中伺服部分的核心代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        IGInfo.SelectedButton = FindButton;
        IGInfo.SelectedButton->ButtonState = BUTTON_SELECTED;
        IGInfo.SelectedButton->CurrentDisplayObjectIDRef = IGInfo.SelectedButton->SelectedStartObjectIDRef;

        /* tell the PE about the selected button */
        IGToPEButtonSelect(IGInfo.SelectedButton);
    }
    else if (IG_STATUS_SUCCESS == IGCompareButtonToDefaultValid(Page, (USHORT)(PSR10), &FindButton))
    {
        /* if PSR10 is already valid on the page don't do anything, BUT make sure our
        current selected button is this button */
        DBGPRINT(DBG_ON(DBG_TRACE), ("IGPSR10Procedure(): Case 2\n"));
        if (IGInfo.SelectedButton == NULL)
        {
            /* this is our new selected button */
            IGInfo.SelectedButton = FindButton;
            IGInfo.SelectedButton->ButtonState = BUTTON_SELECTED;
            IGInfo.SelectedButton->CurrentDisplayObjectIDRef = IGInfo.SelectedButton->SelectedStartObjectIDRef;
        }
        else
        {
            /* make sure the button that is selected is in the selected state*/
            IGInfo.SelectedButton->ButtonState = BUTTON_SELECTED;
            IGInfo.SelectedButton->CurrentDisplayObjectIDRef = IGInfo.SelectedButton->SelectedStartObjectIDRef;
        }
    }
    else if (IG_STATUS_SUCCESS == IGHasValidDefaultButtonID(Page, &FindButton))
    {
        DBGPRINT(DBG_ON(DBG_TRACE), ("IGPSR10Procedure(): Case 3\n"));
        if (IGInfo.SelectedButton)
        {
            IGInfo.SelectedButton->ButtonState = BUTTON_ENABLED;
            IGInfo.SelectedButton->CurrentDisplayObjectIDRef = IGInfo.SelectedButton->NormalStartObjectIDRef;
        }

        IGInfo.SelectedButton = FindButton;
        IGInfo.SelectedButton->ButtonState = BUTTON_SELECTED;
        IGInfo.SelectedButton->CurrentDisplayObjectIDRef = IGInfo.SelectedButton->SelectedStartObjectIDRef;

        IGToPEButtonSelect(IGInfo.SelectedButton);
    }
    else
    {
        /* if the button has not been found, the default is no selection*/
        DBGPRINT(DBG_ON(DBG_TRACE), ("IGPSR10Procedure(): Case 4\n"));
        if (IGInfo.SelectedButton)
        {
            IGInfo.SelectedButton->ButtonState = BUTTON_ENABLED;
            IGInfo.SelectedButton->CurrentDisplayObjectIDRef = IGInfo.SelectedButton->NormalStartObjectIDRef;

            /* draw the first frame of the button */
            IGGraphicsRenderButton(IGInfo.SelectedButton, 0);

            IGInfo.SelectedButton = NULL;

            /* there is no selected button, NOTE: This Pointer is NULL! */
            IGToPEButtonSelect(IGInfo.SelectedButton);

            /* disable all buttons in the page */
            return IG_STATUS_BUTTONS_DISABLED;
        }
    }

    return IG_STATUS_SUCCESS;
}


/**
 * IGRenderEffectsSequence - render the given effects sequence and return when finished
 *
 * @param BYTE *FrameBufferBase - The buffer we are drawing to
 *
 * @return void
 */
IG_STATUS IGRenderEffectsSequence(EFFECT_SEQUENCE *Sequence)
{
    int i;
    ULONG OSTicksPerClock;
    ULONG Aggregate=0;
    ULONG TZero;
    ULONG DisplayTimes[MAX_EFFECTS];
    DFBRegion EffRegion;

    if (Sequence->NumEffects > 0)
    {
        DBGPRINT(DBG_ON(DBG_TRACE), ("IGRenderEffectsSequence(): num effects are %d, numwindows %d\n",
            Sequence->NumEffects, Sequence->NumWindows));

        /* calculate the tick rate */
        OSTicksPerClock = OS_GetTickRate() / 90000;

        /* if there is a user timeout timer running, get the time left and stop it,
           restart this timer with the remaining time when the effects are finished
           spec 8.8.4.7.3 */
        if (0 != IGInfo.ICS->UserTimeoutDuration)
        {
            if (OS_TimerGetTimeMsec(IGInfo.TimerUserSelection, &IGInfo.UserTimeRemaining) == OS_OK)
            {
                OS_TimerStop(IGInfo.TimerUserSelection);
            }
            else
            {
                DBGPRINT(DBG_ON(DBG_ERROR), ("IGRenderEffectsSequence(): failed to get UserTimeRemaining\n"));
                IGInfo.UserTimeRemaining = 0;
            }
        }

        /* create the flipping region for the effects sequence, this will be the union of
        the two regions for the two windows assigned to the sequence */
        if (Sequence->NumWindows == 0)
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("IGRenderEffectsSequence(): effects but no windows!\n"));
            return IG_STATUS_ERROR;
        }
        else if (Sequence->NumWindows == 1)
        {
            EffRegion.x1 = Sequence->WindowList[0].X;
            EffRegion.x2 = EffRegion.x1 + Sequence->WindowList[0].Width;
            EffRegion.y1 = Sequence->WindowList[0].Y;
            EffRegion.y2 = EffRegion.y1 + Sequence->WindowList[0].Height;
        }
        else if (Sequence->NumWindows == 2)
        {
            if (Sequence->WindowList[0].X < Sequence->WindowList[1].X)
            {
                EffRegion.x1 = Sequence->WindowList[0].X;
            }
            else
            {
                EffRegion.x1 = Sequence->WindowList[1].X;
            }

            if (Sequence->WindowList[0].Y < Sequence->WindowList[1].Y)
            {
                EffRegion.y1 = Sequence->WindowList[0].Y;
            }
            else
            {
                EffRegion.y1 = Sequence->WindowList[1].Y;
            }

            if ((Sequence->WindowList[0].X + Sequence->WindowList[0].Width) >
                (Sequence->WindowList[1].X + Sequence->WindowList[1].Width))
            {
                EffRegion.x2 = Sequence->WindowList[0].X + Sequence->WindowList[0].Width;
            }
            else
            {
                EffRegion.x2 = Sequence->WindowList[1].X + Sequence->WindowList[1].Width;
            }

            if ((Sequence->WindowList[0].Y + Sequence->WindowList[0].Height) >
                (Sequence->WindowList[1].Y + Sequence->WindowList[1].Height))
            {
                EffRegion.y2 = Sequence->WindowList[0].Y + Sequence->WindowList[0].Height;
            }
            else
            {
                EffRegion.y2 = Sequence->WindowList[1].Y + Sequence->WindowList[1].Height;
            }
        }
        else
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("IGRenderEffectsSequence(): effects sequence has too many windows!\n"));
            return IG_STATUS_ERROR;
        }

        /* calculate the times needs for display updates */
        TZero = OS_GetTicks();
        for (i=0; i<Sequence->NumEffects; i++)
        {
            Aggregate += (Sequence->EffectsList[i].EffectDuration * OSTicksPerClock);
            DisplayTimes[i] = TZero + Aggregate;
        }

        /* render the effects given for windows */
        for (i=0; i<Sequence->NumEffects; i++)
        {
            /* if composition timeout fires, kick out early */
            if (IGInfo.CompositionEnding)
            {
                break;
            }

            /* draw the effect */
            if (Sequence->EffectsList[i].NumCompObjs > 0)
            {
                IGRenderEffect(&Sequence->EffectsList[i]);
            }
            else
            {
                continue;
            }

            /* this flip does not take the blit lock we already have it */
            if (IGInfo.IGDFBInfo.PrimarySurface->Flip(IGInfo.IGDFBInfo.PrimarySurface, NULL, DSFLIP_NONE) != DFB_OK)
            {
                DBGPRINT(DBG_ON(DBG_ERROR), ("Failed to flip surface\n"));
            }

            /* yield to the flip task */
            OS_TaskYield();

            /* clear this region, it won't affect whats on screen, if it's the last one don't do it */
            if (i != (Sequence->NumEffects-1))
            {
                IGGraphicsClearFlipRegion();
            }

            /* wait until the display time has expired (current time has past display time) */
            while( (OS_GetTicks() < DisplayTimes[i]) && (0 == IGInfo.CompositionEnding) )
            {
                OS_TaskYield();
            }
        }

        /* clear the entire screen but don't show it */
        IGGraphicsClearScreen();

        /* if we had a user timeout duration, we restart the timer here */
        if (0 != IGInfo.ICS->UserTimeoutDuration)
        {
            if (0 != IGInfo.UserTimeRemaining)
            {
                OS_TimerSetMsec(IGInfo.TimerUserSelection, IGInfo.UserTimeRemaining);
            }
        }
    }

    return IG_STATUS_SUCCESS;
}


/**
 * IGRenderEffect - render the given effects sequence and return when finished
 *
 * @param EFFECT *Effect - The effect to render
 * @param BYTE WindowID - The ID of the Window object to render
 *
 * @return void
 */
IG_STATUS IGRenderEffect(EFFECT *Effect)
{
    if (IGGraphicsSetPalette(&IGPalettes[Effect->PaletteIDRef]) != IG_STATUS_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGRenderEffect(): failed to set palette\n"));
        return IG_STATUS_ERROR;
    }

    /* now render the composition objects that reference the window ID passed in */
    for (int i=0; i<Effect->NumCompObjs; i++)
    {
        if (IGInfo.CompositionEnding)
        {
            break;
        }

        /* draw the object */
        IGGraphicsDrawCompObj(&Effect->CompObjs[i], 0);
    }

    return IG_STATUS_SUCCESS;
}

/**
 * IGButtonEventDisable - 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 - the button id of the button to disable
 *
 * @return IG_STATUS
 */
IG_STATUS IGButtonDisable(IG_HANDLE handle, USHORT ButtonID)
{
    int fDisabled = 0;

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

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

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

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

    /* search for the button by button ID and disable it,
    it may need to be explicitly redrawn as background pixels in case there
    is no animation going on */

    if (NULL == IGInfo.ActivePage)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGButtonDisable(): 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), ("IGButtonDisable(): 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) &&
                    (IGInfo.ActivePage->Bogs[i].Buttons[j].ButtonState != BUTTON_DISABLED))
                {
                    IGInfo.ActivePage->Bogs[i].Buttons[j].ButtonState = BUTTON_DISABLED;

                    DBGPRINT(DBG_ON(DBG_TRACE), ("IGButtonDisable(): Disabling bog[%d].button[%d].ButtonID = %d\n", i, j,
                                                IGInfo.ActivePage->Bogs[i].Buttons[j].ButtonID));

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

                    fDisabled=1;

                    /* did we just disable the current selected button? */
                    if (&IGInfo.ActivePage->Bogs[i].Buttons[j] == IGInfo.SelectedButton)
                    {
                        /* the selected button was disabled */
                        IGInfo.SelectedButton = NULL;
                        IGToPEButtonSelect(IGInfo.SelectedButton);
                    }

                    goto foundbutton;
                }
            }
        }
    }

foundbutton:

    /* tell the PE what page is now selected */
    IG_PAGE_SELECT_EVENT_INFO PageSelectInfo;
    PageSelectInfo.pPage = IGInfo.ActivePage;
    IGToPEPageSelect(&PageSelectInfo);

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

    if (fDisabled)
    {
        return IG_STATUS_SUCCESS;
    }
    else
    {
        /* NOTE: no button info to PE on this call */
        return IG_STATUS_ICS_VALID_ERROR;
    }
}

⌨️ 快捷键说明

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