📄 blt.cpp
字号:
/// Set Destination Clipping window Rect
if(pBltParms->prclClip)
{
m_oG2D->SetClipWindow(pBltParms->prclClip);
}
else
{
m_oG2D->SetClipWindow(prclDst);
}
/// Set X-axis flip flag
EnterCriticalSection(&m_cs2D);
m_oG2D->FlipBlt( prclSrc, prclDst, FLIP_X );
LeaveCriticalSection(&m_cs2D);
/// recover top, bottom coordinate
SWAP(prclDst->top, prclDst->bottom, LONG);
return TRUE;
}
// RotateRectl(prclDst);
}
else if(iRotate == DMDO_90 || iRotate == DMDO_270)
{
RotateRectlBack(prclDst);
/// Original Coordinate
RETAILMSG(TEMP_DEBUG, (TEXT("R:%d, DR:%d, DST(%d,%d,%d,%d)\r\n"),pBltParms->pDst->Rotate(), iRotate,
pBltParms->prclDst->left,
pBltParms->prclDst->top,
pBltParms->prclDst->right,
pBltParms->prclDst->bottom));
/// if screen rotation is not DMDO_0. we need to bitblt once more. and use scratch memory
if(prclDst->right < prclDst->left)
{
RotateRectl(prclDst);
/// Screen rotated
/// if 90, 270 degree, that is T,B Swaped and rotate
/// +-----+ (L,T)
/// | |
/// | |
/// | |
/// +-----+
/// (R,B)
/// 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 as Scratch Surface
m_oG2D->SetDstSurface(&descScratch);
/// Set Destination Clipping window Rect
m_oG2D->SetClipWindow(&t_rect);
/// Y-axis mirror case. left-right inversion
EnterCriticalSection(&m_cs2D);
m_oG2D->FlipBlt( prclSrc, &t_rect, FLIP_Y );
LeaveCriticalSection(&m_cs2D);
/// 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
/// Y-axis mirror case. left-right inversion
RETAILMSG(TEMP_DEBUG,(TEXT("B TBSWAP:%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->top, prclDst->bottom, LONG);
/// 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->BitBlt( &t_rect, prclDst, m_oG2D->GetRotType(iRotate) );
LeaveCriticalSection(&m_cs2D);
/// recover left, right coordinate
SWAP(prclDst->top, prclDst->bottom, LONG);
/// Disallocate Scratch Surface
delete ScratchSurf;
RETAILMSG(TEMP_DEBUG, (TEXT("BitBlt Y-axis flip: R:%d\r\n"),pBltParms->pDst->Rotate()));
// RotateRectl(prclDst);
return TRUE;
}
else 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);
/// X-axis mirror case. top-bottom inversion
RETAILMSG(TEMP_DEBUG,(TEXT("B 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)));
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);
/// Swap left, right coordinate
/// LT <-> RB
SWAP(prclDst->left, prclDst->right, LONG);
/// 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->BitBlt( &t_rect, prclDst, m_oG2D->GetRotType(iRotate) );
LeaveCriticalSection(&m_cs2D);
/// recover left, right coordinate
SWAP(prclDst->left, prclDst->right, LONG);
/// Disallocate Scratch Surface
delete ScratchSurf;
RETAILMSG(TEMP_DEBUG, (TEXT("BitBlt X-axis flip: R:%d\r\n"),pBltParms->pDst->Rotate()));
return TRUE;
}
RotateRectl(prclDst);
}
else //< DMDO_180
{
RotateRectlBack(prclDst);
/// if screen rotation is not DMDO_0. we need to bitblt once more. and use scratch memory
if(prclDst->right < prclDst->left)
{
RotateRectl(prclDst);
RETAILMSG(TEMP_DEBUG, (TEXT("BitBlt Y-axis flip: R:%d\r\n"),pBltParms->pDst->Rotate()));
/// 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);
/// Y-axis mirror case. left-right inversion
RETAILMSG(TEMP_DEBUG,(TEXT("(%d,%d)~(%d,%d) %d,%d\n"),pBltParms->prclDst->left,pBltParms->prclDst->top,pBltParms->prclDst->right,pBltParms->prclDst->bottom, iRotate, m_oG2D->GetRotType(iRotate)));
EnterCriticalSection(&m_cs2D);
m_oG2D->FlipBlt( prclSrc, &t_rect, FLIP_Y );
LeaveCriticalSection(&m_cs2D);
/// 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
SWAP(prclDst->right, prclDst->left, LONG);
/// 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->BitBlt( &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;
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()));
/// 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);
/// X-axis mirror case. top-down inversion
RETAILMSG(TEMP_DEBUG,(TEXT("(%d,%d)~(%d,%d) %d,%d\n"),pBltParms->prclDst->left,pBltParms->prclDst->top,pBltParms->prclDst->right,pBltParms->prclDst->bottom, iRotate, m_oG2D->GetRotType(iRotate)));
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);
/// Swap left, right 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);
}
/// Set Y-axis flip flag
EnterCriticalSection(&m_cs2D);
m_oG2D->BitBlt( &t_rect, prclDst, m_oG2D->GetRotType(iRotate) );
LeaveCriticalSection(&m_cs2D);
/// recover left, right coordinate
SWAP(prclDst->top, prclDst->bottom, LONG);
/// Disallocate Scratch Surface
delete ScratchSurf;
return TRUE;
}
RotateRectl(prclDst);
}
}
RotateRectl(prclDst);
/// 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->BitBlt( prclSrc, prclDst, m_oG2D->GetRotType(iRotate) );
LeaveCriticalSection(&m_cs2D);
RETAILMSG(FULL_TEST_OK, (TEXT("BitBlt no flip: R:%d\r\n"),pBltParms->pDst->Rotate()));
}
RotateRectl(prclSrc);
RotateRectl(prclDst);
return TRUE;
}
#endif
/**
* @fn void S3C2450Disp::AcceleratedBltSelect16(GpeBltParms *pBltParms)
* @brief Select appropriate hardware acceleration function or software emulation function.
* if there's no appropriate accelerated function,
* Leave Blit funciton to intial setting, EmulatedBlt(generic Bit blit emulator)
* @param pBltParms Blit Parameter Information Structure
* @sa GPEBltParms
*/
SCODE S3C2450DISP::AcceleratedBltSelect16(GPEBltParms *pBltParms)
{
// In SMDK2450, Stretch function support only integer multipling calculation
// Do not support shrink, fractional stretching
/// All these condition is same to EmulatedBltSelect16
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -