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

📄 macsite.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/************************************************************************ *  Method: *    CHXMacSite::SetMacControlRectangle */voidCHXMacSite::SetMacControlRectangle(ControlHandle theControl,		INT32 left, INT32 top, INT32 right, INT32 bottom ){    if (theControl)    {	::SizeControl(theControl, right-left, bottom-top);	::MoveControl(theControl, left, top);    }}voidCHXMacSite::SetMacControlRange(ControlHandle theControl, INT32 controlMax){    if (theControl)    {        ::SetControl32BitMinimum(theControl, 0);        ::SetControl32BitMaximum(theControl, controlMax);    }}/************************************************************************ *  Method: *    CHXMacSite::_ShowXSlider */voidCHXMacSite::_ShowXSlider(BOOL bShow){    HXxWindow* pWindow = GetWindow();    if (!pWindow || !pWindow->window)    {	return;    }    WindowPtr w = (WindowPtr)pWindow->window;    Point oldOrigin;    Rect portRect;    ::GetPortBounds( ::GetWindowPort(w), &portRect);    oldOrigin.h = portRect.left;    oldOrigin.v = portRect.top;        SetOriginAndMaintainClipRgn(0,0);        ShowMacControl(m_hHScrollBar, bShow);        SetOriginAndMaintainClipRgn(oldOrigin.h, oldOrigin.v);}/************************************************************************ *  Method: *    CHXMacSite::_MoveXSlider */voidCHXMacSite::_MoveXSlider(INT32 left, INT32 top, INT32 right, INT32 bottom, BOOL bRedraw){    // xxxbobclark do nothing right now}/************************************************************************ *  Method: *    CHXMacSite::_ShowYSlider */voidCHXMacSite::_ShowYSlider(BOOL bShow){    HXxWindow* pWindow = GetWindow();    if (!pWindow || !pWindow->window)    {	return;    }    WindowPtr w = (WindowPtr)pWindow->window;    Point oldOrigin;    Rect portRect;    ::GetPortBounds(::GetWindowPort(w), &portRect);    oldOrigin.h = portRect.left;    oldOrigin.v = portRect.top;        SetOriginAndMaintainClipRgn(0,0);        ShowMacControl(m_hVScrollBar, bShow);        SetOriginAndMaintainClipRgn(oldOrigin.h, oldOrigin.v);}/************************************************************************ *  Method: *    CHXMacSite::_MoveYSlider */voidCHXMacSite::_MoveYSlider(INT32 left, INT32 top, INT32 right, INT32 bottom, BOOL bRedraw){    // xxxbobclark don't do anything right now}/************************************************************************ *  Method: *    CHXMacSite::_DoesXSliderExist */BOOLCHXMacSite::_DoesXSliderExist(){    if (m_hHScrollBar) return TRUE;    return FALSE;}/************************************************************************ *  Method: *    CHXMacSite::_GetContainingWindow */void*CHXMacSite::_GetContainingWindow(){    if (m_pParentSite) return m_pParentSite->_GetContainingWindow();    return NULL;}/************************************************************************ *  Method: *    CHXMacSite::_GetCursorPos */voidCHXMacSite::_GetCursorPos(HXxPoint* pPoint){    // this will return in global coordinates. (???)    HX_ASSERT(_AtSystemTime());    if (!_AtSystemTime()) return;        HX_ASSERT(pPoint);    if (!pPoint) return;        Point pt;    ::GetMouse(&pt);    // pt is in local coordinates        ::LocalToGlobal(&pt);        pPoint->x = pt.h;    pPoint->y = pt.v;}/************************************************************************ *  Method: *    CHXMacSite::_MapPointToOSWindow */voidCHXMacSite::_MapPointToOSWindow(HXxPoint* pPt, void** pWindowHandle){}/************************************************************************ *  Method: *    CHXMacSite::_GetWindowWithCursor */void*CHXMacSite::_GetWindowWithCursor(){    return NULL;}/************************************************************************ *  Method: *    CHXMacSite::_ReInitPrimarySurface */voidCHXMacSite::_ReInitPrimarySurface(){}/************************************************************************ *  Method: *    CHXMacSite::_MoveWindow */BOOLCHXMacSite::_MoveWindow(void* window, INT32 X, INT32 Y, INT32 nWidth, INT32 nHeight, BOOL bRepaint){    return TRUE;}/************************************************************************ *  Method: *    CHXMacSite::_UpdateWindow */BOOLCHXMacSite::_UpdateWindow(void* hWnd){    return TRUE;}/************************************************************************ *  Method: *    CHXMacSite::_ShowWindow */BOOLCHXMacSite::_ShowWindow(void* hWnd, INT32 nCmdShow){    return TRUE;}/************************************************************************ *  Method: *    CHXMacSite::_SetWindowPos */BOOLCHXMacSite::_SetWindowPos(void* hWnd, void* hWndInsertAfter, INT32 X, INT32 Y, INT32 cx, INT32 cy, INT32 uFlags){    return TRUE;}/************************************************************************ *  Method: *    CHXMacSite::_SetWindowRgn */BOOLCHXMacSite::_SetWindowRgn(void* hWnd, HXREGION* hRgn, BOOL bRedraw){    return TRUE;}/************************************************************************ *  Method: *    CHXMacSite::_SetFocus */voidCHXMacSite::_SetFocus(void* pWindow){}/************************************************************************ *  Method: *    CHXMacSite::GetMacContentAreaOffset */voidCHXMacSite::GetMacContentAreaOffset(REF(HXxPoint)offset){    offset.x = m_topleft.x;    offset.y = m_topleft.y;        HXxWindow* pWindow = GetWindow();        if (pWindow)    {	offset.x += pWindow->x;	offset.y += pWindow->y;    }        return;}#pragma export onextern "C" void MacSiteHandleAllEvents(HXxEvent* pEvent){    CHXMacSite::_HandleAllOSEvents(pEvent);}#pragma export off/************************************************************************ *  Callback implementation *//************************************************************************ *  Method: *    CHXMacSite::MacSiteRedrawCallback ctor */CHXMacSite::MacSiteRedrawCallback::MacSiteRedrawCallback(CHXMacSite* pMacSite) : m_lRefCount(0) , m_ulMacSiteRedrawCallbackPendingID(0) , m_pMacSite(pMacSite){}/************************************************************************ *  Method: *    CHXMacSite::MacSiteRedrawCallback dtor */CHXMacSite::MacSiteRedrawCallback::~MacSiteRedrawCallback(){}/************************************************************************ *  Method: *    CHXMacSite::MacSiteRedrawCallback::QueryInterface */STDMETHODIMPCHXMacSite::MacSiteRedrawCallback::QueryInterface(REFIID riid, void** ppvObj){    if (IsEqualIID(riid, IID_IHXCallback))    {	AddRef();	*ppvObj = (IHXCallback*)this;	return HXR_OK;    }    else if (IsEqualIID(riid, IID_IUnknown))    {        AddRef();        *ppvObj = this;        return HXR_OK;    }    *ppvObj = NULL;    return HXR_NOINTERFACE;}/************************************************************************ *  Method: *    CHXMacSite::MacSiteRedrawCallback::AddRef */STDMETHODIMP_(ULONG32)CHXMacSite::MacSiteRedrawCallback::AddRef(){    return InterlockedIncrement( &m_lRefCount );}/************************************************************************ *  Method: *    CHXMacSite::MacSiteRedrawCallback::Release */STDMETHODIMP_(ULONG32)CHXMacSite::MacSiteRedrawCallback::Release(){    if ( InterlockedDecrement( &m_lRefCount ) > 0 )    {	return m_lRefCount;    }        delete this;    return 0;}/************************************************************************ *  Method: *    CHXMacSite::MacSiteRedrawCallback::Func */STDMETHODIMPCHXMacSite::MacSiteRedrawCallback::Func(){    m_pMacSite->_TLSLock();        m_ulMacSiteRedrawCallbackPendingID = NULL;    m_pMacSite->ForceRedraw();        m_pMacSite->_TLSUnlock();        return HXR_OK;}#ifdef THREADS_SUPPORTED#ifdef USE_CARBON_TIMER/************************************************************************ *  Method: *    CHXMacSite::Redraw(something)Timer *//*static*/#ifdef _MAC_MACHOvoid CHXMacSite::RedrawCFTimer(CFRunLoopTimerRef, CHXMacSite* pMacSite)#elsevoid CHXMacSite::RedrawCarbonTimer(EventLoopTimerRef, CHXMacSite* pMacSite)#endif{    // XXXMEH    MLOG_BLT(NULL,             "%lu\t----macsite.cpp--- RedrawCarbonTimer()\n",             HX_GET_BETTERTICKCOUNT());    HX_ASSERT( pMacSite );    HX_ASSERT(IsMacInCooperativeThread());    if (pMacSite->m_pIHXCoreMutex) pMacSite->m_pIHXCoreMutex->LockCoreMutex();        // this huge block of code is adapted from the base site's implementation of    // InternalScheduleUpgrade, where it needs to match up an IHXPlayer with this    // site. In this case, we're protecting ourselves against rug-pulling, i.e.    // if a stream has ended and stuff has been deleted, it's still possible (due    // to the Carbon Timer's behavior of delaying redraws) that there's a pending    // ForceRedraw() that wants to happen. If there's no player for this site, or    // if the player is done, then we'll omit the blit.        // On a one-gigahertz processor, this checking function is taking    // between 20 and 30 microseconds; it may be worthwhile to save the    // player in a member variable.        bool bPlayerStillRunning = false;        IHXPreferences* pPreferences = NULL;    IHXBuffer* pBuffer = NULL;        IHXClientEngine* pClientEngine = NULL;    if (HXR_OK == pMacSite->m_pContext->QueryInterface(IID_IHXClientEngine, (void**)&pClientEngine))    {        UINT16 nPlayerCount = pClientEngine->GetPlayerCount();        IUnknown* pUnknown = NULL;                if (nPlayerCount == 1)        {            // wow, this was easy -- this is the only player then.            pClientEngine->GetPlayer(0, pUnknown);        }        else        {            IHXSite* pThisSite = NULL;                        pMacSite->QueryInterface(IID_IHXSite, (void**)&pThisSite);            HX_ASSERT(pThisSite);                        UINT16 index;            for (index = 0; index < nPlayerCount; index++)            {                IHXSiteManager2* pSiteMgr2 = NULL;                IUnknown* pUnknownPlayer = NULL;                                pClientEngine->GetPlayer(index, pUnknownPlayer);                HX_ASSERT(pUnknownPlayer);                                pUnknownPlayer->QueryInterface(IID_IHXSiteManager2, (void**)&pSiteMgr2);                if (pSiteMgr2)                {                    UINT32 nNumSites;                    pSiteMgr2->GetNumberOfSites(nNumSites);                    UINT32 index2;                    for (index2 = 0; index2 < nNumSites; index2++)                    {                        IHXSite* pIterationSite = NULL;                        pSiteMgr2->GetSiteAt(index2, pIterationSite);                        if (pThisSite == pIterationSite)                        {                            // it matches!                            HX_ASSERT(pUnknown == NULL);                            pUnknown = pUnknownPlayer;                            pUnknown->AddRef();                        }                    }                    HX_RELEASE(pSiteMgr2);                }                HX_RELEASE(pUnknownPlayer);            }                        HX_RELEASE(pThisSite);        }                if (pUnknown)        {            IHXPlayer* pPlayer;                        pUnknown->QueryInterface(IID_IHXPlayer, (void**)&pPlayer);            if (pPlayer)            {                if (!pPlayer->IsDone())                {                    bPlayerStillRunning = true;                }                HX_RELEASE(pPlayer);            }            HX_RELEASE(pUnknown);        }                HX_RELEASE(pClientEngine);    }        if (bPlayerStillRunning)    {        pMacSite->ForceRedraw();    }        if (pMacSite->m_pIHXCoreMutex) pMacSite->m_pIHXCoreMutex->UnlockCoreMutex();}#endif#endif

⌨️ 快捷键说明

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