sa2video.cpp
来自「该BSP是基于PXA270+WINCE的BSP」· C++ 代码 · 共 2,007 行 · 第 1/5 页
CPP
2,007 行
switch ( (bSrc + 1) >> 2 ) // src pixel in range 0...4
{
case 0:
// Leave destination untouched
break;
case 1:
// 3/4 destination color and 1/4 brush color
*pwDstPixel = ((*pwDstPixel >> 2) & SHIFT_TWO_MASK)
+ ((*pwDstPixel >> 1) & SHIFT_ONE_MASK) + wOnColor[1];
break;
case 2:
// 1/2 destination color and 1/2 brush color
*pwDstPixel = ((*pwDstPixel >> 1) & SHIFT_ONE_MASK) + wOnColor[2];
break;
case 3:
// 1/4 destination color and 3/4 brush color
*pwDstPixel = ((*pwDstPixel >> 2) & SHIFT_TWO_MASK) + wOnColor[3];
break;
case 4:
// Fill with solid brush color
*pwDstPixel = wOnColor[4];
break;
default:
DebugBreak();
}
pwDstPixel++;
}
// advance to next scanline
pbSrcScanLine += iSrcScanStride;
pbDstScanLine += iDstScanStride;
}
return S_OK;
}
__inline
SCODE
EmulatedBltText16_Eml(
GPEBltParms * pParms
)
{
DEBUGMSG(GPE_ZONE_BLT_HI,(TEXT("EmulatedBltText16\r\n")));
UINT32 iDstScanStride = pParms->pDst->Stride();
BYTE * pDibBitsDst = (BYTE *)pParms->pDst->Buffer();
UINT32 iSrcScanStride = pParms->pMask->Stride();
BYTE * pDibBitsSrc = (BYTE *)pParms->pMask->Buffer();
PRECTL prcSrc = pParms->prclMask;
PRECTL prcDst = pParms->prclDst;
unsigned int wOnColor = (unsigned int)pParms->solidColor;
int iSrcBitOffset;
int iNumDstRows;
int iNumDstCols;
BYTE * pbSrcScanLine;
BYTE * pbDstScanLine;
WORD * pwDstPixel;
// Caller assures a well-ordered, non-empty rect
// compute size of destination rect
iNumDstCols = prcDst->right - prcDst->left;
iNumDstRows = prcDst->bottom - prcDst->top;
// compute pointers to the starting rows in the src and dst bitmaps
pbSrcScanLine = pDibBitsSrc + prcSrc->top * iSrcScanStride + (prcSrc->left >> 3);
iSrcBitOffset = prcSrc->left & 0x07;
pbDstScanLine = pDibBitsDst + prcDst->top * iDstScanStride + prcDst->left * 2;
pwDstPixel = (WORD *)pbDstScanLine;
EmulatedBltText16ASM(pbSrcScanLine,pwDstPixel, wOnColor, iNumDstCols, iNumDstRows, iSrcScanStride, iDstScanStride, iSrcBitOffset);
return S_OK;
}
SCODE
SA2Video::Line(
GPELineParms * pLineParms,
EGPEPhase phase
)
{
if(phase == gpeSingle || phase == gpePrepare)
{
if(pLineParms->pDst != m_pPrimarySurface)
{
pLineParms->pLine = EmulatedLine;
}
else
{
pLineParms->pLine = (SCODE (GPE::*)(struct GPELineParms *))WrappedEmulatedLine;
}
}
return S_OK;
}
#undef SWAP
#define SWAP(type,a,b) { type tmp; tmp=a; a=b; b=tmp; }
SCODE
SA2Video::WrappedEmulatedBlt(
GPEBltParms * pParms
)
{
SCODE code;
RECT bounds;
// This function should only be called when using a virtual primary (ie.
// bDoRotation is TRUE).
ASSERT(bDoRotation);
if ((pParms->pDst == m_pPrimarySurface && m_iRotate) || (pParms->pSrc == m_pPrimarySurface && m_iRotate))
{
code = EmulatedBltRotate(pParms);
}
else
{
if ( !( (pParms->bltFlags & (BLT_ALPHABLEND | BLT_TRANSPARENT | BLT_STRETCH)) || (pParms->pLookup) || (pParms->pConvert) )
&& pParms->pDst->Format() == gpe16Bpp )
{
if ( pParms->rop4 == 0xcccc )
{
if ( EGPEFormatToBpp[pParms->pSrc->Format()] == 16 )
{
code = EmulatedBltSrcCopy1616_Eml(pParms);
goto contd;
}
}
else if ( pParms->rop4 == 0xf0f0 )
{
if (pParms->solidColor != -1)
{ // must be a solid colored brush
code = EmulatedBltFill16_Eml(pParms);
goto contd;
}
}
else if ( pParms->rop4 == 0xaaf0 )
{
if (pParms->solidColor != -1)
{
if (pParms->pMask->Format() == gpe1Bpp)
{
code = EmulatedBltText16_Eml(pParms);
goto contd;
}
else if (pParms->pMask->Format() == gpe4Bpp)
{
code = EmulatedBltAlphaText16_Eml(pParms);
goto contd;
}
}
}
}
code = EmulatedBlt(pParms);
}
contd:
if (bDoRotation)
{
bounds.left = pParms->prclDst->left;
bounds.top = pParms->prclDst->top;
bounds.right = pParms->prclDst->right;
bounds.bottom = pParms->prclDst->bottom;
if(bounds.left > bounds.right)
{
SWAP(int,bounds.left,bounds.right)
}
if( bounds.top > bounds.bottom)
{
SWAP(int,bounds.top,bounds.bottom)
}
if (bounds.top == bounds.bottom-1)
{
if ( !( (pParms->bltFlags & (BLT_ALPHABLEND | BLT_TRANSPARENT | BLT_STRETCH)) || (pParms->pLookup) || (pParms->pConvert) ) )
{
if ( pParms->rop4 == 0xf0f0 )
{
if ( EGPEFormatToBpp[pParms->pDst->Format()] == 16 )
{
if (pParms->solidColor != -1)
{ // must be a solid colored brush
if (!gDrawCursorFlag)
{
DispDrvrDirtyRectDump2((LPRECT)&bounds,pParms->solidColor);
return S_OK;
}
}
}
}
}
}
if ( !( (pParms->bltFlags & (BLT_ALPHABLEND | BLT_TRANSPARENT | BLT_STRETCH)) || (pParms->pLookup) || (pParms->pConvert) ) )
{
if ( pParms->rop4 == 0xf0f0 )
{
if ( EGPEFormatToBpp[pParms->pDst->Format()] == 16 )
{
if (pParms->solidColor != -1)
{ // must be a solid colored brush
DispDrvrDirtyRectDump_rectfill((LPRECT)&bounds,pParms->solidColor);
return S_OK;
}
}
}
}
if(FAILED(code))
{
return code;
}
DispDrvrDirtyRectDump((LPRECT)&bounds);
}
return code;
}
SCODE
SA2Video::BltPrepare(
GPEBltParms * pParms
)
{
DEBUGMSG(GPE_ZONE_LINE,(TEXT("SA2Video::BltPrepare\r\n")));
RECTL rectl;
pParms->pBlt = EmulatedBlt;
// Check to see if the software cursor should be disabled.
if (!bDoRotation)
{
if (pParms->pDst == m_pPrimarySurface) // only care if dest is main display surface
{
if (m_CursorVisible && !m_CursorDisabled)
{
if (pParms->prclDst != NULL) // make sure there is a valid prclDst
{
rectl = *pParms->prclDst; // if so, use it
// There is no guarantee of a well ordered rect in pParms
// due to flipping and mirroring.
if(rectl.top > rectl.bottom)
{
int iSwapTmp = rectl.top;
rectl.top = rectl.bottom;
rectl.bottom = iSwapTmp;
}
if(rectl.left > rectl.right)
{
int iSwapTmp = rectl.left;
rectl.left = rectl.right;
rectl.right = iSwapTmp;
}
}
else
{
rectl = m_CursorRect; // if not, use the Cursor rect - this forces the cursor to be turned off in this case.
}
if (m_CursorRect.top <= rectl.bottom && m_CursorRect.bottom >= rectl.top &&
m_CursorRect.left <= rectl.right && m_CursorRect.right >= rectl.left)
{
CursorOff();
m_CursorForcedOff = TRUE;
}
}
}
// check for source overlap with cursor and turn off cursor if overlaps
if (pParms->pSrc == m_pPrimarySurface) // only care if source is main display surface
{
if (m_CursorVisible && !m_CursorDisabled)
{
if (pParms->prclSrc != NULL) // make sure there is a valid prclSrc
{
rectl = *pParms->prclSrc; // if so, use it
}
else
{
rectl = m_CursorRect; // if not, use the Cursor rect - this forces the cursor to be turned off in this case.
}
if (m_CursorRect.top < rectl.bottom && m_CursorRect.bottom > rectl.top &&
m_CursorRect.left < rectl.right && m_CursorRect.right > rectl.left)
{
CursorOff();
m_CursorForcedOff = TRUE;
}
}
}
}
if ((pParms->pDst == m_pPrimarySurface && m_iRotate) || (pParms->pSrc == m_pPrimarySurface && m_iRotate))
{
pParms->pBlt = EmulatedBltRotate;
}
if (bDoRotation && pParms->pDst == m_pPrimarySurface)
{
pParms->pBlt = (SCODE (GPE::*)(GPEBltParms *))WrappedEmulatedBlt;
}
return S_OK;
}
// This function would be used to undo the setting of clip registers etc
SCODE
SA2Video::BltComplete(
GPEBltParms * pParms
)
{
if (!bDoRotation)
{
if (m_CursorForcedOff)
{
m_CursorForcedOff = FALSE;
CursorOn();
}
}
return S_OK;
}
int
SA2Video::InVBlank()
{
static BOOL value = FALSE;
DEBUGMSG (GPE_ZONE_INIT, (TEXT("SA2Video::InVBlank\r\n")));
value = !value;
return value;
}
SCODE
SA2Video::SetPalette(
const PALETTEENTRY * source,
unsigned short firstEntry,
unsigned short numEntries
)
{
if (bpp == 8)
{
if (firstEntry < 0 || firstEntry + numEntries > 256)
{
return E_INVALIDARG;
}
DispDrvrSetPalette(source,firstEntry,numEntries);
}
return S_OK;
}
ULONG *
APIENTRY
DrvGetMasks(
DHPDEV dhpdev
)
{
return BitMasks;
}
// This routine maps between power manager power states and video
// ioctl power states.
ULONG
SA2Video::PmToVideoPowerState(CEDEVICE_POWER_STATE Dx)
{
ULONG PowerState;
switch( Dx )
{
case D0:
case D1:
PowerState = VideoPowerOn;
break;
case D2:
PowerState = VideoPowerStandBy;
break;
case D3:
PowerState = VideoPowerSuspend;
break;
case D4:
PowerState = VideoPowerOff;
break;
default:
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?