macsurf.cpp

来自「symbian 下的helix player源代码」· C++ 代码 · 共 1,064 行 · 第 1/3 页

CPP
1,064
字号
/* ***** BEGIN LICENSE BLOCK *****
 * Source last modified: $Id: macsurf.cpp,v 1.5.20.3 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 ***** */

/****************************************************************************
 * 
 *  $Id: macsurf.cpp,v 1.5.20.3 2004/07/09 01:59:02 hubbe Exp $
 *  
 */

#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"
#ifndef _MAC_UNIX
#include "hxmm.h"
#endif
#include "hxprefs.h"

#include "hxevent.h"
#include "hxthread.h"

#include "platform/mac/macsurf.h"
#include "platform/mac/macroot.h"
#include "baseroot.h"
#include "basesite.h"
#include "platform/mac/macsite.h"

#include "platform/mac/hx_moreprocesses.h"

#ifndef _MACINTOSH
#ifndef _MAC_UNIX
#error This is the Macintosh platform specific implementation.
#endif
#endif


#include "hxheap.h"
#ifdef _DEBUG
#undef HX_THIS_FILE		
static const char HX_THIS_FILE[] = __FILE__;
#endif


CHXSimpleList CMacSurface::zm_SurfaceList;

void* CMacSurface::zm_pOverlayBuf = nil;
long CMacSurface::zm_nOverlayRowBytes = 0;
RgnHandle CMacSurface::zm_OverlayMaskRgn = NULL;
BOOL CMacSurface::zm_bSafeToOverlayBlit = FALSE;
CMacSurface* CMacSurface::zm_pOverlaySurface = nil;
BOOL CMacSurface::zm_bOverlayRequiresKeyColor = FALSE;
BOOL CMacSurface::zm_bOverlayRequiresDrawBand = FALSE;

ImageSequence CMacSurface::zm_SequenceID = NULL;
ImageDescriptionHandle CMacSurface::zm_ImageDescriptionHandle = NULL;
long CMacSurface::zm_nOverlayBufferSize = 0;

void* CMacSurface::zm_pHoldOverlayBuf = NULL;
long CMacSurface::zm_nHoldOverlayBufSize = 0;


#pragma options align=mac68k

struct BogusCodecDecompressParams
{
    CodecDecompressParams decompParams;
    long dummy[100];
    // XXXbobclark
    // sheesh. OK, when ImageCodecNewImageBufferMemory() is
    // called, memory can be corrupted. The address of a
    // CodecDecompressParams is passed to the call, and it
    // pokes memory past the end of the 210-byte structure.
    // I've reproduced this in ATI's YUVSDK as well. ATI
    // insists that it can't be their fault and they don't
    // think it's Apple's fault either. Whatever. Memory
    // is still getting corrupted. By including a bunch of
    // dummy space, that corruption happens in a harmless
    // place. Instead of, like it was doing for weeks, in
    // some random variable that would cause strange behavior
    // and/or crashes at ill-defined times.
};
typedef BogusCodecDecompressParams BogusCodecDecompressParams;

ComponentInstanceRecord *gYUV = nil;

BogusCodecDecompressParams bogusDecompParams;
ImageSubCodecDecompressRecord drp;

#pragma options align=reset



/************************************************************************
 *  Method:
 *    CMacSurface constructor
 */
CMacSurface::CMacSurface(IUnknown* pContext, CHXBaseSite* pSite)
 : CBaseSurface(pContext, pSite)
{
    zm_SurfaceList.AddTail(this);
}

/************************************************************************
 *  Method:
 *    CHXMacSite destructor
 */
CMacSurface::~CMacSurface()
{
    
    if (CMacSurface::zm_pOverlaySurface == this)
    {
	CleanUpOverlay();
	CMacSurface::zm_pOverlaySurface = nil;
	
	::DisposePtr((Ptr)zm_pHoldOverlayBuf);
	zm_pHoldOverlayBuf = NULL;
	zm_nHoldOverlayBufSize = 0;
    }
    
    LISTPOSITION pos = zm_SurfaceList.Find(this);
    zm_SurfaceList.RemoveAt(pos);
}

/************************************************************************
 *  Method:
 *    CMacSurface::_ReleaseSurface
 */
void
CMacSurface::_ReleaseSurface(CBaseRootSurface* pSurface)
{
}


/************************************************************************
 *  Method:
 *    CMacSurface::_DrawBlack
 */
void
CMacSurface::_DrawBlack(void* pWindow)
{
}


/************************************************************************
 *  Method:
 *    CMacSurface::__Sleep
 */
void
CMacSurface::__Sleep(int milliseconds)
{
}


/************************************************************************
 *  Method:
 *    CMacSurface::_BltToPrimary
 */
HX_RESULT
CMacSurface::_BltToPrimary(REF(HXxRect) rDestRect, REF(HXxRect) rSrcRect)
{
    return HXR_OK;
}


/************************************************************************
 *  Method:
 *    CMacSurface::_CreateBuffer
 */
void
CMacSurface::_CreateBuffer()
{
}


/************************************************************************
 *  Method:
 *    CMacSurface::_GetCaps
 */
HX_RESULT
CMacSurface::_GetCaps(UINT32* pfSurfaceCaps)
{
    // see if it supports stuff like overlay.
    
    if (pfSurfaceCaps)
    {
	*pfSurfaceCaps = 0;
	if (_OverlayAvailable())
	{
	    *pfSurfaceCaps |= HX_OVERLAY;
	}
    }
    return HXR_OK;
}


/************************************************************************
 *  Method:
 *    CMacSurface::_CreateOverlay
 */
HX_RESULT
CMacSurface::_CreateOverlay(BOOL bOverlay, int cid, int x, int y)
{
    HX_ASSERT(_OverlayAvailable());
    if (CMacSurface::zm_pOverlaySurface == nil)
    {
	CMacSurface::zm_pOverlaySurface = this;
	// we don't want to construct the overlay here, uhhh, because
	// we don't yet know WHERE it's gonna be. We'll construct it
	// the first time we need it.
    }
    else if (CMacSurface::zm_pOverlaySurface == this)
    {
	CleanUpOverlay();
    }
    if (CMacSurface::zm_pOverlaySurface == this)
    {
	m_nBltMode = HX_OVERLAY_BLT;
	m_surfaceSize.cx = x;
	m_surfaceSize.cy = y;
    }
    return HXR_OK;
}

// xxxbobclark weird, it looks like the first time the color convertor is used,
// it slams something weird into the mouse pointer. I'm just doing a quick
// (unnoticeable really) cursor switch to obscure the garbagey stuff.
BOOL gDumbCursorRedrawNeeded = FALSE;

/************************************************************************
 *  Method:
 *    CMacSurface::_LockInternalSurface
 */
HX_RESULT
CMacSurface::_LockInternalSurface(UCHAR** ppSurPtr, LONG32* pnSurfPitch, REF(HXxSize) srcSize)
{
    HX_RESULT retVal = HXR_OK;
    
    GrafPtr savePort = nil;
    
    if (IsMacInCooperativeThread())
    {
	::GetPort(&savePort);
	HXxWindow* pWindow = m_pSite->m_pTopLevelSite->GetWindow();
	HX_ASSERT(pWindow);
	
	if (!pWindow)
	{
	    return HXR_FAIL;
	}
	
	HX_ASSERT(pWindow->window);
	::SetPort( GetWindowPort( (WindowPtr)pWindow->window ) );
    }
    
    if (zm_pOverlayBuf == nil)
    {
	CMacSurface::zm_pOverlaySurface = this;
	m_nSurfaceCID = CID_YUY2;
    }

    if (CMacSurface::zm_pOverlaySurface == this)
    {
	static Point sLastPoint = {-1,-1};
	static HXxSize sLastSize = {0,0};
	static HXxSize sLastSrcSize = {0,0};

	static Point sP = {-1,-1};

	HX_ASSERT(m_pSite);
	
	HXxSize s;
	
	m_pSite->GetSize(s);
	
	sP.h = 0;
	sP.v = 0;
	BOOL bOverlayRebuildingRequired = FALSE;
	
	if (sLastPoint.h != sP.h || sLastPoint.v != sP.v) bOverlayRebuildingRequired = TRUE;
	if (sLastSize.cx != s.cx || sLastSize.cy != s.cy) bOverlayRebuildingRequired = TRUE;
	if (sLastSrcSize.cx != srcSize.cx || sLastSrcSize.cy != srcSize.cy) bOverlayRebuildingRequired = TRUE;
	if (zm_pOverlayBuf == nil) bOverlayRebuildingRequired = TRUE;
	
	// xxxbobclark this catch up workaround is necessary because with some
	// parameters of the overlay while the TLC is resizing, a glitch can
	// happen and blits start happening outside of our window onto the
	// desktop.
	// If (a) the overlay extends beyond the window or (b) a mask region
	// is used when creating the overlay, then when the TLC resizes the
	// following sequence of events takes place:
	// 1. overlay (sequenceID) created.
	// 2. blit happens (DecompressSequenceFrameWhen) successfully
	// 3. All future blits fail with slamming the frame onto the

⌨️ 快捷键说明

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