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

📄 macsurf.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	    if ( (!bOverlayRebuildingRequired) && (!zm_OverlayMaskRgn || !::EqualRgn(newMaskRgn, zm_OverlayMaskRgn)))	    {		bOverlayRebuildingRequired = TRUE;	    }	}		if (bOverlayRebuildingRequired)	{	    // reset the workaround counter	    sbCatchUp = CHXMacSite::zm_ListOfMacSites.GetCount();	}	else if (sbCatchUp > 0)	{	    bOverlayRebuildingRequired = TRUE;	    sbCatchUp--;	}		if (bOverlayRebuildingRequired)	{	    if (!IsMacInCooperativeThread())	    {//		// xxxbobclark these shouldn't be here 'cause they can//		// force it out of overlay mode even as it's switching//		// to full-screen mode, for example.//		retVal = HXR_FAIL;//		goto exit;	    }	    else	    {		sLastPoint = sP;		sLastSize = s;		sLastSrcSize = srcSize;                                if (!newMaskRgn && zm_OverlayMaskRgn)                {                    // CleanUpOverlay is going to clear out                    // zm_OverlayMaskRgn. Since newMaskRgn is                    // null and zm_OverlayMaskRgn exists we know                    // that we're in the sbCatchUp workaround,                    // and we need to remember the mask region                    // around the CleanUpOverlay function call.                    newMaskRgn = ::NewRgn();                    ::CopyRgn(zm_OverlayMaskRgn, newMaskRgn);                }		CleanUpOverlay();		if (newMaskRgn)		{		    HX_ASSERT(!zm_OverlayMaskRgn);		    zm_OverlayMaskRgn = newMaskRgn;		    newMaskRgn = NULL;		}		HX_ASSERT(zm_OverlayMaskRgn);				ConstructOverlay(sP.h, sP.v, s.cx, s.cy, srcSize.cx, srcSize.cy, zm_OverlayMaskRgn);	    }	}	if (newMaskRgn)	{	    ::DisposeRgn(newMaskRgn);	}    }    else    {	retVal = HXR_FAIL;	goto exit;    }    if (zm_pOverlayBuf == nil || zm_nOverlayRowBytes == 0)    {	retVal = HXR_FAIL;	goto exit;    }    *ppSurPtr = (UCHAR*)zm_pOverlayBuf;    *pnSurfPitch = zm_nOverlayRowBytes;    exit:    HX_ASSERT(savePort != nil);    ::SetPort(savePort);    return retVal;}/************************************************************************ *  Method: *    CMacSurface::_UnlockInternalSurface */HX_RESULTCMacSurface::_UnlockInternalSurface(UCHAR* pSurfPtr){    // On RagePro, the ImageCodecDrawBand call does not NEED to    // be made. Since it uses a key color, whatever's drawn    // to the overlay magically shows up through the key color.    // The Rage128 ignores key color, though, and requires a    // call to ImageCodecDrawBand to update the overlay. This    // blasts through everything, obeying the mask region.    // So if the mask region may be outdated we will not make    // the call to ImageCodecDrawBand.        if (gDumbCursorRedrawNeeded)    {	gDumbCursorRedrawNeeded = FALSE;    }        BOOL bDoOverlayBlit = TRUE;        CHXMacSite* pSite = (CHXMacSite*)zm_pOverlaySurface->m_pSite;    HXxPoint offset;    offset.x = 0;    offset.y = 0;    pSite->GetMacContentAreaOffset(offset);    SetOriginAndMaintainClipRgn(-offset.x, -offset.y);    if (bDoOverlayBlit)    {        if (zm_SequenceID)        {            short err = DecompressSequenceFrameWhen(                            zm_SequenceID,                            (Ptr)zm_pOverlayBuf, zm_nOverlayBufferSize,                            0, // flags                            nil,                            nil,                            nil);        }    }        SetOriginAndMaintainClipRgn(0,0);    return HXR_OK;}/************************************************************************ *  Method: *    CMacSurface::_SetupDCObjects */voidCMacSurface::_SetupDCObjects(HXxDC hxxDC, void** phOldBrush, void** phOldPen){}/************************************************************************ *  Method: *    CMacSurface::_FillRectangle */voidCMacSurface::_FillRectangle(HXxDC hxxDC, UINT32 left, UINT32 top, UINT32 right, UINT32 bottom){    if (zm_bOverlayRequiresKeyColor)    {	GrafPtr savePort;	::GetPort(&savePort);		HX_ASSERT(m_pSite);	HXxWindow* pWindow = m_pSite->GetWindow();		HX_ASSERT(pWindow && pWindow->window);		::SetPort((GrafPtr)pWindow->window);		Rect r;		r.left = left + pWindow->x;	r.top = top + pWindow->y;	r.right = right + pWindow->x;	r.bottom = bottom + pWindow->y;		// xxxbobclark for ATI RagePro cards, they use a key	// color, and the key color is hardcoded. I don't	// know, but this may change if we stumble across a	// card that supports key colors that aren't hard-	// coded -- or that use a DIFFERENT hard-coded one.		static RGBColor keyColor = {0x0000, 0x1000, 0x0000};		RGBColor hold;	::GetForeColor(&hold);	::RGBForeColor(&keyColor);		PaintRect(&r);		::RGBForeColor(&hold);	::SetPort(savePort);    }}/************************************************************************ *  Method: *    CMacSurface::_RestoreDCObjects */voidCMacSurface::_RestoreDCObjects(HXxDC hxxDC, void* hOldBrush, void* hOldPen){}/************************************************************************ *  Method: *    CMacSurface::_GetCompositeionSurfacePNxDC */voidCMacSurface::_GetCompositionSurfaceHXxDC(HXxDC* hdc){}/************************************************************************ *  Method: *    CMacSurface::_ReleaseCompositionSurfaceHXxDC */voidCMacSurface::_ReleaseCompositionSurfaceHXxDC(HXxDC hdc){}/************************************************************************ *  Method: *    CMacSurface::_InsureColorMatch */INT32CMacSurface::_InsureColorMatch(INT32 InColor){    return InColor; // XXXbobclark}/************************************************************************ *  Method: *    CMacSurface::_SetColorKey */voidCMacSurface::_SetColorKey(INT32 nColorSpaceLowValue, INT32 nColorSpaceHighValue){}/************************************************************************ *  Method: *    CMacSurface::_UpdateOverlay */voidCMacSurface::_UpdateOverlay(HXxRect* src, HXxRect* dest, INT32 inFlags){}/************************************************************************ *  Method: *    CMacSurface::_IsSurfaceVisible */BOOLCMacSurface::_IsSurfaceVisible(){    return TRUE;}/************************************************************************ *  Method: *    CMacSurface::_ReleaseSurface */voidCMacSurface::_ReleaseSurface(){    if (CMacSurface::zm_pOverlaySurface == this)    {	CleanUpOverlay();	CMacSurface::zm_pOverlaySurface = nil;    }}/************************************************************************ *  Method: *    CMacSurface::_GetDC */HXxDCCMacSurface::_GetDC(HXxWindow* pWindow){    return NULL; // XXXbobclark gotta figure out what to return, duh}/************************************************************************ *  Method: *    CMacSurface::_ReleaseDC */voidCMacSurface::_ReleaseDC(HXxWindow* pWindow, HXxDC pdc){}/************************************************************************ *  Method: *    CMacSurface::_GetWindowDeviceCords */voidCMacSurface::_GetWindowDeviceCords(HXxRect* rect){    static Point sLastCords = {0,0};        sLastCords.h = 0;    sLastCords.v = 0;    ::LocalToGlobal(&sLastCords);    rect->left = sLastCords.h;    rect->top = sLastCords.v;}/************************************************************************ *  Method: *    CMacSurface::_OverlayAvailable */BOOLCMacSurface::_OverlayAvailable(){    if (!m_bUseOverlays) return FALSE;        return TRUE;}/************************************************************************ *  Method: *    CMacSurface::_AllowsOverlayShrinking */BOOLCMacSurface::_AllowsOverlayShrinking(){    return TRUE;}// some of the following is from ATI's YUVSDK.// Some ATI specific definitions#define 	kATIYUVComponentType			'imdc'#define		kATIYUVComponentSubType			'yuvs'#define		kATIYUVComponentManufacturer	'ATI '#pragma options align=mac68k//QT 3.x stuff : begin -- Anitastruct YUVSdecompressRecord {	short width;			// width (in pixels) of a row	long numStrips;		// number of strips to draw	long srcDataIncrement;	// increment for srcData between strips	long baseAddrIncrement;	// increment for baseAddr between strips	struct Globals *glob;	// pointer to our globals};typedef struct YUVSdecompressRecord YUVSdecompressRecord;// Added for VAUstruct BDCTextureDRP	{				ByteCount dataSize;				// Number of bytes in compressed data		SInt16  width;					// Width in pixels		SInt16  height;					// Height in lines	};typedef struct BDCTextureDRP BDCTextureDRP;pascal void MymemoryGoneProc(Ptr memoryBlock, void *refcon);ICMMemoryDisposedUPP theMemoryProc = nil;pascal void MymemoryGoneProc(Ptr memoryBlock, void *refcon){	// do nothing.}/* static */void CMacSurface::ConstructOverlay(long screenCoorX, long screenCoorY, long screenWidth, long screenHeight, long sourceWidth, long sourceHeight,		RgnHandle maskRgn){    // first let's find our component.    ComponentDescription cd;    Component c = NULL;    Component foundComponent = NULL;    cd.componentType = 'imdc';    cd.componentSubType = 'yuvs';    cd.componentManufacturer = 0;        cd.componentFlags = 0;    cd.componentFlagsMask = 0;    while ((c = FindNextComponent(c, &cd)) != 0)    {        HX_ASSERT(foundComponent == NULL);        foundComponent = c;        break;    }    // this chunk o' code assumes local coordinates.    Point local;    local.h = screenCoorX;    local.v = screenCoorY;    if (!IsRunningNativeOnMacOSX())    {        GlobalToLocal(&local);    }    Rect srcR, dstR;    srcR.left = 0;    srcR.top = 0;    srcR.right = sourceWidth;    srcR.bottom = sourceHeight;    dstR.left = local.h;    dstR.top = local.v;    dstR.right = local.h + screenWidth;    dstR.bottom = local.v + screenHeight;    zm_ImageDescriptionHandle = (ImageDescriptionHandle)NewHandleClear(sizeof(ImageDescription));    (**zm_ImageDescriptionHandle).idSize = sizeof(ImageDescription);    (**zm_ImageDescriptionHandle).cType = 'yuvs';    (**zm_ImageDescriptionHandle).width = srcR.right-srcR.left;    (**zm_ImageDescriptionHandle).height = srcR.bottom-srcR.top;    (**zm_ImageDescriptionHandle).hRes = 72L << 16;    (**zm_ImageDescriptionHandle).vRes = 72L << 16;    (**zm_ImageDescriptionHandle).frameCount = 1;    (**zm_ImageDescriptionHandle).clutID = -1;    MatrixRecord matrix;    RectMatrix(&matrix, &srcR, &dstR);    OSErr err = DecompressSequenceBeginS(                    &zm_SequenceID,                    zm_ImageDescriptionHandle,                    nil, 0, // data pointer and data length                    nil, // use the current port                    nil, // go to screen                    &srcR,                    &matrix,                    ditherCopy,                    maskRgn,                    codecFlagUseImageBuffer,                    codecNormalQuality,                    foundComponent);    zm_nOverlayRowBytes = (srcR.right-srcR.left) * 2;    zm_nOverlayBufferSize = (srcR.bottom - srcR.top) * zm_nOverlayRowBytes;        if ((zm_nOverlayBufferSize == zm_nHoldOverlayBufSize) && zm_pHoldOverlayBuf)    {        zm_pOverlayBuf = zm_pHoldOverlayBuf;    }    else    {        zm_pOverlayBuf = ::NewPtr(zm_nOverlayBufferSize);        if (zm_pHoldOverlayBuf)        {            ::DisposePtr((Ptr)zm_pHoldOverlayBuf);        }        zm_pHoldOverlayBuf = zm_pOverlayBuf;        zm_nHoldOverlayBufSize = zm_nOverlayBufferSize;    }}void CMacSurface::CleanUpOverlay(){    if (zm_SequenceID)    {        CDSequenceEnd(zm_SequenceID);    }    zm_SequenceID = NULL;        if (zm_pOverlayBuf)    {        // xxxbobclark don't dispose this; hold on to it in        // zm_pHoldOverlayBuf in case we create another overlay        // of the same size. Saves allocation and initialization        // time, plus sidesteps some alpha-blending bugs.        // DisposePtr((Ptr)zm_pOverlayBuf);    }    zm_pOverlayBuf = nil;        zm_nOverlayRowBytes = 0;    zm_nOverlayBufferSize = 0;        if (zm_OverlayMaskRgn)    {        ::DisposeRgn(zm_OverlayMaskRgn);    }    zm_OverlayMaskRgn = NULL;    if (zm_ImageDescriptionHandle)    {        ::DisposeHandle((Handle)zm_ImageDescriptionHandle);    }    zm_ImageDescriptionHandle = NULL;}RgnHandleCMacSurface::BuildOverlayVisRgn(){    // This assumes that the decomp params    // rectangle has already been set up!    //    // It also assumes that the port has    // been set to the correct window!    //    // The caller must dispose of the    // region!        HX_ASSERT(IsMacInCooperativeThread());        RgnHandle rgn = ::NewRgn();        ::RectRgn(rgn, &bogusDecompParams.decompParams.dstRect);    return rgn;}#pragma options align=reset

⌨️ 快捷键说明

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