comparison 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
comparison
equal deleted inserted replaced
291:68a8a8237c09 292:eadc0746dfaf
419 static int DX5_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst); 419 static int DX5_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst);
420 static int DX5_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color); 420 static int DX5_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color);
421 static int DX5_SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key); 421 static int DX5_SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key);
422 static int DX5_SetHWAlpha(_THIS, SDL_Surface *surface, Uint8 alpha); 422 static int DX5_SetHWAlpha(_THIS, SDL_Surface *surface, Uint8 alpha);
423 static int DX5_LockHWSurface(_THIS, SDL_Surface *surface); 423 static int DX5_LockHWSurface(_THIS, SDL_Surface *surface);
424 static int DX5_LockHWSurfaceRect(_THIS, SDL_Surface *surface, SDL_Rect *rect, void **pixels, int *pitch);
424 static void DX5_UnlockHWSurface(_THIS, SDL_Surface *surface); 425 static void DX5_UnlockHWSurface(_THIS, SDL_Surface *surface);
425 static int DX5_FlipHWSurface(_THIS, SDL_Surface *surface); 426 static int DX5_FlipHWSurface(_THIS, SDL_Surface *surface);
426 static void DX5_FreeHWSurface(_THIS, SDL_Surface *surface); 427 static void DX5_FreeHWSurface(_THIS, SDL_Surface *surface);
427 428
428 static int DX5_AllocDDSurface(_THIS, SDL_Surface *surface, 429 static int DX5_AllocDDSurface(_THIS, SDL_Surface *surface,
589 device->CheckHWBlit = DX5_CheckHWBlit; 590 device->CheckHWBlit = DX5_CheckHWBlit;
590 device->FillHWRect = DX5_FillHWRect; 591 device->FillHWRect = DX5_FillHWRect;
591 device->SetHWColorKey = DX5_SetHWColorKey; 592 device->SetHWColorKey = DX5_SetHWColorKey;
592 device->SetHWAlpha = DX5_SetHWAlpha; 593 device->SetHWAlpha = DX5_SetHWAlpha;
593 device->LockHWSurface = DX5_LockHWSurface; 594 device->LockHWSurface = DX5_LockHWSurface;
595 device->LockHWSurfaceRect = DX5_LockHWSurfaceRect;
594 device->UnlockHWSurface = DX5_UnlockHWSurface; 596 device->UnlockHWSurface = DX5_UnlockHWSurface;
597 device->UnlockHWSurfaceRect = DX5_UnlockHWSurface;
595 device->FlipHWSurface = DX5_FlipHWSurface; 598 device->FlipHWSurface = DX5_FlipHWSurface;
596 device->FreeHWSurface = DX5_FreeHWSurface; 599 device->FreeHWSurface = DX5_FreeHWSurface;
597 #ifdef IID_IDirectDrawGammaControl 600 #ifdef IID_IDirectDrawGammaControl
598 device->SetGammaRamp = DX5_SetGammaRamp; 601 device->SetGammaRamp = DX5_SetGammaRamp;
599 device->GetGammaRamp = DX5_GetGammaRamp; 602 device->GetGammaRamp = DX5_GetGammaRamp;
1908 surface->format->BytesPerPixel; 1911 surface->format->BytesPerPixel;
1909 } 1912 }
1910 surface->pixels = ddsd.lpSurface; 1913 surface->pixels = ddsd.lpSurface;
1911 return(0); 1914 return(0);
1912 } 1915 }
1916 static int DX5_LockHWSurfaceRect(_THIS, SDL_Surface *surface, SDL_Rect *rect, void **pixels, int *pitch)
1917 {
1918 HRESULT result;
1919 LPDIRECTDRAWSURFACE3 dd_surface;
1920 DDSURFACEDESC ddsd;
1921 RECT ddrect;
1922
1923 /* Calculate the lock rectangle */
1924 ddrect.top = rect->y;
1925 ddrect.bottom = rect->y+rect->h;
1926 ddrect.left = rect->x;
1927 ddrect.right = rect->x+rect->w;
1928
1929 /* Lock and load! */
1930 dd_surface = surface->hwdata->dd_writebuf;
1931 memset(&ddsd, 0, sizeof(ddsd));
1932 ddsd.dwSize = sizeof(ddsd);
1933 result = IDirectDrawSurface3_Lock(dd_surface, &ddrect, &ddsd,
1934 (DDLOCK_NOSYSLOCK|DDLOCK_WAIT), NULL);
1935 if ( result == DDERR_SURFACELOST ) {
1936 result = IDirectDrawSurface3_Restore(
1937 surface->hwdata->dd_surface);
1938 result = IDirectDrawSurface3_Lock(dd_surface, &ddrect, &ddsd,
1939 (DDLOCK_NOSYSLOCK|DDLOCK_WAIT), NULL);
1940 }
1941 if ( result != DD_OK ) {
1942 SetDDerror("DirectDrawSurface3::Lock", result);
1943 return(-1);
1944 }
1945 *pixels = ddsd.lpSurface;
1946 #if defined(NONAMELESSUNION)
1947 *pitch = ddsd.u1.lPitch;
1948 #else
1949 *pitch = (Uint16)ddsd.lPitch;
1950 #endif
1951 return(0);
1952 }
1913 1953
1914 static void DX5_UnlockHWSurface(_THIS, SDL_Surface *surface) 1954 static void DX5_UnlockHWSurface(_THIS, SDL_Surface *surface)
1915 { 1955 {
1916 IDirectDrawSurface3_Unlock(surface->hwdata->dd_writebuf, NULL); 1956 IDirectDrawSurface3_Unlock(surface->hwdata->dd_writebuf, NULL);
1917 surface->pixels = NULL; 1957 surface->pixels = NULL;