/* Lock a surface to directly access the pixels  */
int SDL_LockSurface(SDL_Surface *surface)
/* Lock a surface to directly access the pixels  */
int SDL_LockSurface(SDL_Surface *surface)
{
	if ( ! surface->locked ) {
		if ( surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT) ) {
			SDL_VideoDevice *video = current_video;
			SDL_VideoDevice *this  = current_video;
			if ( video->LockHWSurface(this, surface) < 0 ) {
				return(-1);
			}
		}
		if ( surface->flags & SDL_RLEACCEL ) {
			SDL_UnRLESurface(surface, 1);
			surface->flags |= SDL_RLEACCEL;
		}
		surface->pixels = (Uint8 *)surface->pixels + surface->offset;
	}
	++surface->locked;
	return(0);
}