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

📄 lines.cpp

📁 Lido PXA270平台开发板的最新BSP,包括源代码
💻 CPP
字号:
/***************************************************************************
 * Name        : lines.cpp
 * Title       : MBX WinCE driver GPE class
 * Author(s)   : Imagination Technologies
 * Created	   : 12th February 2003
 *
 * Copyright   : 2003 by Imagination Technologies. All rights reserved.
 *             : No part of this software, either material or conceptual 
 *             : may be copied or distributed, transmitted, transcribed,
 *             : stored in a retrieval system or translated into any 
 *             : human or computer language in any form by any means,
 *             : electronic, mechanical, manual or other-wise, or 
 *             : disclosed to third parties without the express written
 *             : permission of Imagination Technologies Limited, Unit 8,
 *             : HomePark Industrial Estate, King's Langley, Hertfordshire,
 *             : WD4 8LZ, U.K.
 *
 * Description : MBX WinCE driver accelerated line drawing routines
 *
 * Platform    : WinCE
 *
 * Modifications:-
 * $Log: lines.cpp $
 *
 *  --- Revision Logs Removed --- 
 *
 *  --- Revision Logs Removed --- 
 *
 *  --- Revision Logs Removed --- 
 *
 ****************************************************************************/

#include	"precomp.h"
#include	"pvr_debug.h"

extern "C"
{
#include	"drvescape.h"
#include	"bltfuncs.h"

#include	"dispperf.h"
}

extern BYTE gaMix[17];		// declared in ddi_if.cpp


/*****************************************************************************
 FUNCTION	: 	MBX::Line

 PURPOSE	:	Prepares for a line drawing operation.

 PARAMETERS	: 	GPELineParms and phase

 RETURNS	: 	S_OK = 0 for success. (winerror.h)
*****************************************************************************/
SCODE MBX::Line(GPELineParms *psLineParameters, EGPEPhase phase)
{
	BYTE byRop;

	DPFX(PVR_ZONE_LINE, (L"MBX::Line"));

	if (phase == gpeSingle || phase == gpePrepare)
	{
        DispPerfStart(ROP_LINE);

		psLineParameters->pLine = EmulatedLine; /* Default to unaccellerated */

#ifdef DEBUG
		if (m_bPunt)
		{
			return (S_OK);
		}
#endif

		/*
			Note : Line params always come down unrotated.
			This is because we have copied the rotation-aware version
			of Microsoft's drvstrok.cpp into our gpe directory thereby forcing it always
			to be built into our driver.
			This unrotates all the params so we can do an unrotated line blt.
			Therefore we don't need to punt rotated lines, and also they
			are pre-optimised as unrotated equivalents.
		*/

		byRop = psLineParameters->mix & 0x0F;

#ifdef LOCAL_MEMORY_SELF_REFRESH
				SysLocalMemoryEnable(m_sDevData.psDevInfoKM);
#endif // LOCAL_MEMORY_SELF_REFRES

		/* We only accelerate solid lines, not the styled variety. */
		if (byRop == psLineParameters->mix>>8)
		{
			if ( ((MBXSurf*)(psLineParameters->pDst))->InVideoMemory() )
			{
#ifdef SW_SIM
				m_bDoProcessBltData = TRUE;
#endif

#if !defined NO_2D_CLOCKCONTROL
#if defined TIMED2DGATING
				/* inc Ops count, Enable if OP count was zero or if we're synchronised*/
				m_sDevData.psDevInfoKM->sDeviceSpecific.s3D.ui32OpsCount++;
				if (SysCoreQuery(DEV_CGCORE_MBX_2D) == IMG_FALSE)
				{
					SysCoreEnable(m_sDevData.psDevInfoKM, DEV_CGCORE_MBX_2D, IMG_TRUE);
				}
#else
				SysCoreEnable(m_sDevData.psDevInfoKM, DEV_CGCORE_MBX_2D, IMG_TRUE);
#endif
#endif /* NO_2D_CLOCKCONTROL */

				DispPerfType(DISPPERF_ACCEL_HARDWARE);

				/* set batch write index */
				SlavePortInitWrites();

				psLineParameters->pLine = (SCODE (GPE::*)(struct GPELineParms *)) AcceleratedSolidLine;

				/* Set dest format etc. */
				SetDstSurf(psLineParameters);

				/* Convert and save the line ROP */
				m_bySolidLineRop = gaMix[byRop];
			}
		}

		if ((psLineParameters->pLine == EmulatedLine) && /* unaccellerated */
			( m_bMBXBltActioned))
		{
			SyncWithHost();
		}
	}

	else if (phase == gpeComplete)
	{
#ifdef SW_SIM
		if (m_bDoProcessBltData)
		{
			m_bDoProcessBltData = FALSE;
			ProcessBltData();
			InitBlt();
		}
#endif
		if ((psLineParameters->pLine != EmulatedLine) &&
			(m_bForceSyncWithHost == TRUE))
		{
			SyncWithHost();	/* Flush out the last few writes. */
		}

		/* If the destination was on-screen then update the single shot mode */
		if (psLineParameters->pDst == m_pPrimarySurface)
		{
			m_clDisplay.PDP_ScreenUpdate();
		}
#if !defined TIMED2DGATING && !defined NO_2D_CLOCKCONTROL
		if (SysCoreQuery(DEV_CGCORE_MBX_2D) == IMG_TRUE)
		{
			SysCoreDisable(m_sDevData.psDevInfoKM, DEV_CGCORE_MBX_2D, IMG_FALSE);
		}
#endif
#ifdef LOCAL_MEMORY_SELF_REFRESH
		SysLocalMemoryDisable(m_sDevData.psDevInfoKM);
#endif // LOCAL_MEMORY_SELF_REFRESH

		DispPerfEnd(0);

	}
	
	return (S_OK);
}


/*****************************************************************************
 FUNCTION	: 	MBX::AcceleratedSolidLine

 PURPOSE	:	Accelerates a line, but if it's diagonal it punts it to GPE.

 PARAMETERS	: 	GPELineParms

 RETURNS	: 	S_OK = 0 for success. (winerror.h)
*****************************************************************************/
SCODE MBX::AcceleratedSolidLine(GPELineParms *psLineParms)
{
	ULONG	ulWidth = 1;
	ULONG	ulHeight = 1;
	LONG	lStartX = psLineParms->xStart;
	LONG	lStartY = psLineParms->yStart;
	
	DPFX(PVR_ZONE_LINE, (L"MBX::Line, colour %08X", psLineParms->solidColor));
	
#ifdef LOCAL_MEMORY_SELF_REFRESH
	SysLocalMemoryEnable(m_sDevData.psDevInfoKM);
#endif // LOCAL_MEMORY_SELF_REFRESH
	
	/* Is it a diagonal line ? */
	if (psLineParms->dN)
	{
		/* We can't accelerate diagonals, so use EmulatedLine() */
		DPFX(PVR_ZONE_LINE, (L"MBX::not vert or horiz line, so use EmulatedLine() to render"));

		if (m_bMBXBltActioned)
		{
			SyncWithHost();
		}

		psLineParms->pLine = EmulatedLine;	/* Default to unaccellerated */

#ifdef LOCAL_MEMORY_SELF_REFRESH
		SysLocalMemoryDisable(m_sDevData.psDevInfoKM);
#endif // LOCAL_MEMORY_SELF_REFRESH
		return	WrappedEmulatedLine(psLineParms);
	}

	/* Line is vertical or horizontal */
	switch (psLineParms->iDir & 0x07)		/* Which quadrant is the line vector in ? */
	{
		/* Right to left */
		case 3:
		case 4:
			ulWidth = psLineParms->cPels;
			lStartX -= ulWidth - 1;			/* Make it a forwards blt */
			break;

		/* Left to right */
		case 7:
		case 0:
			ulWidth = psLineParms->cPels;
			break;
		
		/* Bottom to top */
		case 5:
		case 6:
			ulHeight = psLineParms->cPels;
			lStartY -= ulHeight - 1;		// Make it a forwards blt
			break;

		/* Top to bottom */
		case 1:
		case 2:
			ulHeight = psLineParms->cPels;
			break;
	}

	/* Acquire slave port */
	if ( PVRSRVAcquireSlavePort(m_sDevData.psDevInfoKM, PVRSRV_SLAVEPORT_2D, IMG_TRUE)==PVRSRV_OK)
	{
		m_bSlavePortAquired = TRUE;

		/* record that a sync is required if we fallback to SW */
		m_bMBXBltActioned = TRUE;

#if defined TIMED2DGATING && !defined NO_2D_CLOCKCONTROL 
		/* inc Ops count, Enable if OP count was zero or if we're synchronised */
		m_sDevData.psDevInfoKM->sDeviceSpecific.s3D.ui32OpsCount++;
		if (SysCoreQuery(DEV_CGCORE_MBX_2D) == IMG_FALSE)
		{
			SysCoreEnable(m_sDevData.psDevInfoKM, DEV_CGCORE_MBX_2D, IMG_TRUE);
		}
#endif

		DispPerfSlaveport(TRUE);

		SlavePortWrite(MBX2D_BLIT_BH | ( (WORD)((WORD) m_bySolidLineRop | (WORD) m_bySolidLineRop<<8) /* Rop4 */
						& MBX2D_ROP4_MASK) | MBX2D_USE_FILL);

		SlavePortWrite((ULONG)psLineParms->solidColor & MBX2D_FILLCOLOUR_MASK); 				/* Solid Colour */

		SlavePortWrite((((SHORT)lStartY) & MBX2D_DST_YSTART_MASK) 								/* YStart */
						| ((((SHORT)lStartX)<<MBX2D_DST_XSTART_SHIFT)&MBX2D_DST_XSTART_MASK) ); /* XStart */

		SlavePortWrite(((SHORT)((SHORT) lStartY + (SHORT)ulHeight) & MBX2D_DST_YEND_MASK) 		/* YEnd */
						| (((SHORT)((SHORT) lStartX + (SHORT)ulWidth)<<MBX2D_DST_XEND_SHIFT)&MBX2D_DST_XEND_MASK) ); /* XEnd */

		SlavePortFencedWrites();

		DispPerfSlaveport(FALSE);
	}
	else
	{
		/* Slave port not available */
		psLineParms->pLine = EmulatedLine;
		DebugBreak();
#ifdef LOCAL_MEMORY_SELF_REFRESH
		SysLocalMemoryDisable(m_sDevData.psDevInfoKM);
#endif // LOCAL_MEMORY_SELF_REFRESH
		return	WrappedEmulatedLine(psLineParms);
	}

	/* Release slave port */
	if (m_bSlavePortAquired)
	{
		PVRSRVReleaseSlavePort(m_sDevData.psDevInfoKM, PVRSRV_SLAVEPORT_2D);
		m_bSlavePortAquired = FALSE;
	}

#ifdef LOCAL_MEMORY_SELF_REFRESH
	SysLocalMemoryDisable(m_sDevData.psDevInfoKM);
#endif // LOCAL_MEMORY_SELF_REFRESH
	return (S_OK);
}

SCODE MBX::WrappedEmulatedLine(GPELineParms *psLineParameters)
{
#ifdef LOCAL_MEMORY_SELF_REFRESH
	SysLocalMemoryEnable(m_sDevData.psDevInfoKM);
#endif // LOCAL_MEMORY_SELF_REFRESH
	EmulatedLine(psLineParameters);
#ifdef LOCAL_MEMORY_SELF_REFRESH
	SysLocalMemoryDisable(m_sDevData.psDevInfoKM);
#endif // LOCAL_MEMORY_SELF_REFRESH
	return S_OK;
}


/********************************** end of file ******************************/

⌨️ 快捷键说明

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