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

📄 blt.cpp

📁 SAMSUNG S3C6410 CPU BSP for winmobile6
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        && !(( uiSrcWidth_0 == uiDstWidth_0) && (uiSrcHeight_0 == uiDstHeight_0))
        )
    {
        if( (prclSrc->left < 0) || (prclSrc->right < 0) || (prclSrc->top < 0) || (prclSrc->bottom < 0)
            || (prclDst->left < 0) || (prclDst->right < 0) || (prclDst->top < 0) || (prclDst->bottom <0))
        {
            /// If rotated coodinate has negative value. we can't care about when stretching is need.
            /// So return false, then process it by SW
            return FALSE;
        }

        RECTL   t_rect;
        DWORD   dwSrcWidth;
        DWORD   dwSrcHeight;
        SURFACE_DESCRIPTOR descScratch;

        /// This is physical value == physically 0 degree;
        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,realstretch: (%d,%d)~(%d,%d), R:%d\r\n"), 
            t_rect.left,t_rect.top,t_rect.right,t_rect.bottom, iRotate));
	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			
		/// 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( (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;
			}

            /// SWAP rect
            SWAP(prclDst->top, prclDst->bottom, LONG);
            SWAP(prclDst->left, prclDst->right, LONG);

#if (G2D_STRETCH_ALGORITHM==G2D_BILINEAR_STRETCH)
            /// Adjust Coordinate from (x1,y1)~(x2,y2) to (0,0)~(x2-x1,y2-y1)
            /// and Recalculate BaseAddress
            m_oG2D->TranslateCoordinateToZero(pdescDstSurface, prclDst, pBltParms->prclClip);
#endif
            /// 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);	
#if (G2D_STRETCH_ALGORITHM==G2D_BILINEAR_STRETCH)
            m_oG2D->StretchBlt_Bilinear( prclSrc, prclDst, m_oG2D->GetRotType(iRotate));
#else
            m_oG2D->StretchBlt( prclSrc, prclDst, m_oG2D->GetRotType(iRotate));
#endif
			LeaveCriticalSection(&m_cs2D);				
			/// Recover rect
			SWAP(prclDst->top, prclDst->bottom, LONG);
			SWAP(prclDst->left, prclDst->right, LONG);			

            //RotateRectl(prclDst);
			
			return TRUE;
			
		}
		RotateRectl(prclDst);		

		
		/// Reconfigure HW to set destination framebuffer address as Scratch Framebuffer
		
		/// Check mirror case, and reset region rectangle
		/// Doing FlipBlt from Source to Sratch
		/// In mirror case, source region does not change.
		/// only destination's regions has reverse coordinate, this cannot be negative.
		if(iRotate == DMDO_90 || iRotate == DMDO_270)
		{	
            /// back to logical value
            RotateRectlBack(prclDst);
            /// if left-right mirror case
		 	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 = (m_VideoMemoryPhysicalBase + ScratchSurf->OffsetInVideoMemory());
				RETAILMSG(TEMP_DEBUG,(TEXT("ScratchBaseAddr : 0x%x\n"), descScratch.dwBaseaddr));
				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);

				/// Swap top, left coordinate when 90 and 270
				RETAILMSG(TEMP_DEBUG,(TEXT("S TBSWAP:%d,%d,%d,%d,%d,%d\n"),prclDst->left, prclDst->top, prclDst->right, prclDst->bottom, iRotate, m_oG2D->GetRotType(iRotate)));
				SWAP(prclDst->top, prclDst->bottom, LONG);
#if (G2D_STRETCH_ALGORITHM==G2D_BILINEAR_STRETCH)
                /// Adjust Coordinate from (x1,y1)~(x2,y2) to (0,0)~(x2-x1,y2-y1)
                /// and Recalculate BaseAddress
                m_oG2D->TranslateCoordinateToZero(pdescDstSurface, prclDst, pBltParms->prclClip);
#endif
                /// 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);	
				RETAILMSG(TEMP_DEBUG,(TEXT("S TASWAP:%d,%d,%d,%d,%d,%d\n"),prclDst->left, prclDst->top, prclDst->right, prclDst->bottom, iRotate, m_oG2D->GetRotType(iRotate)));				
#if (G2D_STRETCH_ALGORITHM==G2D_BILINEAR_STRETCH)
                m_oG2D->StretchBlt_Bilinear( &t_rect, prclDst, m_oG2D->GetRotType(iRotate));
#else
                m_oG2D->StretchBlt( &t_rect, prclDst, m_oG2D->GetRotType(iRotate));
#endif
				LeaveCriticalSection(&m_cs2D);		
				/// recover left, right coordinate
				SWAP(prclDst->top, prclDst->bottom, LONG);				

				/// Disallocate Scratch Surface
				delete ScratchSurf;

				RETAILMSG(TEMP_DEBUG, (TEXT("Stretch Y-axis flip: R:%d\r\n"), pBltParms->pDst->Rotate()));
				
				return TRUE;
			}
            /// if bottom-up mirror case
			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 = (m_VideoMemoryPhysicalBase + ScratchSurf->OffsetInVideoMemory());
				RETAILMSG(TEMP_DEBUG,(TEXT("ScratchBaseAddr : 0x%x, Offset:%d,SrcW:%d, SrcH:%d, Stride:%d, R:%d\n"), descScratch.dwBaseaddr, ScratchSurf->OffsetInVideoMemory(), dwSrcWidth, dwSrcHeight, ScratchSurf->Stride(), ScratchSurf->Rotate()));
				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);

				/// 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);			


#if (G2D_STRETCH_ALGORITHM==G2D_BILINEAR_STRETCH)
                /// Adjust Coordinate from (x1,y1)~(x2,y2) to (0,0)~(x2-x1,y2-y1)
                /// and Recalculate BaseAddress
                m_oG2D->TranslateCoordinateToZero(pdescDstSurface, prclDst, pBltParms->prclClip);
#endif
                /// 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);
#if (G2D_STRETCH_ALGORITHM==G2D_BILINEAR_STRETCH)    
                m_oG2D->StretchBlt_Bilinear( &t_rect, prclDst, m_oG2D->GetRotType(iRotate));
#else
                m_oG2D->StretchBlt( &t_rect, prclDst, m_oG2D->GetRotType(iRotate));
#endif
				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);
            /// Non flip but rotated.
        }
        else        //< DMDO_0 and DMDO_180 does not need to modify prclDst region
        {
            RotateRectlBack(prclDst);
            /// Check Left-Right flip, when stretching is needed.
		 	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 = (m_VideoMemoryPhysicalBase + 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);

                /// Swap left, right coordinate
                RETAILMSG(TEMP_DEBUG,(TEXT("S 0,180 BSWAP : %d,%d,%d,%d\n"),pBltParms->prclDst->left,pBltParms->prclDst->top,pBltParms->prclDst->right,pBltParms->prclDst->bottom));
                SWAP(prclDst->right, prclDst->left, LONG);
#if (G2D_STRETCH_ALGORITHM==G2D_BILINEAR_STRETCH)    
                /// Adjust Coordinate from (x1,y1)~(x2,y2) to (0,0)~(x2-x1,y2-y1)
                /// and Recalculate BaseAddress
                m_oG2D->TranslateCoordinateToZero(pdescDstSurface, prclDst, pBltParms->prclClip);
#endif
                /// Set Destination Surface to real Framebuffer Surface
                m_oG2D->SetDstSurface(pdescDstSurface);

				/// Set Destination Clipping window Rect
				if(pBltParms->prclClip)

⌨️ 快捷键说明

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