📄 blt.cpp
字号:
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 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 = (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);
/// 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(pBltParms->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 = (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);
/// 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 = (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);
/// 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()));
}
return TRUE;
}
#endif
/**
* @fn void S3C6410Disp::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
*/
#if (CPU_NAME == S3C6410)
SCODE S3C6410Disp::AcceleratedBltSelect16( GPEBltParms *pBltParms )
{
/// All these condition is same to EmulatedBltSelect16
if (pBltParms->pDst->Format() != gpe16Bpp) //< Destination must be 16bpp
{
RETAILMSG(DUMP_BLTPARAM, (TEXT("Color Format is not 16bpp\r\n")));
return S_OK;
}
if(pBltParms->bltFlags & BLT_ALPHABLEND) //< if AlphaBlend is required, emulate
{
RETAILMSG(DUMP_BLTPARAM, (TEXT("AlphaBlend is required\r\n")));
return S_OK;
}
#if 0
if(pBltParms->bltFlags & BLT_TRANSPARENT) //< Our HW can support Transparent blit for 16bpp, 24bpp
{
return S_OK;
}
#endif
#if G2D_BYPASS_HW_STRETCHBLT
if(pBltParms->bltFlags & BLT_STRETCH) //< can support Stretch Blit for 16bpp, 24bpp
{
RETAILMSG(DUMP_BLTPARAM, (TEXT("Stretch is required\r\n")));
return S_OK;
}
#endif
if(pBltParms->pLookup)
{
RETAILMSG(DUMP_BLTPARAM, (TEXT("Lookup is required\r\n")));
return S_OK;
}
if(pBltParms->pConvert) //< Emulate if color conversion required
{
RETAILMSG(DUMP_BLTPARAM, (TEXT("Color Converting is required\r\n")));
return S_OK;
}
if(pBltParms->prclClip && (pBltParms->prclClip->left == pBltParms->prclClip->right) && (pBltParms->prclClip->top == pBltParms->prclClip->bottom))
{
// Just skip, there is no image flushing to screen
// SW bitblt takes this case, and it can skip more efficiently.
return S_OK;
}
/**
* Check if source and destination regions' coordinates has positive value.
*
*
**/
if ((pBltParms->bltFlags & BLT_STRETCH)) // Stretch Bllitting with X or Y axis mirroring
{
if(!pBltParms->prclDst)
{
// goto emulsel;
return S_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -