📄 wince_ws.c
字号:
PWSREGION psNext;
while(psRegion)
{
psNext=psRegion->psNext;
free(psRegion);
psRegion=psNext;
}
}
/*****************************************************************************
FUNCTION : FreeItems
DESCRIPTION: Free the specified item list
PARAMETERS : PLISTITEM psRegion
RETURNS : None
*****************************************************************************/
void FreeItems(PLISTITEM psItem)
{
PLISTITEM psNext;
while(psItem)
{
psNext=psItem->psNext;
free(psItem);
psItem=psNext;
}
}
/*****************************************************************************
FUNCTION : DoClippedBlits
DESCRIPTION: Issue the blits for the list of blit regions
PARAMETERS : PVRSRV_SURF sDestSurface
KEGL_SURFACE *psSourceSurface
RETURNS : None
*****************************************************************************/
IMG_BOOL DoClippedBlits(PVRSRV_SURF sDestSurface, KEGL_SURFACE *psSourceSurface)
{
PWSREGION psCur;
int nWidth,nHeight,nDestX,nDestY,nSrcX,nSrcY;
IMG_BOOL bDoUpdate=FALSE;
// we need to use the Rotation angle to transform the source and destination rectangles the requirements for the blit are.
// Source address, height and width of blit, and source offsets
psCur=psSourceSurface->u.window.ws.psClippedBlits;
while(psCur)
{
// todo we still have a incluseive/exclusive rectangle mismatch to sort out....
switch(psSourceSurface->u.window.ws.ui32RotationAngle)
{
case 270:
nWidth=(psCur->sRect.i32Bottom-psCur->sRect.i32Top)+1;
nHeight=(psCur->sRect.i32Right-psCur->sRect.i32Left)+1;
nDestX=(sDestSurface.ui32PixelWidth-psCur->sRect.i32Bottom)-1;
nDestY=psCur->sRect.i32Left;
nSrcX=(psSourceSurface->u.window.ws.sWindowRect.i32Bottom-1)-psCur->sRect.i32Bottom;
nSrcY=psCur->sRect.i32Left-psSourceSurface->u.window.ws.sWindowRect.i32Left;
break;
case 90:
nWidth=(psCur->sRect.i32Bottom-psCur->sRect.i32Top)+1;
nHeight=(psCur->sRect.i32Right-psCur->sRect.i32Left)+1;
nDestX=psCur->sRect.i32Top;
nDestY=(sDestSurface.ui32PixelHeight-psCur->sRect.i32Right)-1;
nSrcX=psCur->sRect.i32Top-psSourceSurface->u.window.ws.sWindowRect.i32Top;
nSrcY=(psSourceSurface->u.window.ws.sWindowRect.i32Right-1)-psCur->sRect.i32Right;
break;
case 180:
nWidth=(psCur->sRect.i32Right-psCur->sRect.i32Left)+1;
nHeight=(psCur->sRect.i32Bottom-psCur->sRect.i32Top)+1;
nDestX=(sDestSurface.ui32PixelWidth - psCur->sRect.i32Right)-1;
nDestY=(sDestSurface.ui32PixelHeight- psCur->sRect.i32Bottom) -1;
nSrcX=(psSourceSurface->u.window.ws.sWindowRect.i32Right-1)-psCur->sRect.i32Right;
nSrcY=(psSourceSurface->u.window.ws.sWindowRect.i32Bottom-1)-psCur->sRect.i32Bottom;
break;
// Lets treat the default case the same as 0
case 0:
nWidth=(psCur->sRect.i32Right-psCur->sRect.i32Left)+1;
nHeight=(psCur->sRect.i32Bottom-psCur->sRect.i32Top)+1;
nDestX=psCur->sRect.i32Left;
nDestY=psCur->sRect.i32Top;
nSrcX=psCur->sRect.i32Left - psSourceSurface->u.window.ws.sWindowRect.i32Left;
nSrcY=psCur->sRect.i32Top -psSourceSurface->u.window.ws.sWindowRect.i32Top;
default:
break;
}
if( DoBlit(psSourceSurface->psQueueInfo,&psSourceSurface->sCurrentRenderSurface,&sDestSurface,nSrcX,nSrcY,nWidth,nHeight,nDestX,nDestY))
{
bDoUpdate=IMG_TRUE;
}
psCur=psCur->psNext;
}
return bDoUpdate;
}
/*****************************************************************************
FUNCTION : DoBlit
DESCRIPTION: Does a blit, paramters are already rotated etc
PARAMETERS : PVRSRV_QUEUE_INFO *psQueue
PVRSRV_SURF *psSrc
PVRSRV_SURF *psDest
IMG_INT32 srcXpos
IMG_INT32 srcYpos
IMG_INT32 Width
IMG_INT32 Height
IMG_INT32 DestXpos
IMG_INT32 DestYpos
RETURNS : None
*****************************************************************************/
IMG_BOOL DoBlit (PVRSRV_QUEUE_INFO *psQueue,PVRSRV_SURF *psSrc,PVRSRV_SURF *psDest,IMG_INT32 srcXpos,IMG_INT32 srcYpos,IMG_INT32 Width, IMG_INT32 Height,IMG_INT32 DestXpos,IMG_INT32 DestYpos)
{
PVRSRV_MEM_INFO *psSrcSurf, *psDstSurf;
IMG_UINT32 ui32DstFormat, ui32SrcFormat;
IMG_UINT32 aui32BltData[12];
IMG_INT32 nSrcXStart,nDestXStart,nDestXEnd;
IMG_INT32 nSrcYStart,nDestYStart,nDestYEnd;
psSrcSurf = psSrc->psMemInfo;
psDstSurf = psDest->psMemInfo;
switch(psDest->ePixelFormat)
{
case PVRSRV_PIXEL_FORMAT_ARGB8888:
ui32DstFormat = MBX2D_DST_8888ARGB;
ui32SrcFormat = MBX2D_SRC_8888ARGB;
break;
case PVRSRV_PIXEL_FORMAT_RGB565:
ui32DstFormat = MBX2D_DST_565RGB;
ui32SrcFormat = MBX2D_SRC_565RGB;
break;
default:
return IMG_FALSE;
}
/* We need to clip the data to fit on screen */
nSrcXStart=srcXpos;
nDestXStart=DestXpos;
nDestXEnd=nDestXStart+Width;
nSrcYStart=srcYpos;
nDestYStart=DestYpos;
nDestYEnd=nDestYStart+Height;
if(nDestXStart<0)
{
if(nDestXEnd<=0)
{
/* The blit is entirely off screen! so don't do it*/
return IMG_FALSE;
}
nSrcXStart+=-nDestXStart;
nDestXStart=0;
}
if(nDestXEnd>(IMG_INT32)psDest->ui32PixelWidth)
{
nDestXEnd=psDest->ui32PixelWidth;
if(nDestXStart>=(IMG_INT32)psDest->ui32PixelWidth)
{
/* The blit is entirely off screen! so don't do it*/
return IMG_FALSE;
}
}
if(nDestYStart<0)
{
if(nDestYEnd<=0)
{
/* The blit is entirely off screen! so don't do it*/
return IMG_FALSE;
}
nSrcYStart+=-nDestYStart;
nDestYStart=0;
}
if(nDestYEnd>(IMG_INT32)psDest->ui32PixelHeight)
{
nDestYEnd=psDest->ui32PixelHeight;
if(nDestYStart>=(IMG_INT32)psDest->ui32PixelHeight)
{
/* The blit is entirely off screen! so don't do it*/
return IMG_FALSE;
}
}
aui32BltData[0] = MBX2D_DST_CTRL_BH
| ui32DstFormat
| psDest->ui32ByteStride;
aui32BltData[1] = ((psDstSurf->uiDevAddr.uiAddr
>> MBX2D_DST_ADDR_ALIGNSHIFT)
<< MBX2D_DST_ADDR_SHIFT)
& MBX2D_DST_ADDR_MASK;
aui32BltData[2] = MBX2D_SRC_CTRL_BH | MBX2D_SRC_FBMEM | ui32SrcFormat | psSrc->ui32ByteStride;
aui32BltData[3] = ((psSrcSurf->uiDevAddr.uiAddr
>> MBX2D_SRC_ADDR_ALIGNSHIFT)
<< MBX2D_SRC_ADDR_SHIFT)
& MBX2D_SRC_ADDR_MASK;
aui32BltData[4] = MBX2D_SRC_OFF_BH | (nSrcXStart << MBX2D_SRCOFF_XSTART_SHIFT) | (nSrcYStart << MBX2D_SRCOFF_YSTART_SHIFT);
aui32BltData[5] = MBX2D_STRETCH_BH | (MBX2D_NO_STRETCH << MBX2D_X_STRETCH_SHIFT) | (MBX2D_NO_STRETCH << MBX2D_Y_STRETCH_SHIFT);
aui32BltData[6] = MBX2D_BLIT_BH
| MBX2D_USE_PAT
| MBX2D_ROP3_SRCCOPY;
aui32BltData[7] = (nDestXStart << MBX2D_DST_XSTART_SHIFT)
| (nDestYStart << MBX2D_DST_YSTART_SHIFT);
aui32BltData[8] = (nDestXEnd << MBX2D_DST_XEND_SHIFT)
| (nDestYEnd << MBX2D_DST_YEND_SHIFT);
aui32BltData[9] = MBX2D_FENCE_BH;
PVRSRVQueueBlt(psQueue, psDstSurf->psSyncInfo, 1, &psSrcSurf->psSyncInfo, 10, aui32BltData);
return IMG_TRUE;
}
/*****************************************************************************
FUNCTION : WS_CopyBuffers
DESCRIPTION: Copy the data from the Source surface into the Target Pixmap
PARAMETERS : PVRSRV_SURF sDestSurface
KEGL_SURFACE *psSourceSurface
NativePixmapType hTarget
RETURNS : EGL_SUCCESS
*****************************************************************************/
EGLint WS_CopyBuffers(KEGL_SURFACE *psSourceSurface, NativePixmapType hTarget)
{
HBITMAP hBitmap;
HBITMAP hBitmapOld;
HDC hDCMem;
HDC hDCScreen;
PVRSRV_SURF *psCurrentRenderSurface = &psSourceSurface->sCurrentRenderSurface;
IMG_UINT32 ui32CurVal;
COLORREF sColor;
IMG_UINT32 *pui32CurVal;
IMG_UINT16 *pui16CurVal;
BYTE byRed;
BYTE byGreen;
BYTE byBlue;
int nYColStep,
nXColStep,
nYRowStep,
nXRowStep,
nCurY,
nYPos,
nCurX,
nXPos,
XStart,
YStart;
int nCopyHeight,nCopyWidth;
int size;
LONG a=0;
PBYTE pbyCur;
hDCScreen=GetDC(NULL);
hDCMem = CreateCompatibleDC (hDCScreen);
ReleaseDC(NULL,hDCScreen);
hBitmap=(HBITMAP)hTarget;
hBitmapOld = SelectObject (hDCMem, hBitmap);
nCopyWidth=psCurrentRenderSurface->ui32PixelWidth;
nCopyHeight=psCurrentRenderSurface->ui32PixelHeight;
switch(psCurrentRenderSurface->ePixelFormat)
{
default:
case PVRSRV_PIXEL_FORMAT_ARGB8888:
size=4;
break;
case PVRSRV_PIXEL_FORMAT_RGB565:
size=2;
break;
}
/* we have to do several things.
First validate the sizes and formats (we can convert from whatever our framebuffer is in to the bitmap so long as it is an RGB type)
Setup our startposition and steps dependant on the rotation of the framebuffer.
Iterate through the source line by line, and output to the required pixel coordinate in the output bitmap
The coordinate mapping is as follows (i think!)
Rotation = 0:
XStart = 0
YStart = 0
ColumnIncrement = X=X+1
RowIncrement = Y=Y+1
Rotation = 90:
XStart = bm.width
YStart = 0
ColumnIncrement = Y=Y+1
RowIncrement = X=X-1
Rotation = 180:
XStart = bm.width
YStart = bm.height
ColumnIncrement = X=X-1
RowIncrement = Y=Y-1
Rotation = 270:
XStart = 0
YStart = bm.height
ColumnIncrement = Y=Y-1
RowIncrement = X=X+1
*/
pbyCur=(PBYTE)psCurrentRenderSurface->psMemInfo->pvLinAddr;
switch(GetRotationAngle())
{
case 0:
nYColStep=0;
nXColStep=1;
nYRowStep=1;
nXRowStep=0;
XStart=0;
YStart=0;
break;
case 90:
nYColStep=1;
nXColStep=0;
nYRowStep=0;
nXRowStep=-1;
XStart=nCopyHeight-1;
YStart=0;
break;
case 270:
nYColStep=-1;
nXColStep=0;
nYRowStep=0;
nXRowStep=1;
XStart=0;
YStart=nCopyWidth-1;
break;
case 180:
nYColStep=0;
nXColStep=-1;
nYRowStep=-1;
nXRowStep=0;
YStart=nCopyHeight-1;
XStart=nCopyWidth-1;
break;
}
nCurY=YStart;
nCurX=XStart;
for(nYPos=0;nYPos<nCopyHeight;nYPos++)
{
if(!nXRowStep)
{
nCurX=XStart;
}
if(!nYRowStep)
{
nCurY=YStart;
}
pbyCur=(PBYTE)psCurrentRenderSurface->psMemInfo->pvLinAddr + (nYPos*psCurrentRenderSurface->ui32ByteStride);
for(nXPos=0;nXPos<nCopyWidth;nXPos++)
{
if(size==4)
{
pui32CurVal=(IMG_UINT32*)pbyCur;
ui32CurVal= *pui32CurVal;
sColor=RGB( ((ui32CurVal&0xff0000) >>16),((ui32CurVal&0x00ff00) >>8),((ui32CurVal&0x0000ff) >>0) );
}
else
{
pui16CurVal=(IMG_UINT16*)pbyCur;
ui32CurVal= *pui16CurVal;
byRed=(BYTE)((ui32CurVal&0xf800) >>8);
byRed |= (byRed)>>5;
byGreen = (BYTE)((ui32CurVal&0x07e0) >>3);
byGreen |= (byGreen)>>6;
byBlue = (BYTE)((ui32CurVal&0x001f) <<3);
byBlue |= (byBlue)>>5;
sColor=RGB(byRed ,byGreen ,byBlue );
}
SetPixel(hDCMem,nCurX,nCurY,sColor);
pbyCur+=size;
nCurY+=nYColStep;
nCurX+=nXColStep;
}
nCurY+=nYRowStep;
nCurX+=nXRowStep;
}
// Delete the memory device context and the display device context.
DeleteDC (hDCMem);
return EGL_SUCCESS;
}
IMG_BOOL IsSecondaryExternalFu
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -