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

📄 fxseshun.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        if (pEffect->GetEffectType() == PXEffect::kEffectTypeViewChange)        {            PXImage* pTargetImage = NULL;            retVal                = m_pImageManager->GetImage(m_pEffect->GetTarget(), &pTargetImage);            if (SUCCEEDED(retVal))            {                // Adjust the starting src rect                PXRect cRect;                cRect = m_pEffect->GetStartSrcRect();                cRect.AdjustForZeroValues(pTargetImage->GetWidth(), pTargetImage->GetHeight());                cRect.AdjustForOvershoot(pTargetImage->GetWidth(), pTargetImage->GetHeight());                m_pEffect->SetStartSrcRect(cRect);                // Adjust the starting dst rect                cRect = m_pEffect->GetStartDstRect();                cRect.AdjustForZeroValues(m_pImageManager->GetDisplayWidth(),                                          m_pImageManager->GetDisplayHeight());                cRect.AdjustForOvershoot(m_pImageManager->GetDisplayWidth(),                                         m_pImageManager->GetDisplayHeight());                m_pEffect->SetStartDstRect(cRect);                // Now we need to determine if we need to update the previous dst                if (!(m_pEffect->GetStartDstRect() == m_pEffect->GetDstRect()) &&                    !m_pEffect->GetDstRect().Contains(m_pEffect->GetStartDstRect()))                {                    // Yes, we will need to restore the dest rect, so                     // set the flag                    m_bRestoreDst = TRUE;                    // Compute the biggest size the restore image needs to be                    INT32 lStartW = m_pEffect->GetStartDstRect().GetWidth();                    INT32 lStartH = m_pEffect->GetStartDstRect().GetHeight();                    INT32 lEndW   = m_pEffect->GetDstRect().GetWidth();                    INT32 lEndH   = m_pEffect->GetDstRect().GetHeight();                    INT32 lMaxW   = PXMAX(lStartW, lEndW);                    INT32 lMaxH   = PXMAX(lStartH, lEndH);                    // Get a scratch image which can handle this size                    retVal = m_pImageManager->GetScratchImage(&m_pPrevDst, lMaxW, lMaxH);                    if (SUCCEEDED(retVal))                    {                        // Set the initial restore rect                        m_cRestoreRect.left   = m_pEffect->GetStartDstRect().GetX();                        m_cRestoreRect.top    = m_pEffect->GetStartDstRect().GetY();                        m_cRestoreRect.right  = m_pEffect->GetStartDstRect().GetX() +                                                m_pEffect->GetStartDstRect().GetWidth();                        m_cRestoreRect.bottom = m_pEffect->GetStartDstRect().GetY() +                                                m_pEffect->GetStartDstRect().GetHeight();                        // Now set up the image for the initial restore size                        retVal = m_pPrevDst->Create(HXxRECT_WIDTH(m_cRestoreRect),                                                    HXxRECT_HEIGHT(m_cRestoreRect),                                                    m_pImageManager->GetDefaultBitsPerPixel(),                                                    m_pImageManager->GetDefaultPixelFormat(),                                                    m_pImageManager->GetDefaultRowsInverted(),                                                    FALSE); // Use the same buffer!!                        if (SUCCEEDED(retVal))                        {                            retVal = m_pPrevDst->Fill32(m_pImageManager->GetBackgroundColor());                        }                    }                }                if (SUCCEEDED(retVal))                {                    // Set the initialized flag                    m_bInitialized = TRUE;                }            }            HX_RELEASE(pTargetImage);        }        else        {            retVal = HXR_FAIL;        }    }    if (FAILED(retVal))    {        Reset();        Deallocate();    }#ifdef XXXMEH_DEBUG_ASSERT    // Debug-only assert    HX_ASSERT(SUCCEEDED(retVal));#endif    return retVal;}HX_RESULT PXSimpleViewchangeEffectSession::Execute(UINT32 ulTime){    HX_RESULT retVal = HXR_OK;    if (m_bInitialized)    {        if (!m_bFinished)        {            if (IsTimeEqualOrLater(m_pEffect->GetStart(), ulTime))            {                // Do the maxfps check                BOOL bDoEffect = MaxFramesPerSecondCheck(ulTime);                // Check if this is the last time                if (IsTimeEqualOrLater(m_pEffect->GetEnd(), ulTime))                {                    m_bFinished = TRUE;                    bDoEffect   = TRUE;                    ulTime      = m_pEffect->GetEnd();                }                if (bDoEffect)                {                    // Compute the current dst rect                    PXRect cCurDstRect;                    cCurDstRect.InterpolateRect(ulTime, m_pEffect->GetStart(), m_pEffect->GetEnd(),                                                m_pEffect->GetStartDstRect(), m_pEffect->GetDstRect());                    // If we need to restore the old dest, then do it now                    HXxRect cOldRestoreRect;                    if (m_bRestoreDst)                    {                        // Copy the old dest rect back - first we get a display                        // subimage rect and then copy it.                        PXImage* pTmp = NULL;                        retVal        = m_pImageManager->GetDisplaySubImage(&pTmp, m_cRestoreRect);                        if (SUCCEEDED(retVal))                        {                            retVal = pTmp->CopyFrom(m_pPrevDst);                            if (SUCCEEDED(retVal))                            {                                // Now before we do the new draw we save what's under the                                // rect we're about to draw on                                //                                // First save the old restore rect, so we can resolve the                                // damage rect later and update the restore rect                                cOldRestoreRect       = m_cRestoreRect;                                m_cRestoreRect.left   = cCurDstRect.GetX();                                m_cRestoreRect.top    = cCurDstRect.GetY();                                m_cRestoreRect.right  = cCurDstRect.GetX() + cCurDstRect.GetWidth();                                m_cRestoreRect.bottom = cCurDstRect.GetY() + cCurDstRect.GetHeight();                                // Now setup our scratch image to handle the new size of the                                // the restore rect. It's very important that we tell the Create()                                // method FALSE for the last argument, for this forces the                                // image to reuse the same buffer (which we know is big enough).                                // This just makes for efficient use of memory.                                retVal = m_pPrevDst->Create(HXxRECT_WIDTH(m_cRestoreRect),                                                            HXxRECT_HEIGHT(m_cRestoreRect),                                                            m_pImageManager->GetDefaultBitsPerPixel(),                                                            m_pImageManager->GetDefaultPixelFormat(),                                                            m_pImageManager->GetDefaultRowsInverted(),                                                            FALSE); // Use the same buffer!!                                if (SUCCEEDED(retVal))                                {                                    HX_RELEASE(pTmp);                                    retVal = m_pImageManager->GetDisplaySubImage(&pTmp, m_cRestoreRect);                                    if (SUCCEEDED(retVal))                                    {                                        retVal = m_pPrevDst->CopyFrom(pTmp);                                    }                                }                            }                        }                        HX_RELEASE(pTmp);                    }                    if (SUCCEEDED(retVal))                    {                        // Compute the current src rect                        PXRect cCurSrcRect;                        cCurSrcRect.InterpolateRect(ulTime, m_pEffect->GetStart(), m_pEffect->GetEnd(),                                                    m_pEffect->GetStartSrcRect(), m_pEffect->GetSrcRect());                        // Get the current src image                        PXImage* pCurSrcImg = NULL;                        retVal = m_pImageManager->GetPresentationSubImage(&pCurSrcImg,                                                                          m_pEffect->GetTarget(),                                                                          cCurSrcRect);                        if (SUCCEEDED(retVal))                        {                            // Now we adjust for aspect ratio if necessary                            if (m_pEffect->GetAspectFlag())                            {                                // We have to adjust for preserving aspect ratio, so we                                // will change the dst rect and leave the src rect the same                                PXRect cNewDstRect;                                PXRect cFill1;                                PXRect cFill2;                                retVal = PXImageManager::ResolveAspectRatio(cCurSrcRect, cCurDstRect,                                                                            cNewDstRect, cFill1, cFill2, FALSE);                                if (SUCCEEDED(retVal))                                {                                    // Do the first fill                                    if (cFill1.GetWidth() > 0 && cFill1.GetHeight() > 0)                                    {                                        PXImage* pFill1Img = NULL;                                        retVal = m_pImageManager->GetDisplaySubImage(&pFill1Img, cFill1);                                        if (SUCCEEDED(retVal))                                        {                                            retVal = pFill1Img->Fill32(m_pImageManager->GetBackgroundColor());                                        }                                        HX_RELEASE(pFill1Img);                                    }                                    // Copy src to dst                                    if (SUCCEEDED(retVal))                                    {                                        if (cNewDstRect.GetWidth() > 0 && cNewDstRect.GetHeight() > 0)                                        {                                            PXImage* pNewDstImg = NULL;                                            retVal = m_pImageManager->GetDisplaySubImage(&pNewDstImg, cNewDstRect);                                            if (SUCCEEDED(retVal))                                            {                                                if (pNewDstImg->SameSize(pCurSrcImg))                                                {                                                    retVal = pNewDstImg->CopyFrom(pCurSrcImg);                                                }                                                else                                                {                                                    retVal = pNewDstImg->ChangeSizeFromNN(pCurSrcImg);                                                }                                            }                                            HX_RELEASE(pNewDstImg);                                        }                                    }                                    // Do the second fill                                    if (SUCCEEDED(retVal))                                    {                                        if (cFill2.GetWidth() > 0 && cFill2.GetHeight() > 0)                                        {                                            PXImage* pFill2Img = NULL;                                            retVal = m_pImageManager->GetDisplaySubImage(&pFill2Img, cFill2);                                            if (SUCCEEDED(retVal))                                            {                                                retVal = pFill2Img->Fill32(m_pImageManager->GetBackgroundColor());                                            }                                            HX_RELEASE(pFill2Img);                                        }                                    }                                }                            }                            else                            {                                // We don't have to worry about aspect ratio                                PXImage* pCurDstImg = NULL;                                retVal = m_pImageManager->GetDisplaySubImage(&pCurDstImg, cCurDstRect);                                if (SUCCEEDED(retVal))                                {                                    if (pCurDstImg->SameSize(pCurSrcImg))                                    {                                        retVal = pCurDstImg->CopyFrom(pCurSrcImg);                                    }                                    else                                    {                                        retVal = pCurDstImg->ChangeSizeFromNN(pCurSrcImg);                                    }                                }                                HX_RELEASE(pCurDstImg);                            }                        }                        HX_RELEASE(pCurSrcImg);                        if (SUCCEEDED(retVal))                        {                            // Set the damaged display flag                            m_bDisplayDamaged = TRUE;                            // Set the damage rect                            m_cDamageRect.left   = cCurDstRect.GetX();                            m_cDamageRect.top    = cCurDstRect.GetY();                            m_cDamageRect.right  = cCurDstRect.GetX() + cCurDstRect.GetWidth();                            m_cDamageRect.bottom = cCurDstRect.GetY() + cCurDstRect.GetHeight();                            if (m_bRestoreDst)                            {                                m_cDamageRect.left   = PXMIN(m_cDamageRect.left,   cOldRestoreRect.left);                                m_cDamageRect.top    = PXMIN(m_cDamageRect.top,    cOldRestoreRect.top);                                m_cDamageRect.right  = PXMAX(m_cDamageRect.right,  cOldRestoreRect.right);                                m_cDamageRect.bottom = PXMAX(m_cDamageRect.bottom, cOldRestoreRect.bottom);                            }                        }                    }                    // Update the last exe time                    m_ulLastExeTime = ulTime;                }            }        }        else        {            ResetDamage();        }    }    else    {        retVal = HXR_NOT_INITIALIZED;    }#ifdef XXXMEH_DEBUG_ASSERT    // Debug-only assert    HX_ASSERT(SUCCEEDED(retVal));#endif    return retVal;}IMPLEMENT_COM_CREATE_FUNCS(PXExternalEffectSession);HX_RESULT PXExternalEffectSession::Init(PXEffectsManager*  pEffectsManager,                                        PXEffect*          pEffect,                                        PXImageManager*    pImageManager,                                        IHXErrorMessages* pErrorMessages){    // Call the super-class' Init()    HX_RESULT retVal = PXEffectSession::Init(pEffectsManager,                                             pEffect,                                             pImageManager,                                             pErrorMessages);    if (SUCCEEDED(retVal))    {        // Make sure this is an external effect        if (pEffect->GetEffectType() == PXEffect::kEffectTypeExternal)        {            HX_RELEASE(m_pStartImage);            retVal = m_pImageManager->GetDisplaySubImage(&m_pStartImage,                                                   

⌨️ 快捷键说明

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