Capability Bits for Non-flippable YV12 Overlays
The following code example shows how to set the DirectDraw capability bits for YV12 overlays that cannot be flipped.
Note To make the following code example easier to read, security checking and error handling are not included. This code example should not be used in a release configuration unless it has been modified to include them.
#include "precomp.h"
DWORD g_FourCC[] = {
FOURCC_YV12,
};
#define MAX_FOURCC ( sizeof ( g_FourCC ) / sizeof ( g_FourCC[0] ) )
// callbacks from the DIRECTDRAW object
DDHAL_DDCALLBACKS cbDDCallbacks =
{
sizeof( DDHAL_DDCALLBACKS ),
DDHAL_CB32_CREATESURFACE |
DDHAL_CB32_WAITFORVERTICALBLANK |
DDHAL_CB32_CANCREATESURFACE |
// DDHAL_CB32_CREATEPALETTE |
// DDHAL_CB32_GETSCANLINE |
0,
DDGPECreateSurface,
DDGPEWaitForVerticalBlank,
DDGPECanCreateSurface,
NULL,
NULL
};
// callbacks from the DIRECTDRAWSURFACE object
DDHAL_DDSURFACECALLBACKS cbDDSurfaceCallbacks =
{
sizeof( DDHAL_DDSURFACECALLBACKS ),
DDHAL_SURFCB32_DESTROYSURFACE |
DDHAL_SURFCB32_LOCK |
DDHAL_SURFCB32_UNLOCK |
DDHAL_SURFCB32_SETCOLORKEY |
DDHAL_SURFCB32_GETBLTSTATUS |
DDHAL_SURFCB32_UPDATEOVERLAY |
DDHAL_SURFCB32_SETOVERLAYPOSITION |
// DDHAL_SURFCB32_SETPALETTE |
0,
DDGPEDestroySurface,
NULL,
DDGPELock,
DDGPEUnlock,
DDGPESetColorKey,
HalGetBltStatus,
NULL,
HalUpdateOverlay,
HalSetOverlayPosition,
NULL
};
// InitDDHALInfo must set up this information
unsigned long g_nVideoMemorySize = 0L;
unsigned char * g_pVideoMemory = NULL; // virtual address of video
// memory from client's side
DWORD g_nTransparentColor = 0L;
EXTERN_C void
buildDDHALInfo(
LPDDHALINFO lpddhi,
DWORD modeidx
)
{
GPEFlat * pGPEFlat = static_cast<GPEFlat *>(GetDDGPE());
if( !g_pVideoMemory ) // in case this is called more than once...
{
unsigned long VideoMemoryStart;
pGPEFlat->GetVirtualVideoMemory( &VideoMemoryStart,
&g_nVideoMemorySize );
DEBUGMSG( GPE_ZONE_INIT,
(TEXT("GetVirtualVideoMemory returned addr=0x%08x size=%d\r\n"),
VideoMemoryStart, g_nVideoMemorySize));
g_pVideoMemory = (BYTE*)VideoMemoryStart;
DEBUGMSG( GPE_ZONE_INIT,
(TEXT("gpVidMem=%08x\r\n"), g_pVideoMemory ));
}
memset( lpddhi, 0, sizeof(DDHALINFO) ); // Clear the DDHALINFO
// structure
lpddhi->dwSize = sizeof(DDHALINFO);
lpddhi->lpDDCallbacks = &cbDDCallbacks;
lpddhi->lpDDSurfaceCallbacks = &cbDDSurfaceCallbacks;
lpddhi->GetDriverInfo = HalGetDriverInfo;
lpddhi->lpdwFourCC = g_FourCC;
// Capability bits.
lpddhi->ddCaps.dwSize = sizeof(DDCAPS);
lpddhi->ddCaps.dwVidMemTotal = g_nVideoMemorySize;
lpddhi->ddCaps.dwVidMemFree = g_nVideoMemorySize;
lpddhi->ddCaps.dwVidMemStride = 0;
lpddhi->ddCaps.ddsCaps.dwCaps =
DDSCAPS_FRONTBUFFER |
DDSCAPS_OVERLAY |
DDSCAPS_PRIMARYSURFACE |
DDSCAPS_SYSTEMMEMORY |
DDSCAPS_VIDEOMEMORY |
0;
lpddhi->ddCaps.dwNumFourCCCodes = MAX_FOURCC;
lpddhi->ddCaps.dwPalCaps = 0;
lpddhi->ddCaps.dwMiscCaps = 0;
// DirectDraw Blttting caps refer to hardware blitting support only.
lpddhi->ddCaps.dwBltCaps = 0;
lpddhi->ddCaps.dwCKeyCaps = 0;
lpddhi->ddCaps.dwAlphaCaps = 0;
// Overlay caps.
lpddhi->ddCaps.dwOverlayCaps = DDOVERLAYCAPS_FOURCC;
lpddhi->ddCaps.dwMaxVisibleOverlays = 1;
lpddhi->ddCaps.dwCurrVisibleOverlays = 0;
lpddhi->ddCaps.dwAlignBoundarySrc = 0;
lpddhi->ddCaps.dwAlignSizeSrc = 0;
lpddhi->ddCaps.dwAlignBoundaryDest = 0;
lpddhi->ddCaps.dwAlignSizeDest = 0;
lpddhi->ddCaps.dwMinOverlayStretch = 1000;
lpddhi->ddCaps.dwMaxOverlayStretch = 1000;
}
See Also
Send Feedback on this topic to the authors