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

📄 blt.cpp

📁 smdk2450 ce6 bsp,需要的朋友可以参考以下.
💻 CPP
📖 第 1 页 / 共 5 页
字号:

				/// X-axis mirror case. up-down inversion
				/// Swap left, right coordinate when 90 and 270 degree
				RETAILMSG(TEMP_DEBUG,(TEXT("S LRSWAP:%d,%d,%d,%d,%d,%d\n"),pBltParms->prclDst->left,pBltParms->prclDst->top,pBltParms->prclDst->right,pBltParms->prclDst->bottom, iRotate, m_oG2D->GetRotType(iRotate)));					
				SWAP(prclDst->left, prclDst->right, LONG);			
				/// Set Destination Clipping window Rect
				if(pBltParms->prclClip)
				{
					m_oG2D->SetClipWindow(pBltParms->prclClip);
				}
				else
				{
					m_oG2D->SetClipWindow(prclDst);
				}	
				
				EnterCriticalSection(&m_cs2D);
				m_oG2D->StretchBlt( &t_rect, prclDst, m_oG2D->GetRotType(iRotate));			
				LeaveCriticalSection(&m_cs2D);
				/// recover top, bottom coordinate
				SWAP(prclDst->left, prclDst->right, LONG);

				/// Disallocate Scratch Surface
				delete ScratchSurf;

				RETAILMSG(TEMP_DEBUG, (TEXT("Stretch X-axis flip: R:%d\r\n"),pBltParms->pDst->Rotate()));			
				
				return TRUE;
			}						
			RotateRectl(prclDst);
		}
		else		//< DMDO_0 and DMDO_180 does not need to modify prclDst region
		{
			RotateRectlBack(prclDst);
		 	if(prclDst->right < prclDst->left)
			{
				RotateRectl(prclDst);
				/// Allocation Scratch Framebuffer for Flip Operation.
				DDGPESurf *ScratchSurf;
				
				AllocSurface(&ScratchSurf, dwSrcWidth, dwSrcHeight, pBltParms->pDst->Format(), EGPEFormatToEDDGPEPixelFormat[pBltParms->pDst->Format()], GPE_REQUIRE_VIDEO_MEMORY);
				if(ScratchSurf == NULL)
				{
					RETAILMSG(TRUE,(TEXT("Scratch Surface Allocation is failed. %d\n"), __LINE__));
#if 0//USE_PACSURF, To increase video memory is better than to use system memory as Video Surface
					RETAILMSG(TRUE,(TEXT("try to allocate surface usign PA Surface\r\n")));
					PACSurf *ScratchSurf;
#endif
					RETAILMSG(TRUE,(TEXT("Maybe There's no sufficient video memory. please increase video memory\r\n")));
					RETAILMSG(TRUE,(TEXT("try to redirect to SW Emulated Bitblt\r\n")));		
					return FALSE;
				}
				

				/// Set Scratch Surface Information
				descScratch.dwBaseaddr = (IMAGE_FRAMEBUFFER_DMA_BASE + ScratchSurf->OffsetInVideoMemory());
				descScratch.dwColorMode = pBltParms->pDst->Format();
				descScratch.dwHoriRes = dwSrcWidth;
				descScratch.dwVertRes = dwSrcHeight;
			
				/// Set Destination Surface to Scratch Surface
				m_oG2D->SetDstSurface(&descScratch);
				/// Set Destination Clipping window Rect
				m_oG2D->SetClipWindow(&t_rect);
			
				/// Set Y-axis flip flag
				EnterCriticalSection(&m_cs2D);
				m_oG2D->FlipBlt( prclSrc, &t_rect,  FLIP_Y );
				LeaveCriticalSection(&m_cs2D);
				/// Y-axis mirror case. left-right inversion
				/// Set Source Address to Scratch Memory
				m_oG2D->SetSrcSurface(&descScratch);
				/// Set Destination Surface to real Framebuffer Surface
				m_oG2D->SetDstSurface(pdescDstSurface);

				/// Swap left, right coordinate
				RETAILMSG(TEMP_DEBUG,(TEXT("%d,%d,%d,%d\n"),pBltParms->prclDst->left,pBltParms->prclDst->top,pBltParms->prclDst->right,pBltParms->prclDst->bottom));			
				SWAP(prclDst->right, prclDst->left, LONG);
				/// Set Destination Clipping window Rect
				if(pBltParms->prclClip)
				{
					m_oG2D->SetClipWindow(pBltParms->prclClip);
				}
				else
				{
					m_oG2D->SetClipWindow(prclDst);
				}	
				
				RETAILMSG(TEMP_DEBUG,(TEXT("%d,%d,%d,%d\n"),pBltParms->prclDst->left,pBltParms->prclDst->top,pBltParms->prclDst->right,pBltParms->prclDst->bottom));			
				EnterCriticalSection(&m_cs2D);	
				m_oG2D->StretchBlt( &t_rect, prclDst, m_oG2D->GetRotType(iRotate));
				LeaveCriticalSection(&m_cs2D);		
				/// recover left, right coordinate
				SWAP(prclDst->right, prclDst->left, LONG);				

				/// Disallocate Scratch Surface
				delete ScratchSurf;

				RETAILMSG(TEMP_DEBUG, (TEXT("Stretch Y-axis flip: R:%d\r\n"),pBltParms->pDst->Rotate()));
				
				return TRUE;
			}
			if(prclDst->bottom < prclDst->top)
			{
				RotateRectl(prclDst);
				/// Allocation Scratch Framebuffer for Flip Operation.
				DDGPESurf *ScratchSurf;
				AllocSurface(&ScratchSurf, dwSrcWidth, dwSrcHeight, pBltParms->pDst->Format(), EGPEFormatToEDDGPEPixelFormat[pBltParms->pDst->Format()], GPE_REQUIRE_VIDEO_MEMORY);
				if(ScratchSurf == NULL)
				{
					RETAILMSG(TRUE,(TEXT("Scratch Surface Allocation is failed. %d\n"), __LINE__));
#if 0//USE_PACSURF, To increase video memory is better than to use system memory as Video Surface
					RETAILMSG(TRUE,(TEXT("try to allocate surface usign PA Surface\r\n")));
					PACSurf *ScratchSurf;
#endif
					RETAILMSG(TRUE,(TEXT("Maybe There's no sufficient video memory. please increase video memory\r\n")));
					RETAILMSG(TRUE,(TEXT("try to redirect to SW Emulated Bitblt\r\n")));		
					return FALSE;
				}
				

				/// Set Scratch Surface Information
				descScratch.dwBaseaddr = (IMAGE_FRAMEBUFFER_DMA_BASE + ScratchSurf->OffsetInVideoMemory());
				descScratch.dwColorMode = pBltParms->pDst->Format();
				descScratch.dwHoriRes = dwSrcWidth;
				descScratch.dwVertRes = dwSrcHeight;

				/// Set Destination Surface to Scratch Surface
				m_oG2D->SetDstSurface(&descScratch);
				/// Set Destination Clipping window Rect
				m_oG2D->SetClipWindow(&t_rect);
			
				/// Set X-axis flip flag
				EnterCriticalSection(&m_cs2D);
				m_oG2D->FlipBlt( prclSrc, &t_rect,  FLIP_X );
				LeaveCriticalSection(&m_cs2D);
				
				/// Set Source Address to Scratch Memory
				m_oG2D->SetSrcSurface(&descScratch);
				/// Set Destination Surface to real Framebuffer Surface
				m_oG2D->SetDstSurface(pdescDstSurface);

				/// X-axis mirror case. up-down inversion
				/// Swap top, bottom coordinate
				SWAP(prclDst->top, prclDst->bottom, LONG);			
				/// Set Destination Clipping window Rect
				if(pBltParms->prclClip)
				{
					m_oG2D->SetClipWindow(pBltParms->prclClip);
				}
				else
				{
					m_oG2D->SetClipWindow(prclDst);
				}	
				
				EnterCriticalSection(&m_cs2D);
				m_oG2D->StretchBlt( &t_rect, prclDst, m_oG2D->GetRotType(iRotate));			
				LeaveCriticalSection(&m_cs2D);
				/// recover top, bottom coordinate
				SWAP(prclDst->top, prclDst->bottom, LONG);

				/// Disallocate Scratch Surface
				delete ScratchSurf;

				RETAILMSG(TEMP_DEBUG, (TEXT("Stretch X-axis flip: R:%d\r\n"),pBltParms->pDst->Rotate()));			
				
				return TRUE;
			}				
			RotateRectlBack(prclDst);
		}
		/// This case does not need to flip.
		
		/// Set Destination Surface to real Framebuffer Surface
		m_oG2D->SetDstSurface(pdescDstSurface);
		/// Set Destination Clipping window Rect
		if(pBltParms->prclClip)
		{
			m_oG2D->SetClipWindow(pBltParms->prclClip);
		}
		else
		{
			m_oG2D->SetClipWindow(prclDst);
		}	
		
		EnterCriticalSection(&m_cs2D);	
		m_oG2D->StretchBlt( prclSrc, prclDst, m_oG2D->GetRotType(iRotate));
		LeaveCriticalSection(&m_cs2D);		

		RETAILMSG(TEMP_DEBUG, (TEXT("\nStretch no flip: R:%d\r\n"),pBltParms->pDst->Rotate()));		
	}
	else		// Do not stretch.
	{
		RotateRectl(prclSrc);
		RotateRectl(prclDst);	
	
		/// Set Source Surface Descriptor
		m_oG2D->SetSrcSurface(pdescSrcSurface);	

		/// Check whether XY flip or not, 
		///if XY flip is requested, just Rotation 180 degree
		RotateRectlBack(prclDst);
		if( ((pBltParms->bltFlags & BLT_STRETCH) == BLT_STRETCH)
			&& (prclDst->right < prclDst->left)  && (prclDst->bottom < prclDst->top) )
		{
			RotateRectl(prclDst);		
			switch(iRotate)
			{
				case DMDO_0:
					iRotate = DMDO_180;
					break;
				case DMDO_90:
					iRotate = DMDO_270;
					break;
				case DMDO_180:
					iRotate = DMDO_0;
					break;
				case DMDO_270:
					iRotate = DMDO_90;
					break;
			}

			/// Set Destination Surface to real Framebuffer Surface
			m_oG2D->SetDstSurface(pdescDstSurface);
			/// Set Destination Clipping window Rect
			if(pBltParms->prclClip)
			{
				m_oG2D->SetClipWindow(pBltParms->prclClip);
			}
			else
			{
				m_oG2D->SetClipWindow(prclDst);
			}	
			
			/// SWAP rect
			SWAP(prclDst->top, prclDst->bottom, LONG);
			SWAP(prclDst->left, prclDst->right, LONG);			
		
			EnterCriticalSection(&m_cs2D);	
			m_oG2D->BitBlt( prclSrc, prclDst, m_oG2D->GetRotType(iRotate));
			LeaveCriticalSection(&m_cs2D);				
			/// Recover rect
			SWAP(prclDst->top, prclDst->bottom, LONG);
			SWAP(prclDst->left, prclDst->right, LONG);			

			RETAILMSG(TEMP_DEBUG,(TEXT("XY Flip R:%d\n"), iRotate));
			
			return TRUE;
			
		}
		//RotateRectl(prclDst);			
		//RotateRectlBack(prclDst);

		/// Mirroring is needed.
		if( ((pBltParms->bltFlags & BLT_STRETCH) == BLT_STRETCH) 
			&&  ((prclDst->left > prclDst->right) || (prclDst->top > prclDst->bottom) )
			)
		{
			RotateRectl(prclDst);	
			
			RECTL t_rect;
			DWORD	dwSrcWidth;
			DWORD	dwSrcHeight;
			SURFACE_DESCRIPTOR descScratch;
		
			dwSrcWidth = ABS(prclSrc->right - prclSrc->left);
			dwSrcHeight  = ABS(prclSrc->bottom - prclSrc->top);

			/// Set Scratch Destination Region		
			t_rect.left = 0;
			t_rect.top = 0;
			t_rect.right = dwSrcWidth;
			t_rect.bottom = dwSrcHeight;
#if TEMP_DEBUG
	RETAILMSG(TEMP_DEBUG,(TEXT("t_rect,justbitbltflip(%d,%d)~(%d,%d), R:%d\r\n"), 
		t_rect.left,		t_rect.top,		t_rect.right,		t_rect.bottom,iRotate		));
#endif
#if TEMP_DEBUG
	if(pBltParms->pSrc)
	{
	RETAILMSG(TEMP_DEBUG,(TEXT("Src:0x%x SrcB 0x%x, Surf(W:%d,H:%d,BPP:%d,STRIDE:%d), Screen(W:%d,H:%d), rect: (%d,%d)~(%d,%d), R:%d\r\n"), 
		pBltParms->pSrc,
		pBltParms->pSrc->Buffer(),
		pBltParms->pSrc->Width(),
		pBltParms->pSrc->Height(),
		EGPEFormatToBpp[pBltParms->pSrc->Format()],
		pBltParms->pSrc->Stride(),
		pBltParms->pSrc->ScreenWidth(),
		pBltParms->pSrc->ScreenHeight(),
		pBltParms->prclSrc->left,
		pBltParms->prclSrc->top,
		pBltParms->prclSrc->right,
		pBltParms->prclSrc->bottom,
		pBltParms->pSrc->Rotate()
		));
	}
	if(pBltParms->pDst)
	{
	RETAILMSG(TEMP_DEBUG,(TEXT("Dst:0x%x DstB 0x%x,  Surf(W:%d,H:%d,BPP:%d,STRIDE:%d), Screen(W:%d,H:%d), rect: (%d,%d)~(%d,%d), R:%d\r\n"), 
		pBltParms->pDst,
		pBltParms->pDst->Buffer(),
		pBltParms->pDst->Width(),
		pBltParms->pDst->Height(),
		EGPEFormatToBpp[pBltParms->pDst->Format()],
		pBltParms->pDst->Stride(),		
		pBltParms->pDst->ScreenWidth(),
		pBltParms->pDst->ScreenHeight(),
		pBltParms->prclDst->left,
		pBltParms->prclDst->top,
		pBltParms->prclDst->right,
		pBltParms->prclDst->bottom,
		pBltParms->pDst->Rotate()
		));									
	}
	RETAILMSG(TEMP_DEBUG, (TEXT("ROP : 0x%0x\r\n"), pBltParms->rop4));				
	RETAILMSG(TEMP_DEBUG, (TEXT("xPositive : %d\r\n"),pBltParms->xPositive));
	RETAILMSG(TEMP_DEBUG, (TEXT("yPositive : %d\r\n"),pBltParms->yPositive));	
#endif			
			
			/// In mirror case, source region does not change.
			/// only destination's regions has reverse coordinate, this cannot be negative.
			if(iRotate == DMDO_0)	//< This is Difference between source and destination.
			{
//				RotateRectlBack(prclDst);
				if(prclDst->right < prclDst->left)
				{
//					RotateRectl(prclDst);
					RETAILMSG(TEMP_DEBUG, (TEXT("BitBlt Y-axis flip: R:%d\r\n"),pBltParms->pDst->Rotate()));											
					/// Set Destination Surface to real Framebuffer Surface		
					m_oG2D->SetDstSurface(pdescDstSurface);

					RETAILMSG(TEMP_DEBUG,(TEXT("BY TBSWAP:%d,%d,%d,%d,%d\n"),pBltParms->prclDst->left,pBltParms->prclDst->top,pBltParms->prclDst->right,pBltParms->prclDst->bottom, iRotate));
					/// Y-axis mirror case. left-right inversion
					/// Swap left, right coordinate
					SWAP(prclDst->right, prclDst->left, LONG);
					
					RETAILMSG(TEMP_DEBUG,(TEXT("BY TASWAP:%d,%d,%d,%d,%d\n"),pBltParms->prclDst->left,pBltParms->prclDst->top,pBltParms->prclDst->right,pBltParms->prclDst->bottom, iRotate));										
					/// Set Destination Clipping window Rect
					if(pBltParms->prclClip)
					{
						m_oG2D->SetClipWindow(pBltParms->prclClip);
					}
					else
					{
						m_oG2D->SetClipWindow(prclDst);
					}	
					
					/// Set Y-axis flip flag
					EnterCriticalSection(&m_cs2D);
					m_oG2D->FlipBlt( prclSrc, prclDst,  FLIP_Y );
					LeaveCriticalSection(&m_cs2D);				
					/// recover left, right coordinate
					SWAP(prclDst->right, prclDst->left, LONG);				

					return TRUE;
				}
				else if(prclDst->bottom < prclDst->top)
				{
//					RotateRectl(prclDst);
					RETAILMSG(TEMP_DEBUG, (TEXT("BitBlt X-axis flip: R:%d\r\n"),pBltParms->pDst->Rotate()));									
					/// Set Destination Surface to real Framebuffer Surface		
					m_oG2D->SetDstSurface(pdescDstSurface);

					RETAILMSG(TEMP_DEBUG,(TEXT("BX TBSWAP:%d,%d,%d,%d,%d\n"),pBltParms->prclDst->left,pBltParms->prclDst->top,pBltParms->prclDst->right,pBltParms->prclDst->bottom, iRotate));				
					/// X-axis mirror case. up-down inversion
					/// Swap top, bottom coordinate
					SWAP(prclDst->top, prclDst->bottom, LONG);
					RETAILMSG(TEMP_DEBUG,(TEXT("BX TASWAP:%d,%d,%d,%d,%d\n"),pBltParms->prclDst->left,pBltParms->prclDst->top,pBltParms->prclDst->right,pBltParms->prclDst->bottom, iRotate));									

⌨️ 快捷键说明

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