📄 blt.cpp
字号:
{
m_oG2D->SetClipWindow(pBltParms->prclClip);
}
else
{
m_oG2D->SetClipWindow(prclDst);
}
RETAILMSG(TEMP_DEBUG,(TEXT("S 0,180 ASWAP : %d,%d,%d,%d\n"),pBltParms->prclDst->left,pBltParms->prclDst->top,pBltParms->prclDst->right,pBltParms->prclDst->bottom));
EnterCriticalSection(&m_cs2D);
#if (G2D_STRETCH_ALGORITHM==G2D_BILINEAR_STRETCH)
m_oG2D->StretchBlt( &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->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;
}
/// Check Up-Down flip, when stretching is needed.
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);
/// 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 top, bottom coordinate
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);
#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->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;
}
RotateRectl(prclDst);
}
/// cover 0, 90, 180, 270 but no flip
RETAILMSG(TEMP_DEBUG,(TEXT("S BRNONSWAP:%d,%d,%d,%d,%d,%d\n"),pBltParms->prclDst->left,pBltParms->prclDst->top,pBltParms->prclDst->right,pBltParms->prclDst->bottom, iRotate, m_oG2D->GetRotType(iRotate)));
// if(pBltParms->pDst->Rotate() == DMDO_90 || pBltParms->pDst->Rotate() == DMDO_270)
// {
// RotateRectl(prclDst);
// RotateRectl(prclDst);
// }
RETAILMSG(TEMP_DEBUG,(TEXT("S BZNONSWAP:%d,%d,%d,%d,%d,%d\n"),pBltParms->prclDst->left,pBltParms->prclDst->top,pBltParms->prclDst->right,pBltParms->prclDst->bottom, iRotate, m_oG2D->GetRotType(iRotate)));
/// This case does not need to flip.
#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
RETAILMSG(TEMP_DEBUG,(TEXT("S NONSWAP:%d,%d,%d,%d,%d,%d\n"),pBltParms->prclDst->left,pBltParms->prclDst->top,pBltParms->prclDst->right,pBltParms->prclDst->bottom, iRotate, m_oG2D->GetRotType(iRotate)));
/// 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);
RETAILMSG(TEMP_DEBUG, (TEXT("\nStretch no flip: R:%d\r\n"),pBltParms->pDst->Rotate()));
}
else // Do not stretch.
{
/// 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 ));
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.
/// This is Difference between source and destination.
if(iRotate == DMDO_0)
{
// 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));
/// 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);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -