halsurf.cpp
来自「WinCE 3.0 BSP, 包含Inter SA1110, Intel_815」· C++ 代码 · 共 1,899 行 · 第 1/5 页
CPP
1,899 行
if( handled )
{
// DDGPECreateSurface( pcsd );
pcsd->ddRVal = DD_OK;
return DDHAL_DRIVER_HANDLED;
}
/*
* if we return handled, then it is assumed that we did SOMETHING
* with the surface structures to indicate either what size of block
* or a new pitch or some modification; or we are returning an error.
*/
return DDGPECreateSurface( pcsd );
// return DDHAL_DRIVER_HANDLED; //ullas
//return DDHAL_DRIVER_NOTHANDLED;
} /* CreateSurface32 */
//////////////////////////// DDHAL_DDEXEBUFCALLBACKS ////////////////////////////
DWORD WINAPI HalCanCreateSurface( LPDDHAL_CANCREATESURFACEDATA pccsd )
{
//DebugBreak();
// DEBUGENTER( HalCanCreateSurface );
/*
typedef struct _DDHAL_CANCREATESURFACEDATA
{
LPDDRAWI_DIRECTDRAW_GBL lpDD; // driver struct
LPDDSURFACEDESC lpDDSurfaceDesc; // description of surface being created
DWORD bIsDifferentPixelFormat;
// pixel format differs from primary surface
HRESULT ddRVal; // return value
LPDDHAL_CANCREATESURFACE CanCreateSurface;
// PRIVATE: ptr to callback
} DDHAL_CANCREATESURFACEDATA;
*/
// Implementation
/*
* - Well, nothing if surf has color format match screen format.
* - For Overlay: we support RGB8/16 and YUV422, doesn't care about
* screen format.
* - In DDRAWI.H, lpDDSurfaceDesc is declared as SURFACEDESC2 ???
*/
DWORD caps;
LPDDSURFACEDESC lpddsd;
int i;
/*
* NOTES:
*
* This entry point is called after parameter validation but before
* any object creation. You can decide here if it is possible for
* you to create this surface. For example, if the person is trying
* to create an overlay, and you already have the maximum number of
* overlays created, this is the place to fail the call.
*
* You also need to check if the pixel format specified can be supported.
*
* pccsd->bIsDifferentPixelFormat tells us if the pixel format of the
* surface being created matches that of the primary surface. It can be
* true for Z buffer and alpha buffers, so don't just reject it out of
* hand...
*/
//DPF( "CanCreateSurface, pccsd->lpDD=%08lx", pccsd->lpDD );
//DPF( " pccsd->lpDDSurfaceDesc=%08lx", pccsd->lpDDSurfaceDesc );
/*
* check pixel format. Don't allow pixel formats that aren't
* the same, unless we have a valid fourcc code, an overlay,
* an alpha surface, or z buffer. (this is just an example)
*/
lpddsd = (LPDDSURFACEDESC) (pccsd->lpDDSurfaceDesc);
caps = lpddsd->ddsCaps.dwCaps;
if( pccsd->bIsDifferentPixelFormat )
{
//DPF( " different pixel format!" );
if((caps & DDSCAPS_OVERLAY) && (!(OverlayData.OverlayActive)))
{
/* assume ALL formats valid for overlay */
//DPF( " Overlay requested" );
if( lpddsd->ddpfPixelFormat.dwFlags & DDPF_FOURCC )
{
//DPF( " FourCC requested (%4.4hs, 0x%08lx)",
// (LPSTR) &lpddsd->ddpfPixelFormat.dwFourCC,
// lpddsd->ddpfPixelFormat.dwFourCC );
for( i=0;i<sizeof( fourCC )/sizeof( fourCC[0] );i++ )
{
if( lpddsd->ddpfPixelFormat.dwFourCC == fourCC[i] )
{
//DPF( " FOURCC=%4.4hs", (LPSTR) &fourCC[i] );
pccsd->ddRVal = DD_OK;
return DDHAL_DRIVER_HANDLED;
}
}
}
// RGB 5:6:5 is OK!
else if(( lpddsd->ddpfPixelFormat.dwFlags & DDPF_RGB ) &&
( lpddsd->ddpfPixelFormat.dwRGBBitCount == 16 ) &&
( lpddsd->ddpfPixelFormat.dwRBitMask & 0x8000))
{
//DPF( "RGB OK!" );
pccsd->ddRVal = DD_OK;
return DDHAL_DRIVER_HANDLED;
}
}
/*
* can't handle any other kinds of different fourcc or RGB overlays
*/
pccsd->ddRVal = DDERR_INVALIDPIXELFORMAT;
return DDHAL_DRIVER_HANDLED;
}
else
{
if((caps & DDSCAPS_OVERLAY) && (!(OverlayData.OverlayActive)))
{
if(pDriverData->dwBpp != 16)
{
pccsd->ddRVal = DDERR_INVALIDPIXELFORMAT;
return DDHAL_DRIVER_HANDLED;
}
}
}
pccsd->ddRVal = DD_OK;
return DDHAL_DRIVER_HANDLED;
} /* CanCreateSurface32 */
DWORD WINAPI HalCreateExecuteBuffer( LPDDHAL_CREATESURFACEDATA pd )
{
// DEBUGENTER( HalCreateExecuteBuffer );
/*
typedef struct _DDHAL_CREATESURFACEDATA
{
LPDDRAWI_DIRECTDRAW_GBL lpDD; // driver struct
LPDDSURFACEDESC lpDDSurfaceDesc;// description of surface being created
LPDDRAWI_DDRAWSURFACE_LCL FAR *lplpSList; // list of created surface objects
DWORD dwSCnt; // number of surfaces in SList
HRESULT ddRVal; // return value
LPDDHAL_CREATESURFACE CreateSurface; // PRIVATE: ptr to callback
} DDHAL_CREATESURFACEDATA;
*/
// Implementation
pd->ddRVal = DD_OK;
return DDHAL_DRIVER_HANDLED;
}
DWORD WINAPI HalDestroyExecuteBuffer( LPDDHAL_DESTROYSURFACEDATA pd )
{
// DEBUGENTER( HalDestroyExecutebuffer );
/*
typedef struct _DDHAL_DESTROYSURFACEDATA
{
LPDDRAWI_DIRECTDRAW_GBL lpDD; // driver struct
LPDDRAWI_DDRAWSURFACE_LCL lpDDSurface; // surface struct
HRESULT ddRVal; // return value
LPDDHALSURFCB_DESTROYSURFACE DestroySurface;// PRIVATE: ptr to callback
BOOL fDestroyGlobal;
} DDHAL_DESTROYSURFACEDATA;
*/
// Implementation
pd->ddRVal = DD_OK;
return DDHAL_DRIVER_HANDLED;
}
DWORD WINAPI HalLock( LPDDHAL_LOCKDATA lpLockData )
{
// DEBUGENTER( HalLock );
/*
typedef struct _DDHAL_LOCKDATA
{
LPDDRAWI_DIRECTDRAW_GBL lpDD; // driver struct
LPDDRAWI_DDRAWSURFACE_LCL lpDDSurface; // surface struct
DWORD bHasRect; // rArea is valid
RECTL rArea; // area being locked
LPVOID lpSurfData; // pointer to screen memory (return value)
HRESULT ddRVal; // return value
LPDDHALSURFCB_LOCK Lock; // PRIVATE: ptr to callback
} DDHAL_LOCKDATA;
*/
HRESULT ddrval;
/*
* NOTES:
*
* This callback is invoked whenever a surface is about to be directly
* accessed by the user. This is where you need to make sure that
* a surface can be safely accessed by the user.
*
* If your memory cannot be accessed while in accelerator mode, you
* should take either take the card out of accelerator mode or else
* return DDERR_SURFACEBUSY
*
* If someone is accessing a surface that was just flipped away from,
* make sure that the old surface (what was the primary) has finished
* being displayed.
*/
/*
* check to see if any pending physical flip has occurred
*/
ddrval = updateFlipStatus(lpLockData->lpDDSurface->lpGbl->fpVidMem);
if( ddrval != DD_OK )
{
lpLockData->ddRVal = DDERR_WASSTILLDRAWING;
return DDHAL_DRIVER_HANDLED;
}
/*
* don't allow a lock if a blt is in progress (only do this if your
* hardware requires it)
*/
if(DRAW_ENGINE_BUSY)
{
lpLockData->ddRVal = DDERR_WASSTILLDRAWING;
return DDHAL_DRIVER_HANDLED;
}
return DDHAL_DRIVER_NOTHANDLED;
} /* Lock32 */
DWORD WINAPI HalUnlock( LPDDHAL_UNLOCKDATA pd )
{
// DEBUGENTER( HalUnlock );
/*
typedef struct _DDHAL_UNLOCKDATA
{
LPDDRAWI_DIRECTDRAW_GBL lpDD; // driver struct
LPDDRAWI_DDRAWSURFACE_LCL lpDDSurface; // surface struct
HRESULT ddRVal; // return value
LPDDHALSURFCB_UNLOCK Unlock; // PRIVATE: ptr to callback
} DDHAL_UNLOCKDATA;
*/
// Implementation
return DDHAL_DRIVER_NOTHANDLED;
} /* Unlock32 */
//////////////////////////// DDHAL_DDSURFACECALLBACKS ////////////////////////////
DWORD WINAPI HalDestroySurface( LPDDHAL_DESTROYSURFACEDATA pdsd )
{
// DEBUGENTER( HalDestroySurface );
/*
typedef struct _DDHAL_DESTROYSURFACEDATA
{
LPDDRAWI_DIRECTDRAW_GBL lpDD; // driver struct
LPDDRAWI_DDRAWSURFACE_LCL lpDDSurface; // surface struct
HRESULT ddRVal; // return value
LPDDHALSURFCB_DESTROYSURFACE DestroySurface;// PRIVATE: ptr to callback
BOOL fDestroyGlobal;
} DDHAL_DESTROYSURFACEDATA;
*/
// if(OverlayInUse){
// OverlayInUse=FALSE;
// }
// Implementation
LPDDRAWI_DDRAWSURFACE_GBL pdsd_gbl;
pdsd_gbl = pdsd->lpDDSurface->lpGbl;
if(pdsd->lpDDSurface->ddsCaps.dwCaps & DDSCAPS_OVERLAY)
{
// Disable video output in GXi
OverlayData.OverlayActive = FALSE;
}
// pdsd->ddRVal = DD_OK;
// return DDHAL_DRIVER_NOTHANDLED;
return DDGPEDestroySurface(pdsd);
} /* DestroySurface32 */
DWORD WINAPI HalSetSurfaceDesc(LPDDHAL_HALSETSURFACEDESCDATA pd)
{
// DEBUGENTER( HalSetSurfaceDesc );
/*
typedef struct _DDHAL_HALSETSURFACEDESCDATA
{
DWORD dwSize; // Size of this structure
LPDDRAWI_DDRAWSURFACE_LCL lpDDSurface; // Surface
LPDDSURFACEDESC lpddsd; // Description of surface
HRESULT ddrval;
} DDHAL_HALSETSURFACEDESCDATA;
*/
// Implementation
pd->ddrval = DD_OK;
return DDHAL_DRIVER_HANDLED;
}
DWORD WINAPI HalFlip( LPDDHAL_FLIPDATA pfd ) {
// DEBUGENTER( HalFlip );
/*
typedef struct _DDHAL_FLIPDATA
{
LPDDRAWI_DIRECTDRAW_GBL lpDD; // driver struct
LPDDRAWI_DDRAWSURFACE_LCL lpSurfCurr; // current surface
LPDDRAWI_DDRAWSURFACE_LCL lpSurfTarg; // target surface (to flip to)
DWORD dwFlags; // flags
HRESULT ddRVal; // return value
LPDDHALSURFCB_FLIP Flip; // PRIVATE: ptr to callback
} DDHAL_FLIPDATA;
*/
HRESULT ddrval;
/*
* NOTES:
*
* This callback is invoked whenever we are about to flip to from
* one surface to another. pfd->lpSurfCurr is the surface we were at,
* pfd->lpSurfTarg is the one we are flipping to.
*
* You should point the hardware registers at the new surface, and
* also keep track of the surface that was flipped away from, so
* that if the user tries to lock it, you can be sure that it is done
* being displayed
*/
//DPF( "Flip32: curr=%08lx, targ=%08lx", pfd->lpSurfCurr, pfd->lpSurfTarg );
//DPF( " vidmem ptrs change: %08lx->%08lx",
// pfd->lpSurfCurr->lpGbl->fpVidMem,
// pfd->lpSurfTarg->lpGbl->fpVidMem );
ddrval = updateFlipStatus(unflipRecord.fpFlipFrom);
if (ddrval)
{
pfd->ddRVal = ddrval;
return DDHAL_DRIVER_HANDLED;
}
/*
* is the bltter busy right now?
*/
if (DRAW_ENGINE_BUSY)
{
pfd->ddRVal = DDERR_WASSTILLDRAWING;
return DDHAL_DRIVER_HANDLED;
}
/*
* everything is OK, do the flip here
*/
if (pfd->lpSurfTarg->ddsCaps.dwCaps & DDSCAPS_OVERLAY)
{
SetVideoOffset(pfd->lpSurfTarg->lpGbl->fpVidMem - pDriverData->FbLinear);
}
else
{
// FlipDisplay(pfd->lpSurfTarg->lpGbl->fpVidMem - pDriverData->FbLinear);
DDGPEFlip(pfd);
}
/*
* remember if we did the flip
*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?