line.cpp

来自「WinCE 3.0 BSP, 包含Inter SA1110, Intel_815」· C++ 代码 · 共 189 行

CPP
189
字号
#include "precomp.h"


//////////////////////////////////////////////////////////////////////////////////////

SCODE MQGC::Line(
	GPELineParms *pLineParms,
	EGPEPhase phase )
{
	DEBUGMSG(GPE_ZONE_LINE,(TEXT("S3Trio64::Line\r\n")));

//	pLineParms->pLine = EmulatedLine;
//
//	return	S_OK;

#ifdef ENABLE_2D
	//Conditions for handling line acceleration:
	// - must be single width and this is a line prepare phase
	// - dest in video memory
	// - no style being specified (make sure no Rop4 )
	// - Can't handle 24bpp
	if((phase == gpeSingle || phase == gpePrepare)
			&& pLineParms->pDst->InVideoMemory()
	#ifdef BUG_LINE_DST_ROP
			&& pLineParms->mix == 0x0d0d
	#else
			&& !pLineParms->style
	#endif

	#ifdef CHECK_24BPP
			&& m_ulBPPSelect != CDEPTH_24BPP
	#endif
			&& (m_ulBPP >= 8)
	   )
	{
		pLineParms->pLine = (SCODE (GPE::*)(struct GPELineParms *))
											SolidLine;
		// if( pLineParms->mix == 0x0B07 )	   .. dotted line
	}
	else
	{
//	pLineParms->pLine = pEMULATED_LINE;
		pLineParms->pLine = EmulatedLine;
  	}

#else	//ENABLE_2D

//	pLineParms->pLine = pEMULATED_LINE;
	pLineParms->pLine = EmulatedLine;

#endif	//ENABLE_2D
	return S_OK;
}

#ifdef ENABLE_2D
#define	Y_MAJOR	0x20000000L
#define	X_MAJOR	0x00000000L

//Quadrant 1, 2, 5, 6 falls into Y-Major
//Quadrant 0, 3, 4, 7 falls into X-Major
//Use this formula to set bit 29 if Y-Major:
//   ((dir + 1) & 2) << 28

//Quadrant  0, 1 +X,+Y
//Quadrant  2, 3 -X,+Y
//Quadrant  4, 5 -X,-Y
//Quadrant  6, 7 +X,-Y

static DWORD	Rop2List[16] =
{ 0x00UL, 0x05UL, 0x0AUL, 0x0FUL, 0x50UL, 0x55UL, 0x5AUL, 0x5FUL,
  0xA0UL, 0xA5UL, 0xAAUL, 0xAFUL, 0xF0UL, 0xF5UL, 0xFAUL, 0xFFUL };

SCODE MQGC::SolidLine( GPELineParms *pLineParms )
{
	ULONG	ulMajor;
	ULONG	xdir;
	ULONG	ulGamma;
	ULONG	dstx, dsty;
	ULONG	iDir;

#ifdef DO_TIMINGS
	LARGE_INTEGER	LargeInt;
	QueryPerformanceCounter (&LargeInt);
	v_TimerStart = LargeInt.LowPart;
#endif
	
	DEBUGMSG(GPE_ZONE_LINE,(TEXT("SolidLine\r\n")));

#ifdef DO_TIMINGS
	QueryPerformanceCounter (&LargeInt);
	v_LineTotal += LargeInt.LowPart - v_TimerStart;
	v_LineCount++;
#endif

#ifndef	HW_ROTATE
	ROTATE_LINE_PARAMS(pLineParms);
#endif;

	geINIT( pLineParms->pDst );

	//Use SRC+DST ROP2 code

	iDir = pLineParms->iDir;

	dstx = pLineParms->xStart + ((MQGCSurf *)pLineParms->pDst)->m_ulLeft;
	dsty = pLineParms->yStart + ((MQGCSurf *)pLineParms->pDst)->m_ulTop;
#ifdef	HW_ROTATE
//	RETAILMSG(1, (TEXT("Before Rotate:dstx=0x%08x, dsty=0x%08x,iDir=0x%08x\r\n"),
//			dstx,dsty,iDir));
	HW_ROTATE_LINE( &dstx, &dsty, &iDir);
//	RETAILMSG(1, (TEXT("After Rotate:dstx=0x%08x, dsty=0x%08x,iDir=0x%08x\r\n"),
//			dstx,dsty,iDir));
#endif
	ulMajor = (ULONG)(iDir + 1) & 2;
	xdir = ((ULONG)(iDir ^ (iDir << 1)) << 9) & X_DIR;

	if ( pLineParms->dN || ulMajor )
	{	//If either dN <> 0 or Y-Major, must be non horizontal
		ulGamma = (ULONG)(pLineParms->llGamma) & 0x1FFFFUL;
		geWAITCMDFIFO( 5 );
		geREG(LINE_DRAW, 	(ulGamma
								| (pLineParms->cPels << 17)
						 		| (ulMajor << 28)));
								//| ((pLineParms->cPels & 0xFFFUL) << 17)
		geREG(LINE_MAJOR_X,	(dstx | ((pLineParms->dM & 0x1FFFFUL) << 12)));
		geREG(LINE_MINOR_Y,	(dsty | ((pLineParms->dN & 0x1FFFFUL) << 12)));
		geREG(FG_COLOR,		pLineParms->solidColor);
		SET_GE_DEST_STRIDE(m_ulDestStride);
	#ifdef BUG_LINE_DST_ROP
		geREG(DRAW_CMD,		(DO_LINEDRAW | MONO_SRC | MONO_SOLID | 0xCCUL | xdir
							| (((ULONG)iDir << 10) & Y_DIR)));
	#else
		geREG(DRAW_CMD,		(DO_LINEDRAW | MONO_SRC | MONO_SOLID | ROP2_ENABLE
							| xdir | (((ULONG)iDir << 10) & Y_DIR)
							| ((pLineParms->mix - 1) & 0xFF)));
	#endif

#ifdef BUG_LINE_NEED_DUMMY2
	if ( ((ulGamma & 0xFFF) >> 4) <= (ULONG)pLineParms->cPels )
	{	//A potential next SrcFIFO overflow could happen if no
		//additional GE operation is performed here!  Do a dummy
		//1x1 rectangle fill by using xor on solid pattern of 0
		geWAITCMDFIFO( 3 );
		geREG(WIDTH_HEIGHT,	0x00010001);
		geREG(PAT_FG_COLOR,	0x00000000);
		geREG(DRAW_CMD,		(DO_BITBLT | MONO_SOLID | MONO_PATTERN | 0x5A));
	}
#else	 //BUG_LINE_NEED_DUMMY2
	#ifdef BUG_LINE_NEED_DUMMY
	// Insert dummy src copy here to fix bug seen on rev. A
	geWAITCMDFIFO(4);
	geREG(WIDTH_HEIGHT,		0x00010001);
	geREG(DEST_XY,			0x00000000);
	geREG(SRC_XY,			0x00000000);
	// Do src copy from the same source and destination 
	geREG(DRAW_CMD,			DO_BITBLT|0xCC);
	#endif	//BUG_LINE_NEED_DUMMY
#endif		//BUG_LINE_NEED_DUMMY2
	}
	else
	{	//Must be horizontal.  Use Rectangle Fill method.
		geWAITCMDFIFO(4);
		geREG(WIDTH_HEIGHT, 	(0x10000UL + pLineParms->cPels));
		geREG(DEST_XY,			((dsty << 16) | dstx));
	#ifdef BUG_LINE_DST_ROP
		geREG(FG_COLOR, 		pLineParms->solidColor);
		geREG(DRAW_CMD,			(DO_BITBLT | MONO_SRC | MONO_SOLID | 0xCCUL
								| xdir));
	#else
		geREG(PAT_FG_COLOR, 	pLineParms->solidColor);
		geREG(DRAW_CMD,			(DO_BITBLT| MONO_PATTERN | MONO_SOLID | xdir
								| Rop2List[(pLineParms->mix - 1) & 0xF]));
		//geREG(FG_COLOR, 		pLineParms->solidColor);
		//geREG(DRAW_CMD,		(DO_BITBLT| ROP2_ENABLE | MONO_SRC | MONO_SOLID
		//						| xdir | ((pLineParms->mix - 1) & 0xFF)));
	#endif	//BUG_LINE_DST_ROP
	}

	geTERMINATE();

#ifndef	HW_ROTATE
	ROTATE_LINE_PARAMS_BACK(pLineParms);
#endif

	RETURN_SOLIDLINE;
}

#endif	//ENABLE_2D

⌨️ 快捷键说明

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