Partager via


Capability Bits for Flippable YV12 Overlays

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

The following code example shows how to set the DirectDraw capability bits YV12 overlays that can 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,
    HalWaitForVerticalBlank,
    DDGPECanCreateSurface,
    NULL,
    NULL
};

// callbacks from the DIRECTDRAWSURFACE object

DDHAL_DDSURFACECALLBACKS cbDDSurfaceCallbacks =
{
    sizeof( DDHAL_DDSURFACECALLBACKS ),
        DDHAL_SURFCB32_DESTROYSURFACE     |
        DDHAL_SURFCB32_FLIP               |
        DDHAL_SURFCB32_LOCK               |
        DDHAL_SURFCB32_UNLOCK             |
        DDHAL_SURFCB32_SETCOLORKEY        |
        DDHAL_SURFCB32_GETBLTSTATUS       |
        DDHAL_SURFCB32_GETFLIPSTATUS      |
        DDHAL_SURFCB32_UPDATEOVERLAY      |
        DDHAL_SURFCB32_SETOVERLAYPOSITION |
//      DDHAL_SURFCB32_SETPALETTE         |
        0,
    DDGPEDestroySurface,
    HalFlip,
    DDGPELock,
    DDGPEUnlock,
    HalSetColorKey,
    HalGetBltStatus,
    DDGPEGetFlipStatus,
    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_BACKBUFFER          |
        DDSCAPS_FRONTBUFFER         |
        DDSCAPS_FLIP                |
        DDSCAPS_OVERLAY             |
        DDSCAPS_PRIMARYSURFACE      |
        DDSCAPS_SYSTEMMEMORY        |
        DDSCAPS_VIDEOMEMORY         |
        0;

    lpddhi->ddCaps.dwNumFourCCCodes = MAX_FOURCC;
    lpddhi->ddCaps.dwPalCaps = 0;
    lpddhi->ddCaps.dwMiscCaps = 0;

    // DirectDraw Blitting caps refer to hardware blitting support only.

    lpddhi->ddCaps.dwBltCaps = 0;
    lpddhi->ddCaps.dwCKeyCaps =
        DDCKEYCAPS_SRCBLT       |
        0;
    lpddhi->ddCaps.dwAlphaCaps = 0;

    // Set bits for ROPS supported
    SETROPBIT(lpddhi->ddCaps.dwRops,SRCCOPY);
    SETROPBIT(lpddhi->ddCaps.dwRops,PATCOPY);
    SETROPBIT(lpddhi->ddCaps.dwRops,BLACKNESS);
    SETROPBIT(lpddhi->ddCaps.dwRops,WHITENESS);

    // Overlay caps.

    lpddhi->ddCaps.dwOverlayCaps =
        DDOVERLAYCAPS_FLIP                |
        DDOVERLAYCAPS_CKEYSRC             |
        DDOVERLAYCAPS_CKEYDEST            |
        DDOVERLAYCAPS_CKEYDESTCLRSPACEYUV |
        0;

    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.dwMiscCaps =  0;

    lpddhi->ddCaps.dwMinOverlayStretch = 1000;
    lpddhi->ddCaps.dwMaxOverlayStretch = 1000;
}

See Also

Concepts

Overlay Surfaces