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

📄 fxmanagr.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 4 页
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: fxmanagr.cpp,v 1.1.24.1 2004/07/09 01:51:47 hubbe Exp $ *  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. *  * The contents of this file, and the files included with this file, * are subject to the current version of the RealNetworks Public * Source License (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the current version of the RealNetworks Community * Source License (the "RCSL") available at * http://www.helixcommunity.org/content/rcsl, in which case the RCSL * will apply. You may also obtain the license terms directly from * RealNetworks.  You may not use this file except in compliance with * the RPSL or, if you have a valid RCSL with RealNetworks applicable * to this file, the RCSL.  Please see the applicable RPSL or RCSL for * the rights, obligations and limitations governing use of the * contents of the file. *  * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL") in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your version of * this file only under the terms of the GPL, and not to allow others * to use your version of this file under the terms of either the RPSL * or RCSL, indicate your decision by deleting the provisions above * and replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient may * use your version of this file under the terms of any one of the * RPSL, the RCSL or the GPL. *  * This file is part of the Helix DNA Technology. RealNetworks is the * developer of the Original Code and owns the copyrights in the * portions it created. *  * This file, and the files included with this file, is distributed * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET * ENJOYMENT OR NON-INFRINGEMENT. *  * Technology Compatibility Kit Test Suite(s) Location: *    http://www.helixcommunity.org/content/tck *  * Contributor(s): *  * ***** END LICENSE BLOCK ***** */// include#include "hxtypes.h"#include "hxwintyp.h"#include "hxresult.h"#include "hxcom.h"#include "hxwin.h"#include "ihxpckts.h"#include "hxvsurf.h"#include "hxfiles.h"#include "hxerror.h"#ifdef _MACINTOSH#include "hxwin.h"	/* for _HXFocusContext; needed for other platforms too? */#endif// pncont#include "hxslist.h"#include "hxmap.h"// pnmisc#include "unkimp.h"#include "baseobj.h"// pxcomlib#include "pxcolor.h"#include "pxrect.h"#include "pxeffect.h"#include "pximage.h"#include "pxcmpmgr.h"#include "pxrndcod.h"#include "rpeffect.h"#include "pxtime.h"// pxrend#include "hlinkmgr.h"#include "imghelpr.h"#include "rncodmgr.h"#include "imagemgr.h"#include "fxseshun.h"#include "fxpkgmgr.h"#include "fxmanagr.h"// pndebug#include "errdbg.h"#include "hxheap.h"#ifdef _DEBUG#undef HX_THIS_FILE     static char HX_THIS_FILE[] = __FILE__;#endifBEGIN_INTERFACE_LIST(PXEffectsManager)END_INTERFACE_LISTPXEffectsManager::PXEffectsManager(){    m_pErrorMessages           = NULL;    m_pImageManager            = NULL;    m_pEffectsPackageManager   = NULL;    m_pHyperlinkManager        = NULL;    m_pEffectsList             = NULL;    m_pEffectSessionList       = NULL;    m_pPostDurationList        = NULL;    m_pFadeLUT                 = NULL;    m_pAlphaLUT                = NULL;    m_bInitialized             = FALSE;    m_bRedrawForced            = FALSE;    m_ulNextEffectHandle       = 1;    m_pLastEffect              = NULL;    m_bCheckIndefiniteDuration = FALSE;    m_bBackChannelNotify       = FALSE;    m_ulBackChannelHandle      = 0;    m_bIsLive                  = FALSE;    ResetDamage();}PXEffectsManager::~PXEffectsManager(){    HX_RELEASE(m_pErrorMessages);    HX_RELEASE(m_pImageManager);    HX_RELEASE(m_pEffectsPackageManager);    HX_RELEASE(m_pHyperlinkManager);    DeleteEffectsList();    DeleteEffectSessionList();    DeletePostDurationList();    HX_DELETE(m_pEffectsList);    HX_DELETE(m_pEffectSessionList);    HX_DELETE(m_pPostDurationList);    HX_VECTOR_DELETE(m_pFadeLUT);    HX_VECTOR_DELETE(m_pAlphaLUT);    HX_RELEASE(m_pLastEffect);}HX_RESULT PXEffectsManager::Init(IHXErrorMessages*       pErrorMessages,                                 PXImageManager*          pImageManager,                                 PXEffectsPackageManager* pEffectsPackageManager,                                 PXHyperlinkManager*      pHyperlinkManager){    HX_RESULT retVal = HXR_OK;    if (pImageManager)    {        // Reset the damage rect        ResetDamage();        // Reset the next effect handle        m_ulNextEffectHandle = 1;        // Save a copy of the IHXErrorMessages interface, if present        HX_RELEASE(m_pErrorMessages);        if (pErrorMessages)        {            m_pErrorMessages = pErrorMessages;            m_pErrorMessages->AddRef();        }        // Save a copy of the image manager        HX_RELEASE(m_pImageManager);        m_pImageManager = pImageManager;        m_pImageManager->AddRef();        // Save a copy of the effects package manager        HX_RELEASE(m_pEffectsPackageManager);        m_pEffectsPackageManager = pEffectsPackageManager;        m_pEffectsPackageManager->AddRef();        // Save a copy of the hyperlink manager        HX_RELEASE(m_pHyperlinkManager);        m_pHyperlinkManager = pHyperlinkManager;        m_pHyperlinkManager->AddRef();        // Create the effect list        DeleteEffectsList();        HX_DELETE(m_pEffectsList);        m_pEffectsList = new CHXSimpleList();        if (m_pEffectsList)        {            // Create the effect session list            DeleteEffectSessionList();            HX_DELETE(m_pEffectSessionList);            m_pEffectSessionList = new CHXSimpleList();            if (m_pEffectSessionList)            {                // Create the post-duration list                DeletePostDurationList();                HX_DELETE(m_pPostDurationList);                m_pPostDurationList = new CHXSimpleList();                if (m_pPostDurationList)                {                    // Set up parameters for LUTs                    m_ulLUTWidth      = 1 << m_pImageManager->GetMaxChannelDepth();                    UINT32 ulNumBytes = m_ulLUTWidth * (kEffectLUTGranularity + 1);                    // Allocate normal fade LUT                    HX_VECTOR_DELETE(m_pFadeLUT);                    m_pFadeLUT = new BYTE [ulNumBytes];                    if (m_pFadeLUT)                    {                        // Set up the fade LUT                        BYTE* pLUT = m_pFadeLUT;                        for (UINT32 ulFrac = 0; ulFrac <= kEffectLUTGranularity; ulFrac++)                        {                            for (UINT32 ulPixVal = 0; ulPixVal < m_ulLUTWidth; ulPixVal++)                            {                                *pLUT++ = (BYTE) ((ulPixVal * ulFrac) / kEffectLUTGranularity);                            }                        }                        // Allocate the alpha LUT                        //                        HX_VECTOR_DELETE(m_pAlphaLUT);                        m_pAlphaLUT = new BYTE [256 * 256];                        if (m_pAlphaLUT)                        {                            // Set up the alpha LUT                            pLUT = m_pAlphaLUT;                            for (UINT32 i = 0; i < 256; i++)                            {                                for (UINT32 j = 0; j < 256; j++)                                {                                    *pLUT++ = (BYTE) (j * i / 255);                                }                            }                        }                        else                        {                            retVal = HXR_OUTOFMEMORY;                        }                    }                    else                    {                        retVal = HXR_OUTOFMEMORY;                    }                }                else                {                    retVal = HXR_OUTOFMEMORY;                }            }            else            {                retVal = HXR_OUTOFMEMORY;            }        }        else        {            retVal = HXR_OUTOFMEMORY;        }    }    else    {        retVal = HXR_INVALID_PARAMETER;    }    return retVal;}void PXEffectsManager::ClearEffects(){    DeleteEffectsList();    DeleteEffectSessionList();    DeletePostDurationList();}HX_RESULT PXEffectsManager::AddEffect(PXEffect *pEffect){    HX_RESULT retVal = HXR_OK;    if (pEffect)    {        if (m_pEffectsList)        {            // Set the effect's ID handle            pEffect->SetHandle(m_ulNextEffectHandle);            // Increment the handle with 32-bit wrap (like we're really gonna need it)            m_ulNextEffectHandle = (m_ulNextEffectHandle == 0xFFFFFFFF ? 1 : m_ulNextEffectHandle + 1);            // Before we add it to the list, we adjust for zero values in the            // dst rect. Zero values of width or height imply the entire            // width or height of the appropriate image. First we adjust for zero            // width and height in the display rect.            PXRect cRect;            cRect = pEffect->GetDstRect();            cRect.AdjustForZeroValues(m_pImageManager->GetDisplayWidth(),                                      m_pImageManager->GetDisplayHeight());            pEffect->SetDstRect(cRect);            // Do we have a src rect?            if (pEffect->HasTarget())            {                // We do the same (adjust for zero-values) for src rects. We                // *may* not have the target image yet, although we most likely will.                PXImage* pTargetImage = NULL;                m_pImageManager->GetImage(pEffect->GetTarget(), &pTargetImage);                if (pTargetImage)                {                    cRect = pEffect->GetSrcRect();                    cRect.AdjustForZeroValues((UINT32) pTargetImage->GetWidth(),                                              (UINT32) pTargetImage->GetHeight());                    pEffect->SetSrcRect(cRect);                }                HX_RELEASE(pTargetImage);            }            // If this is a viewchange effect, then we need to set the            // starting src and dst rects            //            // XXXMEH - this is a design error in the .rp language - the starting            // src and dst rects for the viewchange should be specified IN THAT effect            // with new attributes rather than relying on whatever the last effect was.            if (pEffect->GetEffectType() == PXEffect::kEffectTypeViewChange && m_pLastEffect)            {                pEffect->SetStartSrcRect(m_pLastEffect->GetSrcRect());                pEffect->SetStartDstRect(m_pLastEffect->GetDstRect());                if (m_pLastEffect->HasTarget())                {                    pEffect->SetTarget(m_pLastEffect->GetTarget());                    if (m_pLastEffect->GetLastUse() == TRUE)                    {                        m_pLastEffect->SetLastUse(FALSE);                        pEffect->SetLastUse(TRUE);                    }                }            }            // Update the last effect            HX_RELEASE(m_pLastEffect);            m_pLastEffect = pEffect;            m_pLastEffect->AddRef();            // Check for a few shortcuts before searching the whole list            // If there aren't any elements in the queue, we know just to            // add ourselves to the end of the list.            if (m_pEffectsList->GetCount())            {                // Now we check the last element in the queue. If our start time is                // greater than or equal to its start time, then we know just to                // add ourselves at the tail of the queue.                PXEffect *pTailEffect = (PXEffect *) m_pEffectsList->GetTail();                if (pTailEffect)                {                    if (IsTimeLater(pEffect->GetStart(), pTailEffect->GetStart()))                    {                        // Now we have to search the list.                        // Insert effect into list which is sorted by increasing start time                        // We look for the first effect which has a start time greater                        // than the one we're inserting                        LISTPOSITION pos = m_pEffectsList->GetHeadPosition();                        while (pos)                        {                            PXEffect *pListEffect = (PXEffect *) m_pEffectsList->GetAt(pos);                            if (pListEffect)                            {                                if (IsTimeLater(pEffect->GetStart(), pListEffect->GetStart()))                                {                                    // Addref effect before insertion                                    pEffect->AddRef();                                    // Insert into the list                                    m_pEffectsList->InsertBefore(pos, (void *) pEffect);                                    break;                                }                                m_pEffectsList->GetNext(pos);                            }                            else

⌨️ 快捷键说明

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