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

📄 dsa_new.cpp

📁 SDL库 在进行视频显示程序spcaview安装时必须的库文件
💻 CPP
📖 第 1 页 / 共 3 页
字号:
		}			if(iSourceMode != DisplayMode() ||  targetRect != sourceRect || targetRect != updateRect || ((iStateFlags & EOrientationFlags) != 0))		{		sourceRect.Intersection(targetRect); //so source always smaller or equal than target		//updateRect.Intersection(targetRect);		ClipCopy(target, aBits, updateRect, sourceRect);		}	else		{		const TInt byteCount = aRect.Width() * aRect.Height() * iSourceBpp; //this could be stored		Mem::Copy(target, aBits, byteCount);		}	return ETrue;	}	*/	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 = Rect();	TRect sourceRect = aRect;	TRect updateRect = aUpdateRect;		if(iStateFlags & EOrientation90)		{		Rotate(sourceRect);		Rotate(updateRect);		}			if(iSourceMode != DisplayMode() ||  targetRect != sourceRect || targetRect != updateRect || ((iStateFlags & EOrientationFlags) != 0))		{		sourceRect.Intersection(targetRect); //so source always smaller or equal than target		updateRect.Intersection(targetRect);		ClipCopy(target, aBits, updateRect, sourceRect.iTl);		}	else		{		const TInt byteCount = aRect.Width() * aRect.Height() * iSourceBpp; //this could be stored		Mem::Copy(target, aBits, byteCount);		}	return ETrue;	}	void CDsa::UpdateSwSurface()	{	iTargetAddr = NULL;	UnlockHwSurface();	//could be faster if does not use AO, but only check status before redraw, then no context switch needed	}	void CDsa::Resume()		{	if(Stopped())		Restart(RDirectScreenAccess::ETerminateRegion);	}	void CDsa::DoStop()	{	if(IsDsaAvailable())		iStateFlags |= ESdlThreadExplicitStop;	Stop();	}	void CDsa::Stop()	{	iStateFlags &= ~ERunning;//	Cancel(); //can be called only from main!	iDsa->Cancel();	}	void CDsa::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/)	{//	iStateFlags |= EChangeNotify;	Stop();	}	void CDsa::Restart(RDirectScreenAccess::TTerminationReasons aReason)	{	if(aReason == RDirectScreenAccess::ETerminateRegion) //auto restart		{														TRAPD(err, RestartL());		PANIC_IF_ERROR(err);		}	}	void CDsa::SetBlitter(MBlitter* aBlitter)	{	iBlitter = aBlitter;	}		TPoint CDsa::WindowCoordinates(const TPoint& aPoint) const		{	TPoint pos = aPoint - iScreenRect.iTl;	const TSize asz = iScreenRect.Size();	if(iStateFlags & EOrientation180)		{		pos.iX = asz.iWidth - pos.iX;		pos.iY = asz.iHeight - pos.iY;			}		if(iStateFlags & EOrientation90)		{		pos.iX = aPoint.iY;		pos.iY = aPoint.iX;			}	pos.iX <<= 16;	pos.iY <<= 16;	pos.iX /= asz.iWidth; 	pos.iY /= asz.iHeight;	pos.iX *= iSwSize.iWidth;	pos.iY *= iSwSize.iHeight;	pos.iX >>= 16;	pos.iY >>= 16;	return pos; 		}	void CDsa::SetTargetRect()	{	iTargetRect = iScreenRect;	if(iStateFlags & EResizeRequest && EpocSdlEnv::Flags(CSDL::EAllowImageResizeKeepRatio))		{		const TSize asz = iScreenRect.Size();		const TSize sz = iSwSize;				TRect rect;				const TInt dh = (sz.iHeight << 16) / sz.iWidth;		if((asz.iWidth * dh ) >> 16 <= asz.iHeight)			{			rect.SetRect(TPoint(0, 0), TSize(asz.iWidth, (asz.iWidth * dh) >> 16));			}		else			{			const TInt dw = (sz.iWidth << 16) / sz.iHeight;	    	rect.SetRect(TPoint(0, 0), TSize((asz.iHeight * dw) >> 16, asz.iHeight));			}		rect.Move((asz.iWidth - rect.Size().iWidth) >> 1, (asz.iHeight - rect.Size().iHeight) >> 1);  				iTargetRect = rect;		iTargetRect.Move(iScreenRect.iTl);		} 	if(!(iStateFlags & EResizeRequest))		iSwSize = iScreenRect.Size();//	iScanLineWidth = /*iTargetBpp **/ SwSize().iWidth;	}		/*)TBool CDsa::ChangeTrigger()	{	const TBool change = iStateFlags & EChangeNotify;	iStateFlags &= ~EChangeNotify;	return change;	}*/	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////void CDsa::Copy256(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)	{	TUint32* target = aTarget;	const TUint32* endt = target + aBytes; 	const TUint8* source = aSource;	while(target < endt)		{		*target++ = aDsa.iLut256[*source++]; 		}	}	void CDsa::Copy256Reversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)	{	const TUint32* target = aTarget;	TUint32* endt = aTarget + aBytes; 	const TUint8* source = aSource;	while(target < endt)		{		*(--endt) = aDsa.iLut256[*source++]; 		}	}		void CDsa::Copy256Flip(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)	{	TUint32* target = aTarget;	const TUint32* endt = target + aBytes; 	const TUint8* column = aSource;	while(target < endt)		{		*target++ = aDsa.iLut256[*column];		column += aLineLen;		}	}	void CDsa::Copy256FlipReversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)	{	const TUint32* target = aTarget;	TUint32* endt = aTarget + aBytes; 	const TUint8* column = aSource;	while(target < endt)		{		*(--endt) = aDsa.iLut256[*column];		column += aLineLen;		}	}		void CDsa::CopyMem(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)	{	const TUint32* src = reinterpret_cast<const TUint32*>(aSource);	Mem::Copy(aTarget, src, aBytes << 2);	}	void CDsa::CopyMemFlip(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)	{	TUint32* target = aTarget;	const TUint32* endt = target + aBytes; 	const TUint32* column = reinterpret_cast<const TUint32*>(aSource);	while(target < endt)		{		*target++ = *column;		column += aLineLen;		}	}	void CDsa::CopyMemReversed(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)	{	const TUint32* target = aTarget;	TUint32* endt = aTarget + aBytes; 	const TUint32* source = reinterpret_cast<const TUint32*>(aSource);	while(target < endt)		{		*(--endt) = *source++; 		}	}			void CDsa::CopyMemFlipReversed(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)	{	const TUint32* target = aTarget;	TUint32* endt = aTarget + aBytes; 	const TUint32* column = reinterpret_cast<const TUint32*>(aSource);	while(target < endt)		{		*(--endt) = *column;		column += aLineLen;		}	}			/*LOCAL_C TRgb rgb16MA(TInt aValue)	{	return TRgb::Color16MA(aValue);	}*/	NONSHARABLE_CLASS(MRgbCopy)	{	public:	virtual void Copy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TBool aReversed) = 0;	virtual void FlipCopy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen, TBool aReversed) = 0;	};	template <class T>NONSHARABLE_CLASS(TRgbCopy) : public MRgbCopy	{	public:	TRgbCopy(TDisplayMode aMode);	void* operator new(TUint aBytes, TAny* aMem);	void Copy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TBool aReversed);	void FlipCopy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen, TBool aReversed);	static TUint32 Gray256(const TUint8& aPixel);	static TUint32 Color256(const TUint8& aPixel);	static TUint32 Color4K(const TUint16& aPixel);	static TUint32 Color64K(const TUint16& aPixel);	static TUint32 Color16M(const TUint32& aPixel);	static TUint32 Color16MU(const TUint32& aPixel);	static TUint32 Color16MA(const TUint32& aPixel);	private:		typedef TUint32 (*TRgbFunc) (const T& aValue);		TRgbFunc iFunc;	};				template <class T>		void* TRgbCopy<T>::operator new(TUint /*aBytes*/, TAny* aMem)	{	return aMem;	}		template <class T>TRgbCopy<T>::TRgbCopy(TDisplayMode aMode)	{	switch(aMode)		{		case EGray256 : iFunc = (TRgbFunc) Gray256; break;		case EColor256 : iFunc =  (TRgbFunc) Color256; break;		case EColor4K : iFunc =  (TRgbFunc) Color4K; break;		case EColor64K : iFunc =  (TRgbFunc) Color64K; break;		case EColor16M : iFunc =  (TRgbFunc) Color16M; break;		case EColor16MU : iFunc =  (TRgbFunc) Color16MU; break;		case EColor16MA : iFunc =  (TRgbFunc) Color16MA; break;		default:			PANIC(KErrNotSupported);		}	}	template <class T>void TRgbCopy<T>::Copy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TBool aReversed)	{	const T* source = reinterpret_cast<const T*>(aSource);	TUint32* target = aTarget;	TUint32* endt = target + aBytes;		if(aReversed)		{		while(target < endt)			{			const T value = *source++;			*(--endt) = iFunc(value);//iFunc(value).Value();			}		}	else		{		while(target < endt)			{			const T value = *source++;			*target++ = iFunc(value);//iFunc(value).Value();			}		}	}	template <class T>void TRgbCopy<T>::FlipCopy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen, TBool aReversed)	{	const T* column = reinterpret_cast<const T*>(aSource);	TUint32* target = aTarget;	TUint32* endt = target + aBytes;		if(aReversed)		{		while(target < endt)			{			*(--endt) = iFunc(*column);			column += aLineLen;			}		}	else		{		while(target < endt)			{			*target++ = iFunc(*column);			column += aLineLen;			}		}	}			template <class T> TUint32 TRgbCopy<T>::Gray256(const TUint8& aPixel)	{	const TUint32 px = aPixel << 16 | aPixel << 8 | aPixel;	return px;	}	template <class T> TUint32 TRgbCopy<T>::Color256(const TUint8& aPixel)	{	return TRgb::Color256(aPixel).Value();	}	template <class T> TUint32 TRgbCopy<T>::Color4K(const TUint16& aPixel)	{	TUint32 col = (aPixel & 0xF00) << 12;	col |= (aPixel & 0xF00) << 8; 		col |= (aPixel & 0x0F0) << 8;	col |= (aPixel & 0x0F0);		col |= (aPixel & 0x00F) << 4;	col |= (aPixel & 0x00F);		return col;	}	template <class T> TUint32 TRgbCopy<T>::Color64K(const TUint16& aPixel)	{	TUint32 col = (aPixel & 0xF800)<< 8;	col |= (aPixel & 0xE000) << 3; 		col |= (aPixel & 0x07E0) << 5;	col |= (aPixel & 0xC0) >> 1;		col |= (aPixel & 0x07E0) << 3;	col |= (aPixel & 0x1C) >> 2;		return col;	}	template <class T> TUint32 TRgbCopy<T>::Color16M(const TUint32& aPixel)	{	return TRgb::Color16M(aPixel).Value();	}	template <class T> TUint32 TRgbCopy<T>::Color16MU(const TUint32& aPixel)	{	return TRgb::Color16MU(aPixel).Value();	}	template <class T> TUint32 TRgbCopy<T>::Color16MA(const TUint32& aPixel)	{	return TRgb::Color16MA(aPixel).Value();	}typedef TUint64 TStackMem;LOCAL_C MRgbCopy* GetCopy(TAny* mem, TDisplayMode aMode)	{	if(aMode == EColor256 || aMode == EGray256)		{		return new (mem) TRgbCopy<TUint8>(aMode);		}	if(aMode == EColor4K || aMode == EColor64K)		{		return new (mem) TRgbCopy<TUint16>(aMode);		}	if(aMode == EColor16M || aMode == EColor16MU || aMode == EColor16MA)		{		return new (mem) TRgbCopy<TUint32>(aMode);		}	PANIC(KErrNotSupported);	return NULL;	}	void CDsa::CopySlowFlipReversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)	{	TStackMem mem = 0;	GetCopy(&mem, aDsa.iSourceMode)->FlipCopy(aTarget, aSource, aBytes, aLineLen, ETrue);		}	void CDsa::CopySlowFlip(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)	{	TStackMem mem = 0;	GetCopy(&mem, aDsa.iSourceMode)->FlipCopy(aTarget, aSource, aBytes, aLineLen, EFalse);	}	void CDsa::CopySlow(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)	{	TStackMem mem = 0;	GetCopy(&mem, aDsa.iSourceMode)->Copy(aTarget, aSource, aBytes, EFalse);		}	void CDsa::CopySlowReversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)	{	TStackMem mem = 0;	GetCopy(&mem, aDsa.iSourceMode)->Copy(aTarget, aSource, aBytes, ETrue);		}	////////////////////////////////////////////////////////////////////////////////////////////////////////////////7

⌨️ 快捷键说明

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