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

📄 dsa_new.cpp

📁 SDL库 在进行视频显示程序spcaview安装时必须的库文件
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    	delete iDsa;    	iDsa = NULL;    	}    	    iDsa = CDirectScreenAccess::NewL(    				iSession,					aDevice,					aWindow,					*this);					if(iLut256 == NULL)		iLut256 = (TUint32*) User::AllocL(256 * sizeof(TUint32));	iTargetMode = aWindow.DisplayMode();	iTargetBpp = BytesPerPixel(DisplayMode());	iScreenRect = TRect(aWindow.Position(), aWindow.Size());	SetTargetRect();    RestartL();    }    void CDsa::DrawOverlays()	{	const TInt last = iOverlays.Count() - 1;	for(TInt i = last; i >= 0 ; i--)		iOverlays[i].iOverlay->Draw(*iDsa->Gc(), HwRect(), SwSize());	}TInt CDsa::AppendOverlay(MOverlay& aOverlay, TInt aPriority)	{	TInt i;	for(i = 0; i < iOverlays.Count() && iOverlays[i].iPriority < aPriority; i++)		{}	const TOverlay overlay = {&aOverlay, aPriority};	return iOverlays.Insert(overlay, i);	}	TInt CDsa::RemoveOverlay(MOverlay& aOverlay)	{	for(TInt i = 0; i < iOverlays.Count(); i++)		{		if(iOverlays[i].iOverlay == &aOverlay)			{			iOverlays.Remove(i);			return KErrNone;			}		}	return KErrNotFound;	}void CDsa::LockPalette(TBool aLock)	{	if(aLock)		iStateFlags |= EPaletteLocked;	else		iStateFlags &= ~EPaletteLocked;	}TInt CDsa::SetPalette(TInt aFirst, TInt aCount, TUint32* aPalette)	{	if(iLut256 == NULL)		return KErrNotFound;	const TInt count = aCount - aFirst;	if(count > 256)		return KErrArgument;	if(iStateFlags & EPaletteLocked)		return KErrNone;	for(TInt i = aFirst; i < count; i++) //not so busy here:-)		{		iLut256[i] = aPalette[i];		}	return KErrNone;	}		void CDsa::RestartL()    {    //const TBool active = iDsa->IsActive();        //if(!active)        iDsa->StartL();	        const RRegion* r = iDsa->DrawingRegion();    const TRect rect = r->BoundingRect();    iDsa->Gc()->SetClippingRegion(r);	       if(rect != iScreenRect)    	{    //	iDsa->Cancel();    	return ;	   	 	}   	 	         	    //iScreenRect = rect; //to ensure properly set, albeit may not(?) match to value SDL has - therefore may has to clip	//targetrect shall no change	SetTargetRect();	RecreateL();    iStateFlags |= ERunning;        ReleaseStop();    if(iStateFlags & ESdlThreadSuspend)    	{    	EpocSdlEnv::Resume();    	iStateFlags &= ~ ESdlThreadSuspend;    	}	    EpocSdlEnv::ObserverEvent(MSDLObserver::EEventWindowReserved);	    }    CDsa::CDsa(RWsSession& aSession) :  	iSession(aSession),  	iStateFlags(0)	{//	CActiveScheduler::Add(this);	iCFTable[0] = CopyMem;	iCFTable[1] = CopyMemFlipReversed;	iCFTable[2] = CopyMemReversed;	iCFTable[3] = CopyMemFlip;			iCFTable[4] = Copy256;	iCFTable[5] = Copy256FlipReversed;	iCFTable[6] = Copy256Reversed;	iCFTable[7] = Copy256Flip;				iCFTable[8] = CopySlow;	iCFTable[9] = CopySlowFlipReversed;	iCFTable[10] = CopySlowReversed;	iCFTable[11] = CopySlowFlip;		}	RWsSession& CDsa::Session()	{	return iSession;	}TInt CDsa::RedrawRequest()	{	if(!(iStateFlags & (EUpdating) && (iStateFlags & ERunning)))		{		return ExternalUpdate();		}	return KErrNotReady;	}TUint8* CDsa::LockHwSurface()	{	if((iStateFlags & EUpdating) == 0) //else frame is skipped		{		return LockSurface();		}	return NULL; 	}/*	void CDsa::RunL()	{	iStateFlags &= ~EUpdating;	}			void CDsa::DoCancel()	{	iStateFlags &= ~EUpdating;	//nothing can do, just wait?	}*/		TInt CDsa::AllocSurface(TBool aHwSurface, const TSize& aSize, TDisplayMode aMode)	{	if(aHwSurface && aMode != DisplayMode())		return KErrArgument;		iSourceMode = aMode;		iSourceBpp = BytesPerPixel(aMode);		const TSize size = WindowSize();	if(aSize.iWidth > size.iWidth)		return KErrTooBig;	if(aSize.iHeight > size.iHeight)		return KErrTooBig;		TRAPD(err, CreateSurfaceL());	if(err != KErrNone)		return err;	SetCopyFunction();		return KErrNone;	}	void CDsa::CreateZoomerL(const TSize& aSize)	{	iSwSize = aSize;	iStateFlags |= EResizeRequest;	CreateSurfaceL();	SetTargetRect();	}	/*void SaveBmp(const TDesC& aName, const TAny* aData, TInt aLength, const TSize& aSz, TDisplayMode aMode)	{	CFbsBitmap* s = new CFbsBitmap();	s->Create(aSz, aMode);	s->LockHeap();	TUint32* addr = s->DataAddress();	Mem::Copy(addr, aData, aLength);	s->UnlockHeap();	s->Save(aName);	s->Reset();	delete s;	}	void SaveBmp(const TDesC& aName, const TUint32* aData, const TSize& aSz)	{	CFbsBitmap* s = new CFbsBitmap();	s->Create(aSz, EColor64K);	TBitmapUtil bmp(s);	bmp.Begin(TPoint(0, 0));	for(TInt j = 0; j < aSz.iHeight; j++)		{		bmp.SetPos(TPoint(0, j));		for(TInt i = 0; i < aSz.iWidth; i++)			{			bmp.SetPixel(*aData);			aData++;			bmp.IncXPos();			}		}	bmp.End();	s->Save(aName);	s->Reset();	delete s;	}		TBuf<16> FooName(TInt aFoo)	{	TBuf<16> b;	b.Format(_L("C:\\pic%d.mbm"), aFoo);	return b;	}	void ClipCopy(TUint8* aTarget, const TUint8* aSource, const TRect& aRect, const TPoint& aTargetPos)	{	const TInt iSourceBpp = 1;	const TInt iTargetBpp = 4;	const TInt iScanLineWidth = 800; 		TUint8* target = aTarget;	const TUint8* source = aSource;	const TInt lineWidth = aRect.Width();	source += iSourceBpp * (aRect.iTl.iY * lineWidth); 	const TInt sourceStartOffset = iSourceBpp *  aRect.iTl.iX;	source += sourceStartOffset;	target += iTargetBpp * ((aTargetPos.iY + aRect.iTl.iY ) * lineWidth); 	const TInt targetStartOffset = iTargetBpp * (aRect.iTl.iX + aTargetPos.iX);	target += targetStartOffset;	TUint32* targetPtr = reinterpret_cast<TUint32*>(target);	const TInt targetWidth = iScanLineWidth >> 2;	const TInt height = aRect.Height(); 	}	*//*void CDsa::ClipCopy(TUint8* aTarget, 					const TUint8* aSource, 					const TRect& aUpdateRect, 					const TRect& aSourceRect) const	{	//TUint8* target = aTarget;	const TUint32* source = (const TUint32*) aSource;	const TInt lineWidth = aSourceRect.Width();		source +=  (aUpdateRect.iTl.iY * lineWidth); 	const TInt sourceStartOffset =   aUpdateRect.iTl.iX;	source += sourceStartOffset;		TUint32* targetPtr = reinterpret_cast<TUint32*>(aTarget);		targetPtr +=  (aSourceRect.iTl.iY + aUpdateRect.iTl.iY ) * SwSize().iWidth; 	const TInt targetStartOffset =  (aUpdateRect.iTl.iX + aSourceRect.iTl.iX);		targetPtr += targetStartOffset;	//	TUint32* targetPtr = reinterpret_cast<TUint32*>(target);		const TInt targetWidth32 = SwSize().iWidth;		const TInt height = aUpdateRect.Height(); 			const TInt lineMove = iStateFlags & EOrientation90 ? 1 : lineWidth;	const TInt copyLen = aUpdateRect.Width();			if(iStateFlags & EOrientation180)		{				targetPtr += targetWidth32 *  (height - 1);			for(TInt i = 0; i < height; i++) //source is always smaller			{			iCopyFunction(*this, targetPtr, (TUint8*)source, copyLen, height);			source += lineMove;			targetPtr -= targetWidth32;			}		}	else		{						for(TInt i = 0; i < height; i++) //source is always smaller			{			iCopyFunction(*this, targetPtr, (TUint8*)source, copyLen, height);			source += lineMove;			targetPtr += targetWidth32; // >> 2;			}		}	}	*/void CDsa::ClipCopy(TUint8* aTarget, const TUint8* aSource, const TRect& aRect, const TPoint& aTargetPos) const	{	TUint8* target = aTarget;	const TUint8* source = aSource;	const TInt lineWidth = aRect.Width();	source += iSourceBpp * (aRect.iTl.iY * lineWidth); 	TInt sourceStartOffset = iSourceBpp *  aRect.iTl.iX;	source += sourceStartOffset;	target += iTargetBpp * ((aTargetPos.iY + aRect.iTl.iY ) * lineWidth); 	TInt targetStartOffset = iTargetBpp * (aRect.iTl.iX + aTargetPos.iX);	target += targetStartOffset;	TUint32* targetPtr = reinterpret_cast<TUint32*>(target);	const TInt targetWidth = iScanLineWidth >> 2;	const TInt height = aRect.Height(); 		TInt lineMove = iStateFlags & EOrientation90 ? 1 : lineWidth;		if(iStateFlags & EOrientation180)		{				targetPtr += targetWidth *  (height - 1);			for(TInt i = 0; i < height; i++) //source is always smaller			{			iCopyFunction(*this, targetPtr, source, lineWidth, height);			source += lineMove;			targetPtr -= targetWidth;			}		}	else		{						for(TInt i = 0; i < height; i++) //source is always smaller			{			iCopyFunction(*this, targetPtr, source, lineWidth, height);			source += lineMove;			targetPtr += targetWidth;			}		}	}					/*void CDsa::ClipCopy(TUint8* aTarget, 					const TUint8* aSource, 					const TRect& aUpdateRect, 					const TRect& aSourceRect) const 		{ 		const TDsa dsa(*this); 		switch(iSourceBpp) 			{ 			case 1: 				::ClipCopy<TUint32, TUint8>(dsa, aTarget, aSource, aUpdateRect, aSourceRect); 				break; 			case 2: 				::ClipCopy<TUint32, TUint16>(dsa, aTarget, aSource, aUpdateRect, aSourceRect); 				break; 			case 4: 				::ClipCopy<TUint32, TUint32>(dsa, aTarget, aSource, aUpdateRect, aSourceRect); 				break; 			} 		}	*/void CDsa::Wipe() //dont call in drawing	{	if(IsDsaAvailable())		Wipe(iTargetBpp * SwSize().iWidth * SwSize().iHeight);	}	void CDsa::SetCopyFunction()	{	//calculate offset to correct function in iCFTable according to given parameters	TInt function = 0;	const TInt KCopyFunctions = 4;	const TInt KOffsetToNative = 0;	const TInt KOffsetTo256 = KOffsetToNative + KCopyFunctions;	const TInt KOffsetToOtherModes = KOffsetTo256 + KCopyFunctions;	const TInt KOffsetTo90Functions = 1;	const TInt KOffsetTo180Functions = 2;		if(iSourceMode == DisplayMode())		function = KOffsetToNative; 		//0	else if(iSourceMode == EColor256)		function = KOffsetTo256;			//4	else		function = KOffsetToOtherModes; 	//8		if(iStateFlags & EOrientation90)		function += KOffsetTo90Functions; 	// + 1	if(iStateFlags & EOrientation180)		function += KOffsetTo180Functions; 	//+ 2		iCopyFunction = iCFTable[function];		Wipe();	}	inline void Rotate(TRect& aRect)	{	const TInt dx = aRect.iBr.iX - aRect.iTl.iX;	const TInt dy = aRect.iBr.iY - aRect.iTl.iY;	aRect.iBr.iX = aRect.iTl.iX + dy;	aRect.iBr.iY = aRect.iTl.iY + dx;		const TInt tmp = aRect.iTl.iX;	aRect.iTl.iX = aRect.iTl.iY;	aRect.iTl.iY = tmp;	}	/*	int bar = 0;*/	/*TBool CDsa::AddUpdateRect(const TUint8* aBits, const TRect& aUpdateRect, const TRect& aRect)	{	if(iStateFlags & EOrientationChanged)		{		iStateFlags &= ~EOrientationFlags;		iStateFlags |= iNewFlags;		SetCopyFunction();		iStateFlags &= ~EOrientationChanged;	    EpocSdlEnv::WaitDeviceChange();	    return EFalse; //skip this frame as data is may be changed		}	if(iTargetAddr == NULL)		{		iTargetAddr = LockHwSurface();		}			TUint8* target = iTargetAddr;	if(target == NULL)		return EFalse;			TRect targetRect = TRect(TPoint(0, 0), SwSize());		TRect sourceRect = aRect;	TRect updateRect = aUpdateRect;	//	TPoint move(0, 0);			if(iStateFlags & EOrientation90)		{		Rotate(sourceRect);		Rotate(updateRect);

⌨️ 快捷键说明

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