Mercurial > sdl-ios-xcode
changeset 526:4314a501d7be
Fixed a crash blitting RLE surfaces to RLE surfaces
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 11 Oct 2002 07:56:36 +0000 |
parents | f55cdaec12b9 |
children | 5c74ac147358 |
files | src/video/SDL_RLEaccel.c src/video/SDL_blit.c src/video/SDL_surface.c |
diffstat | 3 files changed, 24 insertions(+), 64 deletions(-) [+] |
line wrap: on
line diff
--- a/src/video/SDL_RLEaccel.c Fri Oct 11 07:55:22 2002 +0000 +++ b/src/video/SDL_RLEaccel.c Fri Oct 11 07:56:36 2002 +0000 @@ -463,10 +463,8 @@ unsigned alpha; /* Lock the destination if necessary */ - if ( dst->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT) ) { - SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; - if ( video->LockHWSurface(this, dst) < 0 ) { + if ( SDL_MUSTLOCK(dst) ) { + if ( SDL_LockSurface(dst) < 0 ) { return(-1); } } @@ -474,7 +472,7 @@ /* Set up the source and destination pointers */ x = dstrect->x; y = dstrect->y; - dstbuf = (Uint8 *)dst->pixels + dst->offset + dstbuf = (Uint8 *)dst->pixels + y * dst->pitch + x * src->format->BytesPerPixel; srcbuf = (Uint8 *)src->map->sw_data->aux_data; @@ -553,10 +551,8 @@ done: /* Unlock the destination if necessary */ - if ( dst->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT) ) { - SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; - video->UnlockHWSurface(this, dst); + if ( SDL_MUSTLOCK(dst) ) { + SDL_UnlockSurface(dst); } return(0); } @@ -733,17 +729,15 @@ SDL_PixelFormat *df = dst->format; /* Lock the destination if necessary */ - if(dst->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT)) { - SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; - if(video->LockHWSurface(this, dst) < 0) { + if ( SDL_MUSTLOCK(dst) ) { + if ( SDL_LockSurface(dst) < 0 ) { return -1; } } x = dstrect->x; y = dstrect->y; - dstbuf = (Uint8 *)dst->pixels + dst->offset + dstbuf = (Uint8 *)dst->pixels + y * dst->pitch + x * df->BytesPerPixel; srcbuf = (Uint8 *)src->map->sw_data->aux_data + sizeof(RLEDestFormat); @@ -874,10 +868,8 @@ done: /* Unlock the destination if necessary */ - if(dst->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT)) { - SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; - video->UnlockHWSurface(this, dst); + if ( SDL_MUSTLOCK(dst) ) { + SDL_UnlockSurface(dst); } return 0; } @@ -1117,7 +1109,7 @@ int x, y; int h = surface->h, w = surface->w; SDL_PixelFormat *sf = surface->format; - Uint32 *src = (Uint32 *)((Uint8 *)surface->pixels + surface->offset); + Uint32 *src = (Uint32 *)surface->pixels; Uint8 *lastline = dst; /* end of last non-blank line */ /* opaque counts are 8 or 16 bits, depending on target depth */ @@ -1303,7 +1295,7 @@ } /* Set up the conversion */ - srcbuf = (Uint8 *)surface->pixels+surface->offset; + srcbuf = (Uint8 *)surface->pixels; curbuf = srcbuf; maxn = bpp == 4 ? 65535 : 255; skip = run = 0; @@ -1409,10 +1401,8 @@ } /* Lock the surface if it's in hardware */ - if ( surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT) ) { - SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; - if ( video->LockHWSurface(this, surface) < 0 ) { + if ( SDL_MUSTLOCK(surface) ) { + if ( SDL_LockSurface(surface) < 0 ) { return(-1); } } @@ -1429,10 +1419,8 @@ } /* Unlock the surface if it's in hardware */ - if ( surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT) ) { - SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; - video->UnlockHWSurface(this, surface); + if ( SDL_MUSTLOCK(surface) ) { + SDL_UnlockSurface(surface); } if(retcode < 0)
--- a/src/video/SDL_blit.c Fri Oct 11 07:55:22 2002 +0000 +++ b/src/video/SDL_blit.c Fri Oct 11 07:56:36 2002 +0000 @@ -50,10 +50,8 @@ /* Lock the destination if it's in hardware */ dst_locked = 0; - if ( dst->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT) ) { - SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; - if ( video->LockHWSurface(this, dst) < 0 ) { + if ( SDL_MUSTLOCK(dst) ) { + if ( SDL_LockSurface(dst) < 0 ) { okay = 0; } else { dst_locked = 1; @@ -61,35 +59,27 @@ } /* Lock the source if it's in hardware */ src_locked = 0; - if ( src->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT) ) { - SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; - if ( video->LockHWSurface(this, src) < 0 ) { + if ( SDL_MUSTLOCK(src) ) { + if ( SDL_LockSurface(src) < 0 ) { okay = 0; } else { src_locked = 1; } } - /* Unencode the destination if it's RLE encoded */ - if ( dst->flags & SDL_RLEACCEL ) { - SDL_UnRLESurface(dst, 1); - dst->flags |= SDL_RLEACCEL; /* save accel'd state */ - } - /* Set up source and destination buffer pointers, and BLIT! */ if ( okay && srcrect->w && srcrect->h ) { SDL_BlitInfo info; SDL_loblit RunBlit; /* Set up the blit information */ - info.s_pixels = (Uint8 *)src->pixels + src->offset + + info.s_pixels = (Uint8 *)src->pixels + (Uint16)srcrect->y*src->pitch + (Uint16)srcrect->x*src->format->BytesPerPixel; info.s_width = srcrect->w; info.s_height = srcrect->h; info.s_skip=src->pitch-info.s_width*src->format->BytesPerPixel; - info.d_pixels = (Uint8 *)dst->pixels + dst->offset + + info.d_pixels = (Uint8 *)dst->pixels + (Uint16)dstrect->y*dst->pitch + (Uint16)dstrect->x*dst->format->BytesPerPixel; info.d_width = dstrect->w; @@ -105,22 +95,12 @@ RunBlit(&info); } - /* Re-encode the destination if it's RLE encoded */ - if ( dst->flags & SDL_RLEACCEL ) { - dst->flags &= ~SDL_RLEACCEL; /* stop lying */ - SDL_RLESurface(dst); - } - /* We need to unlock the surfaces if they're locked */ if ( dst_locked ) { - SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; - video->UnlockHWSurface(this, dst); + SDL_UnlockSurface(dst); } if ( src_locked ) { - SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; - video->UnlockHWSurface(this, src); + SDL_UnlockSurface(src); } /* Blit is done! */ return(okay ? 0 : -1);
--- a/src/video/SDL_surface.c Fri Oct 11 07:55:22 2002 +0000 +++ b/src/video/SDL_surface.c Fri Oct 11 07:56:36 2002 +0000 @@ -692,10 +692,6 @@ /* * Lock a surface to directly access the pixels - * -- Do not call this from any blit function, as SDL_DrawCursor() may recurse - * Instead, use: - * if ( (surface->flags & SDL_HWSURFACE) == SDL_HWSURFACE ) - * video->LockHWSurface(video, surface); */ int SDL_LockSurface (SDL_Surface *surface) { @@ -724,10 +720,6 @@ } /* * Unlock a previously locked surface - * -- Do not call this from any blit function, as SDL_DrawCursor() may recurse - * Instead, use: - * if ( (surface->flags & SDL_HWSURFACE) == SDL_HWSURFACE ) - * video->UnlockHWSurface(video, surface); */ void SDL_UnlockSurface (SDL_Surface *surface) {