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

📄 basesurf.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: basesurf.cpp,v 1.11.4.3 2004/07/26 10:27:38 pankajgupta 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 "hxcom.h"#include "hxtypes.h"#include "hxwintyp.h"#include "hxvsurf.h"#include "hxslist.h"#include "hxthread.h"#include "hxver.h"#if defined(_WINDOWS)#include "winsurf.h"#if defined (HELIX_FEATURE_VS2)#include "winsurf2.h"#endif#include "winroot.h"    // must be included before colormap.h#endif#include "region.h"#include "basesurf.h"#include "basesite.h"#include "baseroot.h"#include "hxprefs.h"#include "hxtick.h"#include "hxheap.h"#include "colormap.h"#include "microsleep.h"#include "hxevent.h"#include "infmt.h"//MMX alphablending only available on linux and windows right now.//Should work just fine on any IA plaform though (intel solaris for example)#ifdef _USE_MMX#include "mmx_util.h" //for checkMmxAvailablity()extern "C"{    void AlphaBlendMMX( UINT32*, UINT32*, INT32 );}#endif#include <math.h>  // fabs()#include "drawline.h"#if defined(_UNIX) && !defined(_MAC_UNIX)#  include "unixsurf.h"#endif#if defined(_MACINTOSH) || defined(_MAC_UNIX)//#include "../dcondev/dcon.h"#include "platform/mac/macsurf.h"#endif#ifdef _DEBUG#undef HX_THIS_FILEstatic const char HX_THIS_FILE[] = __FILE__;#endif#ifdef _DEBUG#include "region.h" //just for _DumpString#endif#include "sitefact.h"#include "hwmemobj.h"#define NOT_IMPL    0/* *  Defines used for testing various parts of the code. *///#define _CHECK_PERFORMANCE//#define _CHECK_SCROLLBARS//#define _CHECK_MODES#define NOT_IMPL 0#define OVERLAY_BYPASS_THRESHOLD 8#define OVERLAY_FAILURE_THRESHOLD 3 // What the heck should this number be? Does it really matter?CBaseSurface::CBaseSurface(IUnknown* pContext, CHXBaseSite* pSite)    : m_lRefCount(0)    , m_pContext(pContext)    , m_Brightness(0)    , m_Contrast(0)    , m_Saturation(0)    , m_Hue(0)    , m_Sharpness(0)    , m_ModeSharpness(0)    , m_PrevBrightness(0)    , m_PrevContrast(0)    , m_PrevSaturation(0)    , m_PrevHue(0)    , m_PrevSharpness(0)    , m_pSite(pSite)    , m_pRootSurface(NULL)    , m_pOptimizedFormat(NULL)    , m_nSrcCID(0)    , m_nBltMode(HX_BASIC_BLT)    , m_nSurfaceCID(0)    , m_bBackGroundDirty(TRUE)    , m_fScrollBarZoom(1.0)    , zm_pColorAcc(NULL)    , m_pyuvInputMngr(NULL)    , m_pHwMemObj(NULL)    , m_pucLastImage(NULL)    , m_ulLastBlendTime(0)    , m_bSpamUpdateOverlay(TRUE)    , m_bFlipOverlay(FALSE)    , m_nBackBufferCount(0)    , m_nMaxBackBuffers(3)    , m_bDisableFillColorKey(TRUE)    , m_bMultipleOverlay(FALSE)    , m_nOldBltMode(0)    , m_nOldBltMode2(0)    , m_oldOverlayColorDepth(0)    , m_convertedOverlayColor(0x00010203)    , m_bUseOverlays(TRUE)    , m_nOverlayFailureCount(0)    , m_nDDSurfaceSize(0)    , m_nUpdateOverlayByPassCount(0)    , m_scaleFactorX(1.0)    , m_scaleFactorY(1.0)    , m_paSrcRects(NULL)    , m_paDestRects(NULL)    , m_pAdditionalColorKey(NULL)    , m_bNeedColorKeyFilled(FALSE)    , m_bYUVBlending(FALSE)    , m_bVideoSurface2(FALSE)    , m_bOptimalVideoScheduler(FALSE)    , m_pLinkedOverlay(NULL)    , m_bAllowOverlayLinking(TRUE)    , m_bLostHWAcceleration(FALSE)    , m_bOffBecauseofShinking(FALSE)    , m_bImageBlocksGood(FALSE)    , m_pOverlayManager(NULL){    HX_ASSERT( m_pContext );    m_pContext->AddRef();    memset( &m_bmiLastImage, 0, sizeof( HXBitmapInfoHeader ) );    memset( &m_bmiLastBlt, 0, sizeof( HXBitmapInfoHeader ) );    memset( &m_surfaceSize, 0, sizeof(HXxSize) );    memset( &m_lastUpdateDestRect, 0, sizeof(m_lastUpdateDestRect) );    memset( &m_lastUpdateSrcRect, 0, sizeof(m_lastUpdateSrcRect) );    memset( &m_lastSrcRect, 0, sizeof(m_lastSrcRect) );    memset( &m_bmi, 0, sizeof(m_bmi) );#if !defined(_GOLD) && 0    m_TimeStamps.Init(m_pContext, this);#endif    IHXPreferences*    pPreferences    = NULL;    IHXBuffer*         pBuffer         = NULL;    if (HXR_OK == m_pContext->QueryInterface(IID_IHXPreferences,(void**)&pPreferences))    {        if (pPreferences->ReadPref("SiteZoomFactor", pBuffer) == HXR_OK)        {            m_fScrollBarZoom = !(::atoi((char*) pBuffer->GetBuffer()) == 1);        }        HX_RELEASE(pBuffer);        if (pPreferences->ReadPref("UseOverlay", pBuffer) == HXR_OK)        {            m_bUseOverlays = ::atoi((char*) pBuffer->GetBuffer()) == 1;        }        HX_RELEASE(pBuffer);        if (pPreferences->ReadPref("SpamUpdateOverlay", pBuffer) == HXR_OK)        {            m_bSpamUpdateOverlay = ::atoi((char*) pBuffer->GetBuffer()) == 1;        }        HX_RELEASE(pBuffer);        if (pPreferences->ReadPref("FlipOverlay", pBuffer) == HXR_OK)        {            m_bFlipOverlay = ::atoi((char*) pBuffer->GetBuffer()) == 1;        }        HX_RELEASE(pBuffer);        if (pPreferences->ReadPref("YUY2First", pBuffer) == HXR_OK)        {            if (::atoi((char*) pBuffer->GetBuffer()) == 1)            {                int list[] = {0,3,1,4};                m_pyuvInputMngr->SetOutputPriority(CID_I420, list, 4);            }        }        HX_RELEASE(pBuffer);        if (pPreferences->ReadPref("LinkOverlays", pBuffer) == HXR_OK)        {            m_bAllowOverlayLinking = ::atoi((char*) pBuffer->GetBuffer()) == 1;        }        HX_RELEASE(pBuffer);        m_pContext->QueryInterface(IID_IHXOverlayManager, (void**)&m_pOverlayManager);    }    HX_RELEASE(pPreferences);#ifdef _DEBUG    const char* szKeyName = "Software\\"HXVER_COMMUNITY"\\Debug\\SetHook";    m_bAllocHook = HXDebugOptionEnabled(szKeyName);#endif}CBaseSurface::~CBaseSurface(){    HX_DELETE(zm_pColorAcc);    HX_DELETE(m_pyuvInputMngr);    HX_DELETE(m_pHwMemObj);    HX_RELEASE(m_pRootSurface);    // CBaseSite::Destroy calls EndOptimizedBlt.  We can't call    // EndOptimizedBlt from the destructor since it calls DestroySurfaces    // which calls _ReleaseSurface which is a pure virtual...the derived    // class was already destoryed.    HX_ASSERT(!m_pOptimizedFormat);    HX_RELEASE(m_pContext);    HX_FREE(m_pucLastImage);    memset( &m_bmiLastImage, 0, sizeof( m_bmiLastImage ) );    memset( &m_bmiLastBlt, 0, sizeof( m_bmiLastBlt ) );    HX_FREE( m_paSrcRects );    HX_FREE( m_paDestRects );    //Clean up alphablending YUVA image list    CHXMapPtrToPtr::Iterator i = m_YUVAImageList.Begin();    while(i != m_YUVAImageList.End())    {        Image* pImage = (Image*)*i;        HX_VECTOR_DELETE(pImage->pucImage);        HX_DELETE(pImage);        ++i;    }    m_YUVAImageList.RemoveAll();    CHXSimpleList::Iterator j = m_imageBlocks.Begin();    m_bImageBlocksGood = FALSE;    while(j != m_imageBlocks.End())    {        ImageBlock* pBlock = (ImageBlock*)*j;        Image* pImage = pBlock->pImage;        HX_FREE(pImage->pucImage);        HX_DELETE(pImage);        HX_DELETE(pBlock);        ++j;    }    m_imageBlocks.RemoveAll();    if (m_pOverlayManager)    {        m_pOverlayManager->RemoveOverlayRequest((IHXOverlayResponse*)this);    }    HX_RELEASE(m_pOverlayManager);    HXDestroyRegion(m_pAdditionalColorKey);    m_pAdditionalColorKey = NULL;    m_LinkedSites.RemoveAll();}void CBaseSurface::SetRootSurface( CBaseRootSurface* pSurface){    m_pRootSurface = pSurface;    pSurface->AddRef();}void CBaseSurface::DestroySurfaces(){    if (m_surfaceSize.cx || m_surfaceSize.cy)    {        CBaseRootSurface* pSurface = m_pSite->GetRootSurface();        // XXXAH huh?  Should this not be releasing it's own internal        //             surface?  Again, minimal Changes.        //XXXgfw not to mention that you can't call this from the dtor        //of this class like is happening. Lets make sure that whatever        //is needed happens when the root surface is deleted.        if (pSurface)        {            _ReleaseSurface(pSurface);        }        ::memset(&m_surfaceSize, 0, sizeof(m_surfaceSize));    }    HX_DELETE(m_pHwMemObj);}void CBaseSurface::ReInitSurfaces(){    if (m_pOptimizedFormat)    {        HXBitmapInfoHeader optFormat;        memcpy(&optFormat, m_pOptimizedFormat, sizeof(HXBitmapInfoHeader)); /* Flawfinder: ignore */        memset(&m_surfaceSize, 0, sizeof(HXxSize));        BeginOptimizedBlt(&optFormat);    }}BOOL CBaseSurface::ForceGDIMode(BOOL bForceGDI){    if(bForceGDI)    {        if (m_nBltMode == HX_OVERLAY_BLT)        {            m_nBltMode = HX_BASIC_BLT;#if defined(_UNIX) && !defined(_MAC_UNIX)            _ReleaseSurface();#endif            m_pSite->InternalForceRedraw();            m_pSite->m_pTopLevelSite->ScheduleCallback(CLIP, 0 );            m_nOldBltMode = HX_OVERLAY_BLT;        }    }    else    {        if (m_nOldBltMode == HX_OVERLAY_BLT)        {            m_nBltMode = HX_OVERLAY_BLT;#if defined(_UNIX) && !defined(_MAC_UNIX)            TryCreateOverlay(TRUE);#endif            m_pSite->InternalForceRedraw();

⌨️ 快捷键说明

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