Mercurial > sdl-ios-xcode
diff src/video/windx5/SDL_dx5video.c @ 292:eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Incorporated XFree86 extension libraries into the source
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 05 Mar 2002 19:55:32 +0000 |
parents | e8157fcb3114 |
children | fab1ddc4d7bf |
line wrap: on
line diff
--- a/src/video/windx5/SDL_dx5video.c Sat Mar 02 16:50:35 2002 +0000 +++ b/src/video/windx5/SDL_dx5video.c Tue Mar 05 19:55:32 2002 +0000 @@ -421,6 +421,7 @@ static int DX5_SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key); static int DX5_SetHWAlpha(_THIS, SDL_Surface *surface, Uint8 alpha); static int DX5_LockHWSurface(_THIS, SDL_Surface *surface); +static int DX5_LockHWSurfaceRect(_THIS, SDL_Surface *surface, SDL_Rect *rect, void **pixels, int *pitch); static void DX5_UnlockHWSurface(_THIS, SDL_Surface *surface); static int DX5_FlipHWSurface(_THIS, SDL_Surface *surface); static void DX5_FreeHWSurface(_THIS, SDL_Surface *surface); @@ -591,7 +592,9 @@ device->SetHWColorKey = DX5_SetHWColorKey; device->SetHWAlpha = DX5_SetHWAlpha; device->LockHWSurface = DX5_LockHWSurface; + device->LockHWSurfaceRect = DX5_LockHWSurfaceRect; device->UnlockHWSurface = DX5_UnlockHWSurface; + device->UnlockHWSurfaceRect = DX5_UnlockHWSurface; device->FlipHWSurface = DX5_FlipHWSurface; device->FreeHWSurface = DX5_FreeHWSurface; #ifdef IID_IDirectDrawGammaControl @@ -1910,6 +1913,43 @@ surface->pixels = ddsd.lpSurface; return(0); } +static int DX5_LockHWSurfaceRect(_THIS, SDL_Surface *surface, SDL_Rect *rect, void **pixels, int *pitch) +{ + HRESULT result; + LPDIRECTDRAWSURFACE3 dd_surface; + DDSURFACEDESC ddsd; + RECT ddrect; + + /* Calculate the lock rectangle */ + ddrect.top = rect->y; + ddrect.bottom = rect->y+rect->h; + ddrect.left = rect->x; + ddrect.right = rect->x+rect->w; + + /* Lock and load! */ + dd_surface = surface->hwdata->dd_writebuf; + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + result = IDirectDrawSurface3_Lock(dd_surface, &ddrect, &ddsd, + (DDLOCK_NOSYSLOCK|DDLOCK_WAIT), NULL); + if ( result == DDERR_SURFACELOST ) { + result = IDirectDrawSurface3_Restore( + surface->hwdata->dd_surface); + result = IDirectDrawSurface3_Lock(dd_surface, &ddrect, &ddsd, + (DDLOCK_NOSYSLOCK|DDLOCK_WAIT), NULL); + } + if ( result != DD_OK ) { + SetDDerror("DirectDrawSurface3::Lock", result); + return(-1); + } + *pixels = ddsd.lpSurface; +#if defined(NONAMELESSUNION) + *pitch = ddsd.u1.lPitch; +#else + *pitch = (Uint16)ddsd.lPitch; +#endif + return(0); +} static void DX5_UnlockHWSurface(_THIS, SDL_Surface *surface) {