# HG changeset patch # User Sam Lantinga # Date 1149836772 0 # Node ID 8e754b82ceccffb6a4522f463a16e0712d12c613 # Parent 89f7510fe17ad5cddaa9a41bfde29bf24312ffa1 Updated SDL_Surface code for software-only access, fixed some build errors diff -r 89f7510fe17a -r 8e754b82cecc src/video/SDL_blit.h --- a/src/video/SDL_blit.h Fri Jun 09 06:42:42 2006 +0000 +++ b/src/video/SDL_blit.h Fri Jun 09 07:06:12 2006 +0000 @@ -59,9 +59,7 @@ SDL_Surface *dst; int identity; Uint8 *table; - SDL_blit hw_blit; SDL_blit sw_blit; - struct private_hwaccel *hw_data; struct private_swaccel *sw_data; /* the version count matches the destination; mismatch indicates diff -r 89f7510fe17a -r 8e754b82cecc src/video/SDL_cursor_c.h --- a/src/video/SDL_cursor_c.h Fri Jun 09 06:42:42 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* Useful variables and functions from SDL_cursor.c */ -#include "SDL_mouse.h" - -extern int SDL_CursorInit(void); -extern void SDL_CursorQuit(void); - -/* State definitions for the SDL cursor */ -#define CURSOR_VISIBLE 0x01 - -extern volatile int SDL_cursorstate; - -/* vi: set ts=4 sw=4 expandtab: */ diff -r 89f7510fe17a -r 8e754b82cecc src/video/SDL_gamma.c --- a/src/video/SDL_gamma.c Fri Jun 09 06:42:42 2006 +0000 +++ b/src/video/SDL_gamma.c Fri Jun 09 07:06:12 2006 +0000 @@ -109,7 +109,7 @@ CalculateGammaRamp(blue, ramp[2]); succeeded = SDL_SetGammaRamp(ramp[0], ramp[1], ramp[2]); } - if ((succeeded < 0) && _this->SetGamma) { + if ((succeeded < 0) && _this && _this->SetGamma) { SDL_ClearError(); succeeded = _this->SetGamma(_this, red, green, blue); } @@ -137,7 +137,7 @@ CalculateGammaFromRamp(blue, ramp[2]); } } - if ((succeeded < 0) && _this->GetGamma) { + if ((succeeded < 0) && _this && _this->GetGamma) { SDL_ClearError(); succeeded = _this->GetGamma(_this, red, green, blue); } @@ -150,13 +150,6 @@ { SDL_VideoDevice *_this = SDL_GetVideoDevice(); int succeeded; - SDL_Surface *screen = SDL_PublicSurface; - - /* Verify the screen parameter */ - if (!screen) { - SDL_SetError("No video mode has been set"); - return -1; - } /* Lazily allocate the gamma tables */ if (!SDL_CurrentWindow.gamma) { @@ -179,7 +172,7 @@ /* Try to set the gamma ramp in the driver */ succeeded = -1; - if (_this->SetGammaRamp) { + if (_this && _this->SetGammaRamp) { succeeded = _this->SetGammaRamp(_this, SDL_CurrentWindow.gamma); } else { SDL_SetError("Gamma ramp manipulation not supported"); @@ -200,7 +193,7 @@ SDL_OutOfMemory(); return -1; } - if (_this->GetGammaRamp) { + if (_this && _this->GetGammaRamp) { /* Get the real hardware gamma */ _this->GetGammaRamp(_this, SDL_CurrentWindow.gamma); } else { diff -r 89f7510fe17a -r 8e754b82cecc src/video/SDL_surface.c --- a/src/video/SDL_surface.c Fri Jun 09 06:42:42 2006 +0000 +++ b/src/video/SDL_surface.c Fri Jun 09 07:06:12 2006 +0000 @@ -22,8 +22,8 @@ #include "SDL_config.h" #include "SDL_video.h" +#include "SDL_compat.h" #include "SDL_sysvideo.h" -#include "SDL_cursor_c.h" #include "SDL_blit.h" #include "SDL_RLEaccel_c.h" #include "SDL_pixels_c.h" @@ -70,7 +70,6 @@ surface->h = height; surface->pitch = SDL_CalculatePitch(surface); surface->pixels = NULL; - surface->hwdata = NULL; surface->locked = 0; surface->map = NULL; SDL_SetClipRect(surface, NULL); @@ -114,8 +113,8 @@ { SDL_Surface *surface; - surface = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, depth, - Rmask, Gmask, Bmask, Amask); + surface = + SDL_CreateRGBSurface(0, 0, 0, depth, Rmask, Gmask, Bmask, Amask); if (surface != NULL) { surface->flags |= SDL_PREALLOC; surface->pixels = pixels; @@ -146,12 +145,12 @@ return NULL; } - surface = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, bpp, - Rmask, Gmask, Bmask, Amask); + surface = SDL_CreateRGBSurface(0, 0, 0, bpp, Rmask, Gmask, Bmask, Amask); if (surface != NULL) { surface->flags |= (SDL_HWSURFACE | SDL_PREALLOC); - surface->w = width; - surface->h = height; + surface->w = w; + surface->h = h; + surface->lock_data = (void *) textureID; SDL_SetClipRect(surface, NULL); } return surface; @@ -221,16 +220,8 @@ } if (flag) { - SDL_VideoDevice *_this = SDL_GetVideoDevice(); - surface->flags |= SDL_SRCCOLORKEY; surface->format->colorkey = key; - if ((surface->flags & SDL_HWACCEL) == SDL_HWACCEL) { - if ((_this->SetHWColorKey == NULL) || - (_this->SetHWColorKey(_this, surface, key) < 0)) { - surface->flags &= ~SDL_HWACCEL; - } - } if (flag & SDL_RLEACCELOK) { surface->flags |= SDL_RLEACCELOK; } else { @@ -272,16 +263,8 @@ SDL_UnRLESurface(surface, 1); if (flag) { - SDL_VideoDevice *_this = SDL_GetVideoDevice(); - surface->flags |= SDL_SRCALPHA; surface->format->alpha = value; - if ((surface->flags & SDL_HWACCEL) == SDL_HWACCEL) { - if ((_this->SetHWAlpha == NULL) || - (_this->SetHWAlpha(_this, surface, value) < 0)) { - surface->flags &= ~SDL_HWACCEL; - } - } if (flag & SDL_RLEACCELOK) { surface->flags |= SDL_RLEACCELOK; } else { @@ -297,10 +280,10 @@ * if just the alpha value was changed. (If either is 255, we still * need to invalidate.) */ - if ((surface->flags & SDL_HWACCEL) == SDL_HWACCEL - || oldflags != surface->flags - || (((oldalpha + 1) ^ (value + 1)) & 0x100)) + if (oldflags != surface->flags + || (((oldalpha + 1) ^ (value + 1)) & 0x100)) { SDL_InvalidateMap(surface->map); + } return (0); } @@ -438,8 +421,6 @@ SDL_LowerBlit(SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect) { - SDL_blit do_blit; - /* Check to make sure the blit mapping is valid */ if ((src->map->dst != dst) || (src->map->dst->format_version != src->map->format_version)) { @@ -447,14 +428,7 @@ return (-1); } } - - /* Figure out which blitter to use */ - if ((src->flags & SDL_HWACCEL) == SDL_HWACCEL) { - do_blit = src->map->hw_blit; - } else { - do_blit = src->map->sw_blit; - } - return (do_blit(src, srcrect, dst, dstrect)); + return (src->map->sw_blit(src, srcrect, dst, dstrect)); } @@ -603,12 +577,6 @@ dstrect = &dst->clip_rect; } - /* Check for hardware acceleration */ - if (((dst->flags & SDL_HWSURFACE) == SDL_HWSURFACE) && - _this->info.blit_fill) { - return (_this->FillHWRect(_this, dst, dstrect, color)); - } - /* Perform software fill */ if (SDL_LockSurface(dst) != 0) { return (-1); @@ -632,7 +600,7 @@ * causes an alignment exception if the destination is * uncachable, so only use it on software surfaces */ - if ((dst->flags & SDL_HWSURFACE) == SDL_HWSURFACE) { + if (dst->flags & SDL_HWSURFACE) { if (dstrect->w >= 8) { /* * 64-bit stores are probably most @@ -752,8 +720,9 @@ if (!surface->locked) { /* Perform the lock */ if (surface->flags & SDL_HWSURFACE) { - SDL_VideoDevice *_this = SDL_GetVideoDevice(); - if (_this->LockHWSurface(_this, surface) < 0) { + if (SDL_LockTexture + ((SDL_TextureID) surface->lock_data, NULL, 1, + &surface->pixels, &surface->pitch) < 0) { return (-1); } } @@ -761,8 +730,6 @@ SDL_UnRLESurface(surface, 1); surface->flags |= SDL_RLEACCEL; /* save accel'd state */ } - /* This needs to be done here in case pixels changes value */ - surface->pixels = (Uint8 *) surface->pixels + surface->offset; } /* Increment the surface lock count, for recursive locks */ @@ -783,13 +750,9 @@ return; } - /* Perform the unlock */ - surface->pixels = (Uint8 *) surface->pixels - surface->offset; - /* Unlock hardware or accelerated surfaces */ if (surface->flags & SDL_HWSURFACE) { - SDL_VideoDevice *_this = SDL_GetVideoDevice(); - _this->UnlockHWSurface(_this, surface); + SDL_UnlockTexture((SDL_TextureID) surface->lock_data); } else { /* Update RLE encoded surface with new data */ if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) { @@ -827,14 +790,6 @@ } } - /* Only create hw surfaces with alpha channel if hw alpha blits - are supported */ - if (format->Amask != 0 && (flags & SDL_HWSURFACE)) { - const SDL_VideoInfo *vi = SDL_GetVideoInfo(); - if (!vi || !vi->blit_hw_A) - flags &= ~SDL_HWSURFACE; - } - /* Create a new surface with the desired format */ convert = SDL_CreateRGBSurface(flags, surface->w, surface->h, @@ -927,7 +882,7 @@ while (surface->locked > 0) { SDL_UnlockSurface(surface); } - if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) { + if (surface->flags & SDL_RLEACCEL) { SDL_UnRLESurface(surface, 0); } if (surface->format) { @@ -938,10 +893,11 @@ SDL_FreeBlitMap(surface->map); surface->map = NULL; } - if (surface->hwdata) { - SDL_VideoDevice *_this = SDL_GetVideoDevice(); - _this->FreeHWSurface(_this, surface); - } + /* Should we destroy the texture too? + if (surface->flags & SDL_HWSURFACE) { + SDL_DestroyTexture((SDL_TextureID)surface->lock_data); + } + */ if (surface->pixels && ((surface->flags & SDL_PREALLOC) != SDL_PREALLOC)) { SDL_free(surface->pixels); } diff -r 89f7510fe17a -r 8e754b82cecc src/video/SDL_video.c --- a/src/video/SDL_video.c Fri Jun 09 06:42:42 2006 +0000 +++ b/src/video/SDL_video.c Fri Jun 09 07:06:12 2006 +0000 @@ -27,7 +27,6 @@ #include "SDL_sysvideo.h" #include "SDL_blit.h" #include "SDL_pixels_c.h" -#include "SDL_cursor_c.h" #include "../events/SDL_sysevents.h" #include "../events/SDL_events_c.h" @@ -280,7 +279,6 @@ SDL_VideoQuit(); return -1; } - SDL_CursorInit(flags & SDL_INIT_EVENTTHREAD); /* We're ready to go! */ return 0; @@ -1557,7 +1555,6 @@ SDL_free(display->windows); display->windows = NULL; } - SDL_free(display->info.vfmt); } _this->VideoQuit(_this); if (_this->displays) { diff -r 89f7510fe17a -r 8e754b82cecc src/video/SDL_yuv_sw.c --- a/src/video/SDL_yuv_sw.c Fri Jun 09 06:42:42 2006 +0000 +++ b/src/video/SDL_yuv_sw.c Fri Jun 09 07:06:12 2006 +0000 @@ -1192,7 +1192,7 @@ if (stretch) { if (!swdata->stretch) { display = swdata->display; - swdata->stretch = SDL_CreateRGBSurface(SDL_SWSURFACE, + swdata->stretch = SDL_CreateRGBSurface(0, overlay->w, overlay->h, display->format->