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

📄 bltfuncs.cpp

📁 Lido PXA270平台开发板的最新BSP,包括源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
					PDumpScript("-- Rotated mask blt, mask is in Video memory");
				}
			}
		}
		#endif

		if (lBltRotation )
		{
			/* Flag this as a rotated blt */
			#ifdef ENABLE_2D_PROFILE
			profile_rotate(m_sActiveNode);
			#endif
		}
	}
	else
	{
		if (psBlitParameters->pSrc && psBlitParameters->pSrc->InVideoMemory())
		{
			ASSERT (((MBXSurf*)(psBlitParameters->pSrc))->m_lRotationAngle == 0);
		}

		m_ulBltRotationHw = MBX2D_TEXTROT_NONE;
	}
	#else
	m_ulBltRotationHw = MBX2D_TEXTROT_NONE;
	#endif /* #ifdef ROTATE_ENABLE */

	if ((m_ulSurfsPresent & PAT_PRESENT))
	{
		if (!SetPatSurf(psBlitParameters))
		{
			return (FALSE);
		}
	}

	if ((m_ulSurfsPresent & SRC_PRESENT))
	{
		if (!CheckSrcPalette(psBlitParameters))
		{
			return (FALSE);
		}
	}

	if ((m_ulSurfsPresent & MASK_PRESENT))
	{
		if (!CanCreateMaskSurf(psBlitParameters))
		{
			return (FALSE);
		}
	}

	/* acquire slave port */
	PVRSRVAcquireSlavePort(m_sDevData.psDevInfoKM, PVRSRV_SLAVEPORT_2D, IMG_TRUE);
	m_bSlavePortAquired = TRUE;

