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

📄 dsa.cpp

📁 SDL库 在进行视频显示程序spcaview安装时必须的库文件
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	public:		CDsbSurface(MDsbObs& aDsb);		TUint8* Address();		void Complete();		~CDsbSurface();	private:		void RunL();		void DoCancel();	private:		MDsbObs& iDsb; 		TUint8* iAddress;	};	CDsbSurface::CDsbSurface(MDsbObs& aDsb) : CActive(CActive::EPriorityHigh) , iDsb(aDsb)	{	CActiveScheduler::Add(this);	}CDsbSurface::~CDsbSurface()	{	Cancel();	}	void CDsbSurface::Complete()	{	if(iAddress != NULL && !IsActive())		{		iAddress = NULL;		SetActive();		iDsb.Dsb().EndUpdate(iStatus);		}	}	TUint8* CDsbSurface::Address()	{	if(iAddress == NULL && !IsActive())		{		TAcceleratedBitmapInfo info;		if(KErrNone == iDsb.Dsb().BeginUpdate(info))			iAddress = info.iAddress;		}	return iAddress;	}	void CDsbSurface::RunL()	{	iDsb.SurfaceReady();	}void CDsbSurface::DoCancel()	{	//empty	}		NONSHARABLE_CLASS(CDsaB) : public CDsaBase, public MDsbObs	{	public:		CDsaB(RWsSession& aSession, TInt aFlags);	private:		~CDsaB();		TUint8* LockSurface();		void UnlockHWSurfaceRequestComplete();		void UnlockHwSurface();		void CreateSurfaceL();		void Wipe(TInt aLength);		void RecreateL();		void ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice);		CDirectScreenBitmap& Dsb();		void SurfaceReady();		TInt ExternalUpdate();	private:		CDsbSurface* iSurface1;		CDsbSurface* iSurface2;		CDirectScreenBitmap* iDsb;		TInt iType;	};CDsaB::CDsaB(RWsSession& aSession, TInt aFlags) : CDsaBase(aSession), iType(aFlags)	{	}	void CDsaB::UnlockHWSurfaceRequestComplete()	{	iSurface1->Complete();	if(iSurface2 != NULL)		iSurface2->Complete();	}	void CDsaB::CreateSurfaceL()	{	__ASSERT_ALWAYS(SwSize() == HwRect().Size(), PANIC(KErrNotSupported));	}	void CDsaB::Wipe(TInt aLength) //dont call in drawing	{	TUint8* addr = LockSurface();	if(addr != NULL) 		{		Mem::FillZ(addr, aLength);		UnlockHwSurface();		}	}	void CDsaB::UnlockHwSurface()	{	EpocSdlEnv::Request(CDsa::ERequestUpdate);	}	TUint8* CDsaB::LockSurface()	{	TUint8* addr =  iSurface1->Address();	if(addr == NULL && iSurface2 != NULL)		addr =  iSurface2->Address();	SetUpdating(addr == NULL);	return addr;	}	void CDsaB::SurfaceReady()		{	SetUpdating(EFalse);	}CDirectScreenBitmap& CDsaB::Dsb()	{	return *iDsb;	}	void CDsaB::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice)	{	if(iDsb == NULL)		iDsb = CDirectScreenBitmap::NewL();		CDsaBase::ConstructL(aWindow, aDevice);	if(iSurface1 == NULL)			iSurface1 = new (ELeave) CDsbSurface(*this);	if(iSurface2 == NULL && iType & CDirectScreenBitmap::EDoubleBuffer)		iSurface2 = new (ELeave) CDsbSurface(*this);	}	CDsaB::~CDsaB()	{	delete iSurface1;	delete iSurface2;	delete iDsb;	}	void CDsaB::RecreateL()	{    iDsb->Close();    iDsb->Create(HwRect(), CDirectScreenBitmap::TSettingsFlags(iType));	}	TInt CDsaB::ExternalUpdate()	{	if(LockSurface())		{		UnlockHWSurfaceRequestComplete();		return KErrNone;		}	return KErrNotReady;	}		/////////////////////////////////////////////////////////////////////////////////////////////////////	CDsa* CDsa::CreateL(RWsSession& aSession)	{	if(EpocSdlEnv::Flags(CSDL::EDrawModeDSB))		{		TInt flags = CDirectScreenBitmap::ENone;		if(EpocSdlEnv::Flags(CSDL::EDrawModeDSBDoubleBuffer))			flags |= CDirectScreenBitmap::EDoubleBuffer;		if(EpocSdlEnv::Flags(CSDL::EDrawModeDSBIncrementalUpdate))			flags |= CDirectScreenBitmap::EIncrementalUpdate;		return new (ELeave) CDsaB(aSession, flags);		}	else if(EpocSdlEnv::Flags(CSDL::EDrawModeGdi))		{		return new (ELeave) CBitmapSurface<CDsaBitgdi>(aSession);		}    else    	{        return new (ELeave) CBitmapSurface<CDsaA>(aSession);		}	}		void CDsa::RecreateL()	{	}void CDsa::Free()	{	}	TSize CDsa::WindowSize() const	{	TSize size = iSwSize;	if(iStateFlags & EOrientation90)		{		const TInt tmp = size.iWidth;		size.iWidth = size.iHeight;		size.iHeight = tmp;		}	return size;	}	void CDsa::SetSuspend()	{	iStateFlags |= ESdlThreadSuspend;	}void CDsa::SetUpdating(TBool aUpdate)	{	if(aUpdate)		iStateFlags |= EUpdating;	else		iStateFlags &= ~EUpdating;	}TBool CDsa::Stopped() const	{	return (iStateFlags & ESdlThreadExplicitStop);	}void CDsa::SetOrientation(CSDL::TOrientationMode aOrientation)	{	TInt flags = 0;	switch(aOrientation)		{		case CSDL::EOrientation90:			flags = EOrientation90;			break;		case CSDL::EOrientation180:			flags = EOrientation180;			break;		case CSDL::EOrientation270:			flags = EOrientation90 | EOrientation180;			break;		case CSDL::EOrientation0:			flags = 0;			break;		}	if(flags != (iStateFlags & EOrientationFlags))		{		iStateFlags |= EOrientationChanged;		iNewFlags = flags; //cannot be set during drawing...		}	}CDsa::~CDsa()    {    iOverlays.Close();    User::Free(iLut256);    }         void CDsa::ConstructL(RWindow& aWindow, CWsScreenDevice& /*aDevice*/)    {				if(iLut256 == NULL)		iLut256 = (TUint32*) User::AllocL(256 * sizeof(TUint32));	iTargetMode = aWindow.DisplayMode();	iTargetBpp = BytesPerPixel(DisplayMode());	iScreenRect = TRect(aWindow.Position(), aWindow.Size());	SetTargetRect();    }    void CDsa::DrawOverlays()	{	const TInt last = iOverlays.Count() - 1;	for(TInt i = last; i >= 0 ; i--)		iOverlays[i].iOverlay->Draw(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;	}		    CDsa::CDsa(RWsSession& aSession) :  	iStateFlags(0), 	iSession(aSession)  	{//	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 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;

⌨️ 快捷键说明

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