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

📄 macroot.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: macroot.cpp,v 1.7.20.1 2004/07/09 01:59:02 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 "hxcom.h"#include "hxtypes.h"#include "hxwintyp.h"#include "hxmap.h"#include "hxslist.h"#include "ihxpckts.h"#include "hxwin.h"#include "hxengin.h"#include "hxsite2.h"#include "chxxtype.h"#include "hxvctrl.h"#include "hxvsurf.h"#include "hxcodec.h"#include "surface.h"#include "vidosurf.h"#include "sitetext.h"#include "chxpckts.h"#include "hxevent.h"#include "bltpatch.h"#include "hxprefs.h"#include "hxevent.h"#include "hxthread.h"#include "basesite.h"#include "platform/mac/macroot.h"#include "platform/mac/macsite.h"#include "platform/mac/macsurf.h"#include "platform/mac/hx_moreprocesses.h"#ifndef _MAC_UNIX#include "hxmm.h"#endif#include "hxcore.h"#ifndef _MACINTOSH#ifndef _MAC_UNIX#error This is the Macintosh platform specific implementation.#endif#endif#if !defined(_CARBON) && !defined(_MAC_UNIX)#error This is an OS X and later implementation!#endif#include "hxheap.h"#ifdef _DEBUG#undef HX_THIS_FILE		static const char HX_THIS_FILE[] = __FILE__;#endifUINT32 CMacRootSurface::zm_uNumberOfAttachedDevices = 0;GDHandle CMacRootSurface::zm_AttachedDevice[CMacRootSurface::kMaxMonitors];CHXSimpleList CMacRootSurface::zm_RootSurfaceList;CMacRootSurface::OverlayInfoStruct CMacRootSurface::zm_OverlayInfo[CMacRootSurface::kMaxMonitors];/************************************************************************ *  Method: *    CMacRootSurface constructor */CMacRootSurface::CMacRootSurface(IUnknown* pContext, CHXBaseSite* pSite) : CBaseRootSurface(pContext, pSite) , m_bItsOKToDoAnInterruptBlit(FALSE) , m_pVisRgnRects(NULL) , m_LastVisRgn(NULL) , m_bNeedToForceVisRgnUpdate(FALSE) , m_nBlitDepthEnum(-1) , m_bInBlueBox(FALSE) , m_bAllowedToITBInBlueBox(TRUE){    m_pVisRgnRects = new CHXSimpleList();        int i;    for (i = 0; i < kNumberOfDepths; i++)    {	m_RootSurfaceGWorld[i] = nil;	m_RootGWorldPixMap[i] = nil;    }    if (zm_uNumberOfAttachedDevices == 0)    {	// OK, first zero it all out	for (i=0; i < kMaxMonitors; i++)	{	    zm_AttachedDevice[i] = NULL;	    	    zm_OverlayInfo[i].b_OverlayExists = FALSE;	    zm_OverlayInfo[i].b_OverlayInitialized = FALSE;	}		// now fill it in with all attached devices!		// check for multiple monitors. Also grab main device...	GDHandle mainGD = ::GetMainDevice();	GDHandle gdH = ::GetDeviceList();	while ( gdH )	{	    zm_AttachedDevice[zm_uNumberOfAttachedDevices] = gdH;	    zm_uNumberOfAttachedDevices++;	    gdH = ::GetNextDevice( gdH );	    	    if (zm_uNumberOfAttachedDevices >= kMaxMonitors)	    {		gdH = nil; // stop counting after ten monitors!	    }	}    }        long blueBoxParams = 0;    short err = Gestalt('bbox', &blueBoxParams);    if (!err && blueBoxParams & 0x00000001)    {	m_bInBlueBox = TRUE;    }        m_LocalToGlobalCoords.h = -32768;    m_LocalToGlobalCoords.v = -32768;    zm_RootSurfaceList.AddTail(this);}/************************************************************************ *  Method: *    CMacRootSurface destructor */CMacRootSurface::~CMacRootSurface(){    LISTPOSITION pos = zm_RootSurfaceList.Find(this);    zm_RootSurfaceList.RemoveAt(pos);        int i;    for (i = 0; i < kNumberOfDepths; i++)    {	if (m_RootSurfaceGWorld[i] != NULL)	{	    ::UnlockPixels(m_RootGWorldPixMap[i]);	    ::DisposeGWorld(m_RootSurfaceGWorld[i]);	    m_RootSurfaceGWorld[i] = NULL;	    m_RootGWorldPixMap[i] = NULL;	}    }        if (m_LastVisRgn)    {	::DisposeRgn(m_LastVisRgn);	m_LastVisRgn = nil;    }    delete m_pVisRgnRects;    m_pVisRgnRects = NULL;}/************************************************************************ *  Method: *    CMacRootSurface::_GetYUVScratchWidthHeight */voidCMacRootSurface::_GetYUVScratchWidthHeight(UINT32* pWidth, UINT32* pHeight){}/************************************************************************ *  Method: *    CMacRootSurface::_CreateYUVScratchSurface */voidCMacRootSurface::_CreateYUVScratchSurface(UINT32 width, UINT32 height){}/************************************************************************ *  Method: *    CMacRootSurface::_GetYUVScratchSurfacePointer */voidCMacRootSurface::_GetYUVScratchSurfacePointer(UCHAR** pYUVBits, INT32* YUVPitch){}/************************************************************************ *  Method: *    CMacRootSurface::CreateScratchSurface */HX_RESULTCMacRootSurface::CreateScratchSurface(int nCompositionSurfaceCID, HXxSize* pSize){    return HXR_OK;}/************************************************************************ *  Method: *    CMacRootSurface::ScratchLock */HX_RESULTCMacRootSurface::ScratchLock(UCHAR** pBits, INT32* pPitch_){    return HXR_OK;}/************************************************************************ *  Method: *    CMacRootSurface::ScratchUnlock */HX_RESULTCMacRootSurface::ScratchUnlock(UCHAR* pBits){    return HXR_OK;}/************************************************************************ *  Method: *    CMacRootSurface::_BltFromScratchToComposition */voidCMacRootSurface::_BltFromScratchToComposition(HXxRect& rDestRect, HXxRect& rSrcRect){}/************************************************************************ *  Method: *    CMacRootSurface::_DebugBlt */HX_RESULTCMacRootSurface::_DebugBlt( UCHAR*               pImageData,                        HXBitmapInfoHeader* pBitmapInfo,                        REF(HXxRect)         rDestRect,                        REF(HXxRect)         rSrcRect){    return HXR_OK;}/************************************************************************ *  Method: *    CMacRootSurface::_MinimalUnlock */HX_RESULTCMacRootSurface::_MinimalUnlock(HXxWindow* pWindow){    return HXR_OK;}/************************************************************************ *  Method: *    CMacRootSurface::_LockComposition */HX_RESULTCMacRootSurface::_LockComposition(UCHAR** pBits, INT32* pPitch){    if (m_bItsOKToDoAnInterruptBlit)    {        // if the OK to ITB boolean still needs to be set,        // the region will be force-updated at an appropriate        // time.                // ensure that region is updated.        Rect r;        r.left = m_boundsRect.left;        r.top = m_boundsRect.top;        r.right = m_boundsRect.right;        r.bottom = m_boundsRect.bottom;        UpdateRegionIfNecessary(r, m_LocalToGlobalCoords, m_bNeedToForceVisRgnUpdate);        m_bNeedToForceVisRgnUpdate = FALSE;    }    return HXR_OK;}/************************************************************************ *  Method: *    CMacRootSurface::_CreateCompositionSurface */HX_RESULTCMacRootSurface::_CreateCompositionSurface(){    // XXXbobclark The composition surface -- where stuff gets blitted    // on an interim basis prior to being blitted straight to the screen    // -- works most optimally if it's the same depth as the screen.    // When all this shtuff was in comlib I did this by having possibly    // three interim GWorlds, one each of depths 8-bit, 16-bit, and 32-bit.    // Note that interrupt-time blitting REQUIRES a composition surface of the    // same depth as the screen 'cause CopyBits() doesn't work. And multiple    // monitors imply that multiple depths may need to be active simultaneously.    // Since this gets called so often I'll never dispose the GWorld    // in _DestroyCompositionSurface() so it won't recreate it here. But if    // it stays this way then I'll need to check the size here to see if I    // need to dispose the current GWorld and create a new, correctly-sized    // one.    if (m_compositionSize.cx > m_allocatedCompositionSize.cx || m_compositionSize.cy > m_allocatedCompositionSize.cy)    {	::UnlockPixels(m_RootGWorldPixMap[kThirtyTwoBitDepth]);	::DisposeGWorld(m_RootSurfaceGWorld[kThirtyTwoBitDepth]);	m_RootSurfaceGWorld[kThirtyTwoBitDepth] = nil;	m_RootGWorldPixMap[kThirtyTwoBitDepth] = nil;	m_pCompositionSurface = nil;	m_nBlitDepthEnum = -1;    }        if (!m_pCompositionSurface)    {	short thePixelDepth = 32;	Rect r;	SetRect(&r, 0, 0, m_compositionSize.cx, m_compositionSize.cy);	// It's possible that this is getting called extremely often -- like	// once per blit! and it's also getting called occasionally at interrupt	// time. So I need to get this being built at appropriate times only,	// and then I think that copying it over in _MinimalBlt() I can blit it over	// to the window and maybe just maybe I'll have something visible. Sheesh.	::NewGWorld(&m_RootSurfaceGWorld[kThirtyTwoBitDepth], thePixelDepth, &r, nil, nil, useTempMem);	if (!m_RootSurfaceGWorld[kThirtyTwoBitDepth])	{	    // it failed to create it in temp mem so try creating it in the application heap.	    ::NewGWorld(&m_RootSurfaceGWorld[kThirtyTwoBitDepth], thePixelDepth, &r, nil, nil, 0);	    	    if (!m_RootSurfaceGWorld[kThirtyTwoBitDepth]) return HXR_FAIL;	}	m_RootGWorldPixMap[kThirtyTwoBitDepth] = GetPortPixMap(m_RootSurfaceGWorld[kThirtyTwoBitDepth]);	::LockPixels(m_RootGWorldPixMap[kThirtyTwoBitDepth]);	m_pCompositionSurface = (unsigned char*)GetPixBaseAddr(m_RootGWorldPixMap[kThirtyTwoBitDepth]);	m_nBlitDepthEnum = kThirtyTwoBitDepth;	m_allocatedCompositionSize = m_compositionSize;	m_nCompositionPitch = (**m_RootGWorldPixMap[kThirtyTwoBitDepth]).rowBytes & 0x3fff;	m_boundsRect.left = r.left;	m_boundsRect.top = r.top;	m_boundsRect.right = r.right;	m_boundsRect.bottom = r.bottom;	m_nCompositionSurfaceCID = CID_RGB32;    }    return HXR_OK;}/************************************************************************ *  Method: *    CMacRootSurface::_DestroyCompositionSurface */HX_RESULTCMacRootSurface::_DestroyCompositionSurface(){    // XXXbobclark I've gotta figure out what the story is here,    // 'cause right now it's getting called every blit.    // I certainly don't want to be destroying the whole GWorld!    // So currently I'll never destroy it. Ehhh.        return HXR_OK;}/************************************************************************ *  Method: *    CMacRootSurface::_MinimalBlt */voidCMacRootSurface::_MinimalBlt(HXxRect& src, HXxRect& dst){    {	GrafPtr savePort;	::GetPort(&savePort);	WindowPtr macWindow;	macWindow = m_pSite->m_pWindow ? (WindowPtr)m_pSite->m_pWindow->window : NULL;		if (CHXMacSite::zm_bFullScreenActive)	{	    CHXMacSite* pMacSite = (CHXMacSite*)m_pSite;	    if (pMacSite->m_pHXxFullScreenWindow)	    {		macWindow = (WindowPtr)pMacSite->m_pHXxFullScreenWindow->window;	    }	}		::SetPort(GetWindowPort(macWindow));	// XXXbobclark The "old site" surface implementation's innermost	// blitting API, "BltImage", always happened to have the dest	// rectangle at (0,0) and relied on SetOrigin to set it up	// correctly. The "new site" implementation's innermost blittin	// API is "_MinimalBlt", and in this case the rectangle is relative	// to the core's area. So I remember the current origin (so I can	// restore it 'cause some renderers need it) and reset it to the	// core's offset.	Point oldOrigin;	Rect portRect;	GetPortBounds(GetWindowPort(macWindow), &portRect);	oldOrigin.h = portRect.left;	oldOrigin.v = portRect.top;	HXxWindow* pWindow = m_pSite->GetWindow();	if (pWindow)	{	    SetOriginAndMaintainClipRgn(-pWindow->x,-pWindow->y);	}	m_LocalToGlobalCoords.h = 0;	m_LocalToGlobalCoords.v = 0;	::LocalToGlobal(&m_LocalToGlobalCoords);

⌨️ 快捷键说明

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