/****************************************************************************
	 * We have several different HW blit functions:
	 * ROP3s:
	 *  FillBlt
	 *  SrcBlt (inc. SrcFillBlt)
	 *  PatBlt
	 *  SrcPatBlt
	 * ROP4s(includes standard text):
	 *  MaskFillBlt
	 *  MaskSrcBlt (inc. MaskSrcFillBlt)
	 *  MaskPatBlt
	 *  MaskSrcPatBlt
	 *  ColourKey
	 *  AlphaBlends:
	 *  AAText
	 *
	 ****************************************************************************/

	/* Let's find out which function we want */
	if ((psBlitParameters->rop4 == 0xAAF0) && (psBlitParameters->pMask->Format() == gpe4Bpp))
	{
		/* antialiased (alpha-blended) text */

		DPFX(PVR_ZONE_BLT,(L"AA Text Blit"));

		/* check for a DST change */
		if (psBlitParameters->pDst->Format() == gpe8Bpp)		/* 8bpp pal does not work as 332 */
		{
			goto HWPrepExit;
		}

		#ifdef PDUMP
		PDumpScript("-- Alpha Blend");
		#endif

		/*
		 * set up alpha blend:
		 * colour:	DstC = SrcC*SrcA + DstC*(1-SrcA)
		 * alpha:	DstA = SrcA + DstA*(1-SrcA)
		 */
		SlavePortWrite( MBX2D_CTRL_BH | MBX2D_ALPHA_CTRL );
		SlavePortWrite( MBX2D_SRCALPHA_OP_SRC 
						| MBX2D_DSTALPHA_OP_SRC | MBX2D_DSTALPHA_INVERT );

		psBlitParameters->pBlt = (SCODE (GPE::*)(struct GPEBltParms *))AATextBlt;
		m_eHWBltState = BLT_Setup;

		#ifdef ENABLE_2D_PROFILE
		if (!psBlitParameters->pMask->InVideoMemory())
		{
			profile_stripe(m_sActiveNode);
		}
		profile_reassign(m_sActiveNode, NODE_AATEXT);
		#endif

		goto HWPrepCont;			/* skips HWVerify */
	}
	else
	{
		switch (m_ulSurfsPresent)
		{
			/* ROP3s: */
			case 0 :				/* no surfs - must be dst only */
			case FILL_PRESENT :
				#ifdef PDUMP
				PDumpScript("-- Fill Blit");
				#endif

				psBlitParameters->pBlt = (SCODE (GPE::*)(struct GPEBltParms *))FillBlt;
				m_eHWBltState = BLT_Setup;

				#ifdef ENABLE_2D_PROFILE
				profile_reassign(m_sActiveNode, NODE_FILLBLT);
				#endif
				break;

			case FILL_PRESENT | MASK_PRESENT :
#if defined PUNT_TEXT
				#ifdef ENABLE_2D_PROFILE
				if (!psBlitParameters->pMask->InVideoMemory())
				{
					profile_stripe(m_sActiveNode);
				}
				profile_reassign(m_sActiveNode, NODE_TEXT);
				#endif
				goto HWPrepExit;
#else
				#ifdef PDUMP
				PDumpScript("-- Text Blit");
				#endif

				psBlitParameters->pBlt = (SCODE (GPE::*)(struct GPEBltParms *))TextBlt;
				m_eHWBltState = BLT_Setup;

				#ifdef ENABLE_2D_PROFILE
				if (!psBlitParameters->pMask->InVideoMemory())
				{
					profile_stripe(m_sActiveNode);
				}
				profile_reassign(m_sActiveNode, NODE_TEXT);
				#endif
				break;
#endif

			case SRC_PRESENT :
			case SRC_PRESENT | FILL_PRESENT :
			case SRC_PRESENT | MASK_PRESENT :
			case SRC_PRESENT | MASK_PRESENT | FILL_PRESENT :
				#ifdef PDUMP
				PDumpScript((m_ulSurfsPresent & MASK_PRESENT) ? "-- Mask Src Blit" : "-- Src Blit");
				#endif

				#ifdef ENABLE_2D_PROFILE
				if (psBlitParameters->bltFlags & BLT_TRANSPARENT)
				{
					profile_reassign(m_sActiveNode, NODE_TRANSPARENT_BLT);
				}
				#if defined (_WINCEOSVER) && (_WINCEOSVER >= 500)
				else if (psBlitParameters->bltFlags & BLT_ALPHABLEND)
				{
					profile_reassign(m_sActiveNode, NODE_ALPHABLEND_BLT);
				}
				#endif /* (_WINCEOSVER) && (_WINCEOSVER >= 500) */
				else
				{
					profile_reassign(m_sActiveNode, (m_ulSurfsPresent & MASK_PRESENT) ? NODE_MASKSRCBLT : NODE_SRCBLT);
				}
				#endif /* ENABLE_2D_PROFILE */
				
				if (psBlitParameters->bltFlags & BLT_TRANSPARENT)
				{
					#ifdef PDUMP
					PDumpScript("-- Src CK");
					#endif

					DWORD dwColour = psBlitParameters->solidColor;
					DWORD dwMask = (psBlitParameters->pDst->Format() == gpe16Bpp) ? 0xFFFF : 0x00FFFFFF;

					/*
					 * According to Jonathan the transparent colour does not need
					 * to be replicated into the higher bytes of the DWORD.
					 * NCJ. 3-JUL-2003
					 *
					 *
					 * MediaPlayer slider control fix. NCJ. 3-JUL-2003
					 * For an 8 bit palletised transparent source we must look up the
					 * transparent colour in the table and pass that on to MBX.
					 * It will already be in destination format as required by MBX.
					 */ 
					if ((psBlitParameters->pSrc->Format() <= gpe8Bpp) && psBlitParameters->pLookup)
					{
						/* HW bugfix 21st July 2004
						   The hardware appears to have trouble doing a compare if the least sig bit
						   of the green channel is set. The fix below unsets this bit.
						   The down side is that the colour is changed which doesn't effect CETK
						   but it might for other apps.
						   August 2004
						   Punt all non black/white palettised src bitmaps */
						if ((psBlitParameters->pLookup[dwColour] != 0x0000) &&
							(psBlitParameters->pLookup[dwColour] != dwMask))
						{
							goto HWPrepExit;
						}

						dwColour = psBlitParameters->pLookup[dwColour];
					}

					/* Internet explorer transparent colour fix. */
					if ((psBlitParameters->pDst->Format() == gpe16Bpp) && 
					    ((psBlitParameters->pSrc->Format() == gpe24Bpp) || (psBlitParameters->pSrc->Format() == gpe32Bpp))) 
					{
						// twiddle the colour
						DWORD dwColour16 = ((dwColour&0x00F80000)>>8) | ((dwColour&0x0000FC00)>>5) | ((dwColour&0x000000F8)>>3);
						dwColour = dwColour16;
					}

					SlavePortWrite( MBX2D_CTRL_BH | MBX2D_SRCCK_CTRL );
					SlavePortWrite( dwColour);
					SlavePortWrite( dwMask);		/* mask without alpha byte */
				}

				/*
				 * At this point we have punted src bitmaps which are not in video memory and < 8Bpp
				 */

				if (!psBlitParameters->pSrc->InVideoMemory())
				{
						
					if (psBlitParameters->pConvert)
					{
						ULONG ulResult = (psBlitParameters->pColorConverter->*(psBlitParameters->pConvert))(0x021F);
						if (ulResult > 0x0000FFFF)
						{
							/* punt rgb-> bgr */
							goto HWPrepExit;
						}
					}

					psBlitParameters->pBlt = (SCODE (GPE::*)(struct GPEBltParms *))StripedSrcBlt;

					#ifdef ENABLE_2D_PROFILE
					profile_stripe(m_sActiveNode);
					#endif
				}
				else
				{
					psBlitParameters->pBlt = (SCODE (GPE::*)(struct GPEBltParms *))SrcBlt;
				}

				m_eHWBltState = BLT_Setup;

				#ifdef ENABLE_2D_PROFILE
				if (psBlitParameters->bltFlags & BLT_TRANSPARENT)
				{
					profile_reassign(m_sActiveNode, NODE_TRANSPARENT_BLT);
				}
				#if defined (_WINCEOSVER) && (_WINCEOSVER >= 500)
				else if (psBlitParameters->bltFlags & BLT_ALPHABLEND)
				{
					profile_reassign(m_sActiveNode, NODE_ALPHABLEND_BLT);
				}
				#endif /* (_WINCEOSVER) && (_WINCEOSVER >= 500) */
				else
				{
					profile_reassign(m_sActiveNode, (m_ulSurfsPresent & MASK_PRESENT) ? NODE_MASKSRCBLT : NODE_SRCBLT);
				}
				#endif /* ENABLE_2D_PROFILE */
				break;

			case PAT_PRESENT :
			case PAT_PRESENT | MASK_PRESENT :
			case PAT_PRESENT | MASK_PRESENT | FILL_PRESENT :
				#ifdef PDUMP
				PDumpScript((m_ulSurfsPresent & MASK_PRESENT) ? "-- Mask Pat Blit" : "-- Pat Blit");
				#endif

				psBlitParameters->pBlt = (SCODE (GPE::*)(struct GPEBltParms *))PatBlt;
				m_eHWBltState = BLT_Setup;

				#ifdef ENABLE_2D_PROFILE
				profile_reassign(m_sActiveNode, (m_ulSurfsPresent & MASK_PRESENT) ? NODE_MASKPATBLT : NODE_PATBLT);
				#endif
				break;

			case SRC_PRESENT | PAT_PRESENT :
			case SRC_PRESENT | PAT_PRESENT | MASK_PRESENT :
			case SRC_PRESENT | PAT_PRESENT | MASK_PRESENT | FILL_PRESENT : 
				#ifdef PDUMP
				PDumpScript((m_ulSurfsPresent & MASK_PRESENT) ? "-- Mask SrcPat Blit" : "-- Src Pat Blit");
				#endif

				if (!psBlitParameters->pSrc->InVideoMemory())
				{
					if (psBlitParameters->pConvert)
					{
						ULONG ulResult = (psBlitParameters->pColorConverter->*(psBlitParameters->pConvert))(0x021F);
						if (ulResult > 0x0000FFFF)
						{
							/* punt rgb-> bgr */
							goto HWPrepExit;
						}
					}

					psBlitParameters->pBlt = (SCODE (GPE::*)(struct GPEBltParms *))StripedSrcBlt;

					#ifdef ENABLE_2D_PROFILE
					profile_stripe(m_sActiveNode);
					#endif

				}
				else
				{
					psBlitParameters->pBlt = (SCODE (GPE::*)(struct GPEBltParms *))SrcBlt;
				}

				m_eHWBltState = BLT_Setup;

				#ifdef ENABLE_2D_PROFILE
				profile_reassign( m_sActiveNode,
								 (m_ulSurfsPresent & MASK_PRESENT) ? NODE_MASKSRCPATBLT : NODE_SRCPATBLT);
				#endif
				break;

			/* drop out! */
			default:
				DPFINFO((L"We should never get here, SurfsPresent %.8X", m_ulSurfsPresent));
				goto HWPrepExit;
		}
	}

//HWPrepCont:
	#if HW_VERIFY
	if (m_eHWBltState == BLT_Setup)
	{
		if (m_clHwVer.IsVerifyEnabled())
		{
			m_pfnHWBlt = psBlitParameters->pBlt;
			psBlitParameters->pBlt = (SCODE (GPE::*)(struct GPEBltParms *))HwVerBlt;

			#ifdef ROTATE_ENABLE
			m_clHwVer.MakeVerifyRect(psBlitParameters, lDestRotation);
			#else
			m_clHwVer.MakeVerifyRect(psBlitParameters, 0);
			#endif
		}
	}
	#endif

HWPrepCont:
	bRtn = TRUE;

HWPrepExit:
	if (m_eHWBltState == BLT_Idle)
	{
		/* 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 (bRtn);
}


/*****************************************************************************
 FUNCTION	:	FillBlt

 PURPOSE	:	Fills a Rectangle with solid colour

 PARAMETERS	:	GPEBltParms *psParms

 RETURN		:	SC_OK or SC_FALSE
*****************************************************************************/
SCODE	MBX::FillBlt ( GPEBltParms *psParms )
{
	DPFX(PVR_ZONE_BLT,(L"FillBlt: rop4=%04X", psParms->rop4));

	#ifdef ENABLE_2D_PROFILE
	profile_start_blt_clip_rect(m_sActiveNode);
	#endif

	ASSERT (psParms->prclClip == NULL);
	ASSERT ((m_ulSurfsPresent & MASK_PRESENT) == 0);

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

	DispPerfSlaveport (TRUE);

	SetDstSurf(psParms);

	/* let's do the blit */
	SlavePortWrite( MBX2D_BLIT_BH
					|	(psParms->rop4 & MBX2D_ROP4_MASK)
					|	MBX2D_USE_FILL
					|	m_ulBltRotationHw );

	SlavePortWrite( psParms->solidColor & MBX2D_FILLCOLOUR_MASK);

	/* Write Destination rectangle to the Slave Port */
	WriteDestRect((MBXSurf *)psParms->pDst, psParms->prclDst);
	SlavePortFencedWrites();
		
	DispPerfSlaveport (FALSE);

#ifdef SW_SIM
	ProcessBltData();
	InitBlt();
#endif /* #ifdef SW_SIM */

	m_eHWBltState = BLT_InContProgress;

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

	#ifdef ENABLE_2D_PROFILE
	profile_end_blt_clip_rect(m_sActiveNode);
	#endif

	return (S_OK);

} /* FillBlt */


/*****************************************************************************
 FUNCTION	:	SrcBlt

 PURPOSE	:	Src and SrcFill Blitting

 PARAMETERS	:	GPEBltParms *psParms

 RETURN		:	SC_OK or SC_FALSE
*****************************************************************************/
SCODE	MBX::SrcBlt ( GPEBltParms *psParms )
{
	RECTL*	prclClip;
	RECTL*	prclDst = psParms->prclDst;
	ULONG	ulClipCount = 0;
	RECTL	rclSrc;
	ULONG   ulHWFormat;
	EGPEFormat eSrcFmt = psParms->pSrc->Format();
	EGPEFormat eDstFmt = psParms->pDst->Format();

	DPFX(PVR_ZONE_BLT,(L"SrcBlt: rop4=%04X", psParms->rop4));

#ifdef ENABLE_2D_PROFILE
	profile_start_blt_clip_rect(m_sActiveNode);
#endif

⌨️ 快捷键说明

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