DirectDraw vs. GDI Device Independent Bitmaps for shadow fb server (and other development news)

John Fortin fortinj@attglobal.net
Sun Apr 1 00:00:00 GMT 2001


> Performance is so varied between DirectDraw and GDI DIB for shadow fb
> servers because DirectDraw requires that you unlock, or throw away your
> memory pointer, to the shadow framebuffer before you transfer (blit) the
> shadow framebuffer to the screen.  After a series of blits you must
> reacquire a pointer to the shadow framebuffer bits so that the 'fb' code
can
> continue painting the screen.  However, with GDI DIBs you do not have to
> throw away your memory pointer when you blit the shadow fb to the screen,
> resulting in a much more responsive server.

if you use the DDSCAPS_SYSTEMMEMORY CAPS flag, direct draw lets you define a
specific area in user memory for
surfaces.  You have to manage it ( ie proper size, pixel format, etc), but
now you have a static pointer for you frame buffer.
ddraw locks it for blitting, but this does not prevent other threads from
writing to it during the blit.  This is MUCH faster then the
write/lock/blit/unlock/write sequence.  BTW this only works for DX 6 and
higher.  Below is a function I use for the GGI port. Look at lpSurfaceAdd
and bddsd.lpSurface

John Fortin

int CreateBackup(void)
{
        HRESULT rc;
        char message[100];

        memset(&bddsd, 0, sizeof(bddsd));
        bddsd.dwSize = sizeof(bddsd);
        bddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PITCH
            | DDSD_LPSURFACE | DDSD_PITCH | DDSD_PIXELFORMAT;
        bddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN |
DDSCAPS_SYSTEMMEMORY;
        lpSurfaceAdd = (char *) malloc(pddsd.dwWidth * pddsd.dwHeight
                              * pddsd.ddpfPixelFormat.dwRGBBitCount / 8);
        ZeroMemory(lpSurfaceAdd, (DWORD) (pddsd.dwWidth * pddsd.dwHeight
                             * pddsd.ddpfPixelFormat.dwRGBBitCount / 8));
        bddsd.lpSurface = lpSurfaceAdd;
        bddsd.dwWidth = pddsd.dwWidth;
        bddsd.dwHeight = pddsd.dwHeight;
        bddsd.lPitch = pddsd.lPitch;




More information about the Cygwin-xfree mailing list