📄 blt.cpp
字号:
SCODE S3C6410Disp::AcceleratedDestInvert(GPEBltParms *pBltParms)
{
int dstX = pBltParms->prclDst->left;
int dstY = pBltParms->prclDst->top;
int width = pBltParms->prclDst->right - pBltParms->prclDst->left;
int height = pBltParms->prclDst->bottom - pBltParms->prclDst->top;
// printf("DestInvert need to implement");
return S_OK;
}
/// From Frame Buffer to Frame Buffer Directly
/// Constraints
/// Source Surface's width is same with Destination Surface's width.
/// Source and Dest must be in Video FrameBuffer Region
/// In Surface Format
/// ScreenHeight and ScreenWidth means logical looking aspect for application
/// Height and Width means real data format.
/**
* @fn SCODE S3C6410Disp::AcceleratedSrcCopyBlt(GPEBltParms *pBltParms)
* @brief Do Blit with SRCCOPY, SRCAND, SRCPAINT, SRCINVERT
* @param pBltParms Blit Parameter Information Structure
* @sa GPEBltParms
* @note ROP : 0xCCCC(SRCCOPY), 0x8888(SRCAND), 0x6666(SRCINVERT), 0XEEEE(SRCPAINT)
* @note Using Information : DstSurface, ROP, Solidcolor
*/
#if (CPU_NAME == S3C6410)
SCODE S3C6410Disp::AcceleratedSrcCopyBlt (GPEBltParms *pBltParms)
{
PRECTL prclSrc, prclDst;
RECT rectlSrcBackup;
BOOL bHWSuccess = FALSE;
prclSrc = pBltParms->prclSrc;
prclDst = pBltParms->prclDst;
// Set Destination Offset In Video Memory, this point is Dest lefttop point
//
// m_oG2D->Init();
/**
* Prepare Source & Destination Surface Information
*/
SURFACE_DESCRIPTOR descSrcSurface, descDstSurface;
DWORD dwSrcBaseAddrOffset = 0;
DWORD dwTopStrideStartAddr = 0;
descSrcSurface.dwColorMode = pBltParms->pSrc->Format();
/// !!!!Surface Width can not match to Real Data format!!!!
/// !!!!Set Width by Scan Stride Size!!!!
descSrcSurface.dwHoriRes = pBltParms->pSrc->Stride()/pBltParms->pSrc->BytesPerPixel();
/// If source surface is created by user temporary, that has no screen width and height.
descSrcSurface.dwVertRes = (pBltParms->pSrc->ScreenHeight() != 0 ) ? pBltParms->pSrc->ScreenHeight() : pBltParms->pSrc->Height();
if(pBltParms->pDst->IsRotate())
{
RotateRectl(prclDst); //< RotateRectl rotate rectangle with screen rotation information
if(pBltParms->prclClip)
{
RotateRectl(pBltParms->prclClip);
}
}
if(pBltParms->pSrc->IsRotate())
{
RotateRectl(prclSrc);
}
if (pBltParms->bltFlags & BLT_TRANSPARENT)
{
RETAILMSG(0,(TEXT("TransparentMode Color : %d\n"), pBltParms->solidColor));
m_oG2D->SetTransparentMode(1, pBltParms->solidColor); // turn on transparency & set comparison color
}
switch (pBltParms->rop4)
{
case 0x6666: // SRCINVERT
RETAILMSG(G2D_MSG, (TEXT("SRCINVERT\r\n")));
m_oG2D->SetRopEtype(ROP_SRC_XOR_DST);
break;
case 0x8888: // SRCAND
RETAILMSG(G2D_MSG, (TEXT("SRCAND\r\n")));
m_oG2D->SetRopEtype(ROP_SRC_AND_DST);
break;
case 0xCCCC: // SRCCOPY
RETAILMSG(G2D_MSG, (TEXT("SRCCOPY\r\n")));
m_oG2D->SetRopEtype(ROP_SRC_ONLY);
break;
case 0xEEEE: // SRCPAINT
RETAILMSG(G2D_MSG, (TEXT("SRCPAINT\r\n")));
m_oG2D->SetRopEtype(ROP_SRC_OR_DST);
break;
}
/// Check Source Rectangle Address
/// HW Coordinate limitation is 2048
/// 1. Get the Top line Start Address
/// 2. Set the base offset to Top line Start Address
/// 3. Recalulate top,bottom rectangle
/// 4. Do HW Bitblt
CopyRect(&rectlSrcBackup, (LPRECT)pBltParms->prclSrc);
/// Set Source Surface Information
/// If using PLA control for surface in virtual address, use PLA
if((( S3C6410Surf *)(pBltParms->pSrc))->InVideoMemory() ) {
descSrcSurface.dwBaseaddr = (m_VideoMemoryPhysicalBase + (( S3C6410Surf *)(pBltParms->pSrc))->OffsetInVideoMemory());
descSrcSurface.dwVertRes = (pBltParms->pSrc->ScreenHeight() != 0 ) ? pBltParms->pSrc->ScreenHeight() : pBltParms->pSrc->Height();
}
else
{
dwTopStrideStartAddr = m_dwSourceSurfacePA + pBltParms->prclSrc->top * pBltParms->pSrc->Stride();
descSrcSurface.dwBaseaddr = dwTopStrideStartAddr;
descSrcSurface.dwVertRes = pBltParms->prclSrc->bottom - pBltParms->prclSrc->top;
pBltParms->prclSrc->top = 0;
pBltParms->prclSrc->bottom = descSrcSurface.dwVertRes;
}
/// Set Destination Surface Information
descDstSurface.dwBaseaddr = (m_VideoMemoryPhysicalBase + (( S3C6410Surf *)(pBltParms->pDst))->OffsetInVideoMemory());
descDstSurface.dwColorMode = pBltParms->pDst->Format();
descDstSurface.dwHoriRes = pBltParms->pDst->Stride()/pBltParms->pDst->BytesPerPixel();
descDstSurface.dwVertRes = pBltParms->pDst->ScreenHeight();
/// Transparency does not relate with alpha blending
m_oG2D->SetAlphaMode(G2D_NO_ALPHA_MODE);
/// No transparecy with alphablend
m_oG2D->SetAlphaValue(0xff);
m_oG2D->Set3rdOperand(G2D_OPERAND3_PAT);
/// Real Register Surface Description setting will be done in HWBitBlt
bHWSuccess = HWBitBlt(pBltParms, &descSrcSurface, &descDstSurface);
CopyRect((LPRECT)pBltParms->prclSrc, &rectlSrcBackup);
if(pBltParms->pDst->IsRotate())
{
RotateRectlBack(prclDst);
if(pBltParms->prclClip)
{
RotateRectlBack(pBltParms->prclClip);
}
}
if(pBltParms->pSrc->IsRotate())
{
RotateRectlBack(prclSrc);
}
if (pBltParms->bltFlags & BLT_TRANSPARENT)
{
m_oG2D->SetTransparentMode(0, pBltParms->solidColor); // turn off Transparency
}
if(!bHWSuccess)
{
return EmulatedBlt(pBltParms);
}
return S_OK;
}
#elif (CPU_NAME == S3C6400)
SCODE
S3C6410Disp::AcceleratedSrcCopyBlt (GPEBltParms *pBltParms)
{
CSPACE ColorMode;
#if G2D_PROFILE
RopProfiler *ropProfiler;
ropProfiler = RopProfiler::Instance();
ropProfiler->Log(true, pBltParms->rop4);
#endif
// Set Destination Offset In Video Memory, this point is Dest lefttop point
//
//
if ( pBltParms->pSrc->Format() == gpe16Bpp)
{
ColorMode = RGB16;
}
else if( pBltParms->pSrc->Format() == gpe24Bpp)
{
ColorMode = RGB24;
}
else
{
ColorMode = RGB16;
}
m_oG2D->InitSetting(
m_VideoMemoryPhysicalBase + (( S3C6410Surf *)(pBltParms->pDst))->OffsetInVideoMemory(),
ColorMode,
m_nScreenWidth, m_nScreenHeight,
0, 0,
m_nScreenWidth, m_nScreenHeight
);
m_oG2D->SetAlphaMode(G2D_NO_ALPHA_MODE);
m_oG2D->SetAlphaValue(0xcf);
m_oG2D->Set3rdOperand(G2D_OPERAND3_PAT);
if (pBltParms->bltFlags & BLT_TRANSPARENT)
{
m_oG2D->SetTransparentMode(1, pBltParms->solidColor); // turn on transparency & set comparison color
}
switch (pBltParms->rop4)
{
case 0x6666: // SRCINVERT
RETAILMSG(G2D_MSG, (TEXT("SRCINVERT\r\n")));
m_oG2D->SetRopEtype(ROP_SRC_XOR_DST);
break;
case 0x8888: // SRCAND
RETAILMSG(G2D_MSG, (TEXT("SRCAND\r\n")));
m_oG2D->SetRopEtype(ROP_SRC_AND_DST);
break;
case 0xCCCC: // SRCCOPY
RETAILMSG(G2D_MSG, (TEXT("SRCCOPY\r\n")));
m_oG2D->SetRopEtype(ROP_SRC_ONLY);
break;
case 0xEEEE: // SRCPAINT
RETAILMSG(G2D_MSG, (TEXT("SRCPAINT\r\n")));
m_oG2D->SetRopEtype(ROP_SRC_OR_DST);
break;
}
m_oG2D->BitBlt(pBltParms);
if (pBltParms->bltFlags & BLT_TRANSPARENT)
{
m_oG2D->SetTransparentMode(0, pBltParms->solidColor); // turn off Transparency
}
return S_OK;
}
#endif
#if (CPU_NAME == S3C6410)
/**
* @fn void S3C6410Disp::HWBitBlt(GpeBltParms *pBltParms)
* @brief Check Further Optional processing. This is intemediate layer between display driver and 2D driver
* @param pBltParms Blit Parameter Information Structure
* @sa GPEBltParms
* @note currently support only rotation
* @note DMDO_0 = 0, DMDO_90 = 1, DMDO_180 = 2, DMDO_270 = 4
*/
BOOL S3C6410Disp::HWBitBlt(GPEBltParms *pBltParms, PSURFACE_DESCRIPTOR pdescSrcSurface, PSURFACE_DESCRIPTOR pdescDstSurface)
{
PRECTL prclSrc; //< Src is already rotated.
PRECTL prclDst; //< Dst is already rotated.
RECT rectlPhySrc; //< If screen is rotated, this value has RotateRectl(prclSrc), physically addressed coordinate.
RECT rectlPhyDst; //< If screen is rotated, this value has RotateRectl(prclDst), physically addressed coordinate.
UINT uiSrcWidth_0; //< Source Rectangle's width as non-rotated logically.
UINT uiDstWidth_0; //< Destination Rectangle's width as non-rotated logically.
UINT uiSrcHeight_0; //< Source Rectangle's height as non-rotated logically.
UINT uiDstHeight_0; //< Destination Rectangle's height as non-rotated logically.
prclSrc = pBltParms->prclSrc;
prclDst = pBltParms->prclDst;
CopyRect(&rectlPhySrc, (LPRECT)prclSrc);
CopyRect(&rectlPhyDst, (LPRECT)prclDst);
int iRotate = DMDO_0;
RotateRectlBack(prclSrc);
RotateRectlBack(prclDst);
/// Get Logical Aspect.
uiSrcWidth_0 = ABS(prclSrc->right - prclSrc->left);
uiSrcHeight_0 = ABS(prclSrc->bottom - prclSrc->top);
uiDstWidth_0 = ABS(prclDst->right - prclDst->left);
uiDstHeight_0 = ABS(prclDst->bottom - prclDst->top);
RotateRectl(prclSrc);
RotateRectl(prclDst);
/// Set Relative Rotation Degree
switch(pBltParms->pSrc->Rotate())
{
default:
case DMDO_0:
switch(pBltParms->pDst->Rotate())
{
default:
case DMDO_0:
iRotate = DMDO_0;
break;
case DMDO_90:
iRotate = DMDO_90;
break;
case DMDO_180:
iRotate = DMDO_180;
break;
case DMDO_270:
iRotate = DMDO_270;
break;
}
break;
case DMDO_90:
switch(pBltParms->pDst->Rotate())
{
default:
case DMDO_0:
iRotate = DMDO_270;
break;
case DMDO_90:
iRotate = DMDO_0;
break;
case DMDO_180:
iRotate = DMDO_90;
break;
case DMDO_270:
iRotate = DMDO_180;
break;
}
break;
case DMDO_180:
switch(pBltParms->pDst->Rotate())
{
default:
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;
}
break;
case DMDO_270:
switch(pBltParms->pDst->Rotate())
{
default:
case DMDO_0:
iRotate = DMDO_90;
break;
case DMDO_90:
iRotate = DMDO_180;
break;
case DMDO_180:
iRotate = DMDO_270;
break;
case DMDO_270:
iRotate = DMDO_0;
break;
}
break;
}
#define SWAP(x,y, _type) { _type i; i = x; x = y; y = i; }
RETAILMSG(TEMP_DEBUG,(TEXT("HWBitBlt Src(%d,%d)~(%d,%d), Dst(%d,%d)~(%d,%d)\n"),
prclSrc->left, prclSrc->top, prclSrc->right, prclSrc->bottom,
prclDst->left, prclDst->top, prclDst->right, prclDst->bottom));
/// if Stretch option is set, run StretchBlt
/// if StretchBlt is on, but source region and destination region are same. use BitBlt
if( ((pBltParms->bltFlags & BLT_STRETCH) == BLT_STRETCH)
//< If Does not need to stretch or shrink. just BitBlt is faster.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -