This is the mail archive of the
cygwin-xfree@cygwin.com
mailing list for the Cygwin XFree86 project.
Re: DirectDraw vs. GDI Device Independent Bitmaps for shadow fb server (and other development news)
- To: "Harold Hunt" <huntharo at msu dot edu>
- Subject: Re: DirectDraw vs. GDI Device Independent Bitmaps for shadow fb server (and other development news)
- From: "John Fortin" <fortinj at attglobal dot net>
- Date: Sat, 24 Mar 2001 12:21:31 -0500
- Cc: <cygwin-xfree at cygwin dot com>
- References: <000001c0b446$45f972a0$2fab0a23@huntharo>
> 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;