📄 halsurf.cpp
字号:
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;
*/
DDPIXELFORMAT *pddpf = &pd->lpDDSurfaceDesc->ddpfPixelFormat;
DWORD caps = pd->lpDDSurfaceDesc->ddsCaps.dwCaps;
/*
// We only have one pixel format for the IPU display (RGB565)
if(pd->bIsDifferentPixelFormat)
{
DEBUGMSG(HAL_ZONE_ERROR, (TEXT("HalCanCreateSurface: the requested surface want different format!\r\n")));
goto CannotCreate;
}
*/
if(pd->bIsDifferentPixelFormat)
{
if (caps & DDSCAPS_OVERLAY) {
if (pddpf->dwFlags & DDPF_FOURCC) {
DEBUGMSG(1, (TEXT("HalCanCreateSurface FOURCC = %08x ('%c','%c','%c','%c')\r\n")
, pddpf->dwFourCC
, (pddpf->dwFourCC ) & 0xff
, (pddpf->dwFourCC >> 8) & 0xff
, (pddpf->dwFourCC >> 16) & 0xff
, (pddpf->dwFourCC >> 24) & 0xff
));
switch (pddpf->dwFourCC) {
case FOURCC_UYVY422:
/* just in case App doesn't fill this */
pddpf->dwYUVBitCount=16;
goto CanCreate;
break;
case FOURCC_YV12:
/* just in case App doesn't fill this */
pddpf->dwYUVBitCount=12;
goto CanCreate;
break;
default:
goto CannotCreate;
}
}
else if (pddpf->dwFlags & DDPF_RGB) {
DEBUGMSG(1, (TEXT("HalCanCreateSurface RGBBitCount = %d\r\n"), pddpf->dwRGBBitCount));
if (
(pddpf->dwRGBBitCount == 16 &&
pddpf->dwRBitMask == 0xF800 &&
pddpf->dwGBitMask == 0x07E0 &&
pddpf->dwBBitMask == 0x001F)
) {
goto CanCreate;
}
else {
goto CannotCreate;
}
}
}
/*
DEBUGMSG(HAL_ZONE_ERROR, (TEXT("HalCanCreateSurface: the requested surface want different format!\r\n")));
goto CannotCreate;
*/
}
#if 0 // We should NOT enable this check, because we can force video memory later in HalCreateSurface().
// If the surface is used for page flipping or overlay, it must be in video memory
DWORD caps = pd->lpDDSurfaceDesc->ddsCaps.dwCaps;
if(caps & (DDSCAPS_FLIP | DDSCAPS_OVERLAY))
{
if(caps & DDSCAPS_VIDEOMEMORY)
{
// Flip or overlay surface is video memory, we can create!
}
else
{
DEBUGMSG(HAL_ZONE_ERROR, (TEXT("HalCanCreateSurface: flip or overlay surface not in video memory\r\n"), caps));
goto CannotCreate;
}
}
#endif
CanCreate:
DEBUGMSG(GPE_ZONE_CREATE, (TEXT("HalCanCreateSurface: OK\r\n")));
pd->ddRVal = DD_OK;
return DDHAL_DRIVER_HANDLED;
CannotCreate:
DEBUGMSG(GPE_ZONE_CREATE, (TEXT("HalCanCreateSurface: Unsupported\r\n")));
pd->ddRVal = DDERR_UNSUPPORTEDFORMAT;
return DDHAL_DRIVER_HANDLED;
}
////////////////////////////////////////////////////////////////////////////////
/////////////////////////// DDHAL_DDSURFACECALLBACKS ///////////////////////////
////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------
//
// Function: HalLock
//
// This callback function locks a specified area of surface memory.
//
// Parameters:
// pd
// [in, out] Pointer to a DDHAL_LOCKDATA structure that contains
// information necessary to lock the specified area.
//
// Returns:
// Returns one of the following values:
// DDHAL_DRIVER_HANDLED
// DDHAL_DRIVER_NOTHANDLED
//
//------------------------------------------------------------------------------
DWORD WINAPI HalLock( LPDDHAL_LOCKDATA pd )
{
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;
*/
// update rotation flag based on driver state
#ifndef PLAT_WPC
#ifndef PLAT_SMARTPHONE
if(((DDIPU_SDC *)g_pGPE)->IsRotated())
{
pd->lpDDSurface->ddsCaps.dwCaps |= DDSCAPS_PRIMARYSURFACELEFT;
}
else
{
pd->lpDDSurface->ddsCaps.dwCaps &= ~DDSCAPS_PRIMARYSURFACELEFT;
}
#endif // ifndef PLAT_SMARTPHONE
#endif // ifndef PLAT_WPC
// call normal lock routine
return DDGPELock(pd);
}
//------------------------------------------------------------------------------
//
// Function: HalFlip
//
// This callback function associates the surface memory
// for the back buffer with the surface memory for the
// front buffer.
//
// Parameters:
// pfd
// [in, out] Pointer to a DDHAL_FLIPDATA structure that contains
// information necessary to perform a flip.
//
// Returns:
// Returns one of the following values:
// DDHAL_DRIVER_HANDLED
// DDHAL_DRIVER_NOTHANDLED
//
//------------------------------------------------------------------------------
DWORD WINAPI HalFlip( LPDDHAL_FLIPDATA pd )
{
//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;
*/
return ((DDIPU_SDC *)GetGPE())->Flip(pd);
}
//------------------------------------------------------------------------------
//
// Function: HalGetBltStatus
//
// This function determines whether the blit queue
// has room for more blits and whether the blit is busy.
//
// Parameters:
// pd
// [in, out] Pointer to a DDHAL_GETBLTSTATUSDATA structure that
// returns the blits status information.
//
// Returns:
// Returns one of the following values:
// DDHAL_DRIVER_HANDLED
// DDHAL_DRIVER_NOTHANDLED
//
//------------------------------------------------------------------------------
DWORD WINAPI HalGetBltStatus( LPDDHAL_GETBLTSTATUSDATA pd )
{
DEBUGENTER( HalGetBltStatus );
/*
typedef struct _DDHAL_GETBLTSTATUSDATA
{
LPDDRAWI_DIRECTDRAW_GBL lpDD; // driver struct
LPDDRAWI_DDRAWSURFACE_LCL lpDDSurface; // surface struct
DWORD dwFlags; // flags
HRESULT ddRVal; // return value
LPDDHALSURFCB_GETBLTSTATUS GetBltStatus; // PRIVATE: ptr to callback
} DDHAL_GETBLTSTATUSDATA;
*/
// Implementation
pd->ddRVal = DD_OK;
if (pd->dwFlags & DDGBS_CANBLT)
{
if (((DDIPU_SDC *)GetGPE())->IsBusy())
{
pd->ddRVal = DDERR_WASSTILLDRAWING;
}
}
else if (pd->dwFlags & DDGBS_ISBLTDONE)
{
if (((DDIPU_SDC *)GetGPE())->IsBusy())
{
pd->ddRVal = DDERR_WASSTILLDRAWING;
}
}
return DDHAL_DRIVER_HANDLED;
}
//------------------------------------------------------------------------------
//
// Function: HalUpdateOverlay
//
// This function repositions or modifies the visual
// attributes of an overlay surface.
//
// Parameters:
// pd
// [in, out] Pointer to a DDHAL_UPDATEOVERLAYDATA structure that
// contains the information required to update the overlay surface.
//
// Returns:
// Returns one of the following values:
// DDHAL_DRIVER_HANDLED
// DDHAL_DRIVER_NOTHANDLED
//
//------------------------------------------------------------------------------
DWORD WINAPI HalUpdateOverlay( LPDDHAL_UPDATEOVERLAYDATA pd )
{
DEBUGENTER( HalUpdateOverlay );
/*
typedef struct _DDHAL_UPDATEOVERLAYDATA
{
LPDDRAWI_DIRECTDRAW_GBL lpDD; // driver struct
LPDDRAWI_DDRAWSURFACE_LCL lpDDDestSurface;// dest surface
RECTL rDest; // dest rect
LPDDRAWI_DDRAWSURFACE_LCL lpDDSrcSurface; // src surface
RECTL rSrc; // src rect
DWORD dwFlags; // flags
DDOVERLAYFX overlayFX; // overlay FX
HRESULT ddRVal; // return value
LPDDHALSURFCB_UPDATEOVERLAY UpdateOverlay; // PRIVATE: ptr to callback
} DDHAL_UPDATEOVERLAYDATA;
*/
// Implementation
return ((DDIPU_SDC *)GetGPE())->UpdateOverlay(pd);
}
//------------------------------------------------------------------------------
//
// Function: HalSetOverlayPosition
//
// This function changes the display coordinates of an overlay surface.
//
// Parameters:
// pd
// [in, out] Pointer to a DDHAL_SETOVERLAYPOSITIONDATA structure
// that contains the information required to change the display
// coordinates of an overlay surface.
//
// Returns:
// Returns one of the following values:
// DDHAL_DRIVER_HANDLED
// DDHAL_DRIVER_NOTHANDLED
//
//------------------------------------------------------------------------------
DWORD WINAPI HalSetOverlayPosition( LPDDHAL_SETOVERLAYPOSITIONDATA pd )
{
DEBUGENTER( HalSetOverlayPosition );
/*
typedef struct _DDHAL_SETOVERLAYPOSITIONDATA
{
LPDDRAWI_DIRECTDRAW_GBL lpDD; // driver struct
LPDDRAWI_DDRAWSURFACE_LCL lpDDSrcSurface; // src surface
LPDDRAWI_DDRAWSURFACE_LCL lpDDDestSurface;// dest surface
LONG lXPos; // x position
LONG lYPos; // y position
HRESULT ddRVal; // return value
LPDDHALSURFCB_SETOVERLAYPOSITION SetOverlayPosition;
// PRIVATE: ptr to callback
} DDHAL_SETOVERLAYPOSITIONDATA;
*/
// Implementation
return ((DDIPU_SDC *)GetGPE())->SetOverlayPosition(pd);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -