From 4015a88c506323ed681767302b352ad5c2cea9b3 Mon Sep 17 00:00:00 2001 From: Tim Felgentreff Date: Fri, 17 Apr 2020 09:59:36 +0200 Subject: [PATCH] kill dead code --- .travis.yml | 3 +- CMakeLists.txt | 7 +- src/guichan/include/guichan/gsdl.h | 3 - src/guichan/sdl/sdlgraphics.cpp | 7 +- src/guichan/sdl/sdlimageloader.cpp | 254 ----------------------------- src/guichan/sdl/sdlinput.cpp | 8 - src/include/video.h | 1 - src/map/map_fog.cpp | 5 - src/map/minimap.cpp | 19 +-- src/stratagus/iolib.cpp | 2 +- src/stratagus/player.cpp | 5 +- src/stratagus/stratagus.cpp | 3 +- src/ui/interface.cpp | 4 - src/ui/ui.cpp | 6 - src/video/cursor.cpp | 5 - src/video/font.cpp | 2 - src/video/graphic.cpp | 98 ----------- src/video/movie.cpp | 32 ---- src/video/sdl.cpp | 2 +- src/video/video.cpp | 1 + 20 files changed, 14 insertions(+), 453 deletions(-) delete mode 100644 src/guichan/sdl/sdlimageloader.cpp diff --git a/.travis.yml b/.travis.yml index 9a58ebc2b..50ab6dec8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,11 +7,12 @@ addons: packages: - cmake - libsdl2-dev + - libsdl2-mixer-dev + - libsdl2-image-dev - liblua5.1-0-dev - libtolua++5.1-dev - libtolua-dev - zlib1g-dev - - libpng12-dev before_script: - "if [ $TRAVIS_OS_NAME == osx ]; then brew install lua51 sdl; \ git clone https://github.com/LuaDist/toluapp.git; \ diff --git a/CMakeLists.txt b/CMakeLists.txt index 120fadbe0..f35701d23 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -159,7 +159,6 @@ set(guichan_SRCS src/guichan/rectangle.cpp src/guichan/sdl/gsdl.cpp src/guichan/sdl/sdlgraphics.cpp -# src/guichan/sdl/sdlimageloader.cpp src/guichan/sdl/sdlinput.cpp src/guichan/widget.cpp src/guichan/widgets/button.cpp @@ -333,7 +332,7 @@ set(video_SRCS src/video/font.cpp src/video/graphic.cpp src/video/linedraw.cpp - src/video/mng.cpp + src/video/mng.cpp src/video/movie.cpp src/video/png.cpp src/video/sdl.cpp @@ -684,10 +683,6 @@ option(ENABLE_STRIP "Strip all symbols from executables" OFF) option(ENABLE_USEGAMEDIR "Place all files created by Stratagus(logs, savegames) in game directory(old behavior), otherwise place everything in user directory(new behavior)" OFF) option(ENABLE_MULTIBUILD "Compile Stratagus on all CPU cores simltaneously in MSVC" ON) -if(NOT WITH_RENDERER) - set(WITH_RENDERER "NativeSDL") -endif() - # Install paths set(BINDIR "bin" CACHE PATH "Where to install user binaries") set(SBINDIR "sbin" CACHE PATH "Where to install system binaries") diff --git a/src/guichan/include/guichan/gsdl.h b/src/guichan/include/guichan/gsdl.h index 788dd47c9..14bead611 100644 --- a/src/guichan/include/guichan/gsdl.h +++ b/src/guichan/include/guichan/gsdl.h @@ -56,9 +56,6 @@ #define GCN_SDL_HPP #include -#ifdef USE_SDL_IMAGE -#include -#endif #include #include "platform.h" diff --git a/src/guichan/sdl/sdlgraphics.cpp b/src/guichan/sdl/sdlgraphics.cpp index 91f87a65e..0d594622c 100644 --- a/src/guichan/sdl/sdlgraphics.cpp +++ b/src/guichan/sdl/sdlgraphics.cpp @@ -97,6 +97,7 @@ namespace gcn void SDLGraphics::setTarget(SDL_Surface** targetPtr) { mTarget = targetPtr; + Assert(SDL_MUSTLOCK(*mTarget) == 0); } bool SDLGraphics::pushClipArea(Rectangle area) { @@ -149,9 +150,7 @@ namespace gcn SDL_Surface* srcImage = (SDL_Surface*)image->_getData(); - //SDL_LockSurface(*mTarget); SDL_BlitSurface(srcImage, &src, *mTarget, &dst); - //SDL_UnlockSurface(*mTarget); } void SDLGraphics::fillRectangle(const Rectangle& rectangle) @@ -174,9 +173,6 @@ namespace gcn int x2 = std::min(area.x + area.width, top.x + top.width); int y2 = std::min(area.y + area.height, top.y + top.height); int x, y; - //Video.FillTransRectangle(SDL_MapRGB((*mTarget)->format, mColor.r, mColor.g, mColor.b), - // x1, y1, x2 - x1, y2 - y1, mColor.a); - //SDL_LockSurface(*mTarget); for (y = y1; y < y2; y++) { for (x = x1; x < x2; x++) @@ -184,7 +180,6 @@ namespace gcn SDLputPixelAlpha(*mTarget, x, y, mColor); } } - //SDL_UnlockSurface(*mTarget); } else { diff --git a/src/guichan/sdl/sdlimageloader.cpp b/src/guichan/sdl/sdlimageloader.cpp deleted file mode 100644 index 4f1c47a0c..000000000 --- a/src/guichan/sdl/sdlimageloader.cpp +++ /dev/null @@ -1,254 +0,0 @@ -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004, 2005 darkbits Js_./ - * Per Larsson a.k.a finalman _RqZ{a<^_aa - * Olof Naessén a.k.a jansem/yakslem _asww7!uY`> )\a// - * _Qhm`] _f "'c 1!5m - * Visit: http://guichan.darkbits.org )Qk

ws?a-?' ._/L #' - * binary forms, with or without )4d[#7r, . ' )d`)[ - * modification, are permitted provided _Q-5'5W..j/?' -?!\)cam' - * that the following conditions are met: j<. a J@\ - * this list of conditions and the j(]1u - -#include "guichan/sdl/sdlimageloader.h" -#include "guichan/exception.h" -#include "guichan/sdl/sdlpixel.h" - -namespace gcn -{ - - SDLImageLoader::SDLImageLoader() - { - mCurrentImage = NULL; - } - - void SDLImageLoader::prepare(const std::string& filename) - { - if (mCurrentImage != NULL) - { - throw GCN_EXCEPTION("Function called before finalizing or discarding last loaded image."); - } - - SDL_Surface* tmp = IMG_Load(filename.c_str()); - - if (tmp == NULL) - { - throw GCN_EXCEPTION(std::string("Unable to load image file: ")+filename); - } - - Uint32 rmask, gmask, bmask, amask; -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - rmask = 0xff000000; - gmask = 0x00ff0000; - bmask = 0x0000ff00; - amask = 0x000000ff; -#else - rmask = 0x000000ff; - gmask = 0x0000ff00; - bmask = 0x00ff0000; - amask = 0xff000000; -#endif - - mCurrentImage = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, 32, - rmask, gmask, bmask, amask); - - if (mCurrentImage == NULL) - { - throw GCN_EXCEPTION(std::string("Not enough memory to load: ")+filename); - } - - SDL_Surface* tmp2 = SDL_ConvertSurface(tmp, mCurrentImage->format, SDL_SWSURFACE); - SDL_FreeSurface(tmp); - SDL_FreeSurface(mCurrentImage); - - mCurrentImage = tmp2; - } - - void* SDLImageLoader::getRawData() - { - return mCurrentImage->pixels; - } - - void* SDLImageLoader::finalize() - { - if (mCurrentImage == NULL) - { - throw GCN_EXCEPTION("No image prepared."); - } - - int i; - bool hasPink = false; - bool hasAlpha = false; - - for (i = 0; i < mCurrentImage->w * mCurrentImage->h; ++i) - { - if (((unsigned int*)mCurrentImage->pixels)[i] == SDL_MapRGB(mCurrentImage->format,255,0,255)) - { - hasPink = true; - break; - } - } - - for (i = 0; i < mCurrentImage->w * mCurrentImage->h; ++i) - { - Uint8 r, g, b, a; - - SDL_GetRGBA(((unsigned int*)mCurrentImage->pixels)[i], mCurrentImage->format, - &r, &g, &b, &a); - - if (a != 255) - { - hasAlpha = true; - break; - } - } - - // Don't convert 32bpp images with alpha, it will destroy the - // alpha channel. - SDL_Surface *temp; - if (hasAlpha) - { - temp = mCurrentImage; - mCurrentImage = NULL; - } - else - { - temp = SDL_DisplayFormat(mCurrentImage); - SDL_FreeSurface(mCurrentImage); - mCurrentImage = NULL; - } - - if (hasPink) - { - SDL_SetColorKey(temp, SDL_TRUE, - SDL_MapRGB(temp->format,255,0,255)); - } - if (hasAlpha) - { - SDL_SetSurfaceAlphaMod(temp, 255); - } - - return temp; - } - - void SDLImageLoader::discard() - { - if (mCurrentImage == NULL) - { - throw GCN_EXCEPTION("No image prepared."); - } - - SDL_FreeSurface(mCurrentImage); - - mCurrentImage = NULL; - } - - void SDLImageLoader::free(Image* image) - { - if (image->_getData() == NULL) - { - throw GCN_EXCEPTION("Image data points to null."); - } - - SDL_FreeSurface((SDL_Surface*)image->_getData()); - } - - int SDLImageLoader::getWidth() const - { - if (mCurrentImage == NULL) - { - throw GCN_EXCEPTION("No image prepared."); - } - - return mCurrentImage->w; - } - - int SDLImageLoader::getHeight() const - { - if (mCurrentImage == NULL) - { - throw GCN_EXCEPTION("No image prepared."); - } - - return mCurrentImage->h; - } - - Color SDLImageLoader::getPixel(int x, int y) - { - if (mCurrentImage == NULL) - { - throw GCN_EXCEPTION("No image prepared."); - } - - if (x < 0 || y < 0 || x >= mCurrentImage->w || y >= mCurrentImage->h) - { - throw GCN_EXCEPTION("x and y out of image bound."); - } - - return SDLgetPixel(mCurrentImage, x, y); - } - - void SDLImageLoader::putPixel(int x, int y, const Color& color) - { - if (mCurrentImage == NULL) - { - throw GCN_EXCEPTION("No image prepared."); - } - - if (x < 0 || y < 0 || x >= mCurrentImage->w || y >= mCurrentImage->h) - { - throw GCN_EXCEPTION("x and y out of image bound."); - } - - SDLputPixel(mCurrentImage, x, y, color); - } -} -#endif diff --git a/src/guichan/sdl/sdlinput.cpp b/src/guichan/sdl/sdlinput.cpp index 9bd86be51..5aa30543c 100644 --- a/src/guichan/sdl/sdlinput.cpp +++ b/src/guichan/sdl/sdlinput.cpp @@ -353,14 +353,6 @@ namespace gcn case SDLK_SCROLLLOCK: value = Key::K_SCROLL_LOCK; break; - #if 0 - case SDLK_RMETA: - value = Key::K_RIGHT_META; - break; - case SDLK_LMETA: - value = Key::K_LEFT_META; - break; - #endif case SDLK_LGUI: value = Key::K_LEFT_SUPER; break; diff --git a/src/include/video.h b/src/include/video.h index de0ff409c..61e09e658 100644 --- a/src/include/video.h +++ b/src/include/video.h @@ -90,7 +90,6 @@ public: void Load(bool grayscale = false); void Flip(); - void UseDisplayFormat(); void Resize(int w, int h); void SetOriginalSize(); bool TransparentPixel(int x, int y); diff --git a/src/map/map_fog.cpp b/src/map/map_fog.cpp index 7768dcf3c..f591cdbb9 100644 --- a/src/map/map_fog.cpp +++ b/src/map/map_fog.cpp @@ -443,9 +443,7 @@ void VideoDrawOnlyFog(int x, int y) drect.x = x; drect.y = y; - //SDL_LockSurface(TheScreen); SDL_BlitSurface(OnlyFogSurface, &srect, TheScreen, &drect); - //SDL_UnlockSurface(TheScreen); } /*---------------------------------------------------------------------------- @@ -672,8 +670,6 @@ void CMap::InitFogOfWar() Uint32 color = Video.MapRGBA(OnlyFogSurface->format, r, g, b, FogOfWarOpacity); SDL_FillRect(OnlyFogSurface, NULL, color); - //SDL_SetSurfaceAlphaMod(OnlyFogSurface, FogOfWarOpacity); - //VideoPaletteListRemove(OnlyFogSurface); // // Generate Alpha Fog surface. @@ -720,7 +716,6 @@ void CMap::InitFogOfWar() AlphaFogG->GraphicHeight = s->h; AlphaFogG->NumFrames = 16;//1; AlphaFogG->GenFramesMap(); - AlphaFogG->UseDisplayFormat(); VisibleTable.clear(); VisibleTable.resize(Info.MapWidth * Info.MapHeight); diff --git a/src/map/minimap.cpp b/src/map/minimap.cpp index 79305f33e..ece640a8a 100644 --- a/src/map/minimap.cpp +++ b/src/map/minimap.cpp @@ -180,8 +180,8 @@ void CMinimap::UpdateTerrain() const int tilepitch = Map.TileGraphic->Surface->w / PixelTileSize.x; - //SDL_LockSurface(MinimapTerrainSurface); - //SDL_LockSurface(Map.TileGraphic->Surface); + Assert(SDL_MUSTLOCK(MinimapTerrainSurface) == 0); + Assert(SDL_MUSTLOCK(Map.TileGraphic->Surface) == 0); // // Pixel 7,6 7,14, 15,6 15,14 are taken for the minimap picture. @@ -208,8 +208,6 @@ void CMinimap::UpdateTerrain() } } - //SDL_UnlockSurface(MinimapTerrainSurface); - //SDL_UnlockSurface(Map.TileGraphic->Surface); } /** @@ -238,8 +236,6 @@ void CMinimap::UpdateXY(const Vec2i &pos) // // Pixel 7,6 7,14, 15,6 15,14 are taken for the minimap picture. // - //SDL_LockSurface(MinimapTerrainSurface); - //SDL_LockSurface(Map.TileGraphic->Surface); const int ty = pos.y * Map.Info.MapWidth; const int tx = pos.x; @@ -285,8 +281,6 @@ void CMinimap::UpdateXY(const Vec2i &pos) } } } - //SDL_UnlockSurface(MinimapTerrainSurface); - //SDL_UnlockSurface(Map.TileGraphic->Surface); } /** @@ -377,8 +371,8 @@ void CMinimap::Update() SDL_BlitSurface(MinimapTerrainSurface, NULL, MinimapSurface, NULL); } - //SDL_LockSurface(MinimapSurface); - //SDL_LockSurface(MinimapTerrainSurface); + Assert(SDL_MUSTLOCK(MinimapSurface) == 0); + Assert(SDL_MUSTLOCK(MinimapTerrainSurface) == 0); for (int my = 0; my < H; ++my) { for (int mx = 0; mx < W; ++mx) { @@ -402,8 +396,6 @@ void CMinimap::Update() } } - //SDL_UnlockSurface(MinimapTerrainSurface); - // // Draw units on map // @@ -413,7 +405,6 @@ void CMinimap::Update() DrawUnitOn(unit, red_phase); } } - //SDL_UnlockSurface(MinimapSurface); } /** @@ -441,9 +432,7 @@ static void DrawEvents() void CMinimap::Draw() const { SDL_Rect drect = {Sint16(X), Sint16(Y), 0, 0}; - //SDL_LockSurface(TheScreen); SDL_BlitSurface(MinimapSurface, NULL, TheScreen, &drect); - //SDL_UnlockSurface(TheScreen); DrawEvents(); } diff --git a/src/stratagus/iolib.cpp b/src/stratagus/iolib.cpp index e053a6dfc..39867b867 100644 --- a/src/stratagus/iolib.cpp +++ b/src/stratagus/iolib.cpp @@ -553,7 +553,7 @@ static bool FindFileWithExtension(char(&file)[PATH_MAX]) #ifdef USE_ZLIB // gzip or bzip2 in global shared directory sprintf(buf, "%s.gz", file); if (!access(buf, R_OK)) { - strcpy_s(file, PATH_MAX + 4, buf); + strcpy_s(file, PATH_MAX, buf); return true; } #endif diff --git a/src/stratagus/player.cpp b/src/stratagus/player.cpp index 6c6bbbb88..5719d8257 100644 --- a/src/stratagus/player.cpp +++ b/src/stratagus/player.cpp @@ -1205,15 +1205,12 @@ void GraphicPlayerPixels(CPlayer &player, const CGraphic &sprite) { Assert(PlayerColorIndexCount); - //SDL_LockSurface(sprite.Surface); + Assert(SDL_MUSTLOCK(sprite.Surface) == 0); std::vector sdlColors(player.UnitColors.Colors.begin(), player.UnitColors.Colors.end()); SDL_SetPaletteColors(sprite.Surface->format->palette, &sdlColors[0], PlayerColorIndexStart, PlayerColorIndexCount); if (sprite.SurfaceFlip) { - //SDL_LockSurface(sprite.SurfaceFlip); SDL_SetPaletteColors(sprite.SurfaceFlip->format->palette, &sdlColors[0], PlayerColorIndexStart, PlayerColorIndexCount); - //SDL_UnlockSurface(sprite.SurfaceFlip); } - //SDL_UnlockSurface(sprite.Surface); } /** diff --git a/src/stratagus/stratagus.cpp b/src/stratagus/stratagus.cpp index 2747ba6d9..7e6ecf7a7 100644 --- a/src/stratagus/stratagus.cpp +++ b/src/stratagus/stratagus.cpp @@ -685,7 +685,8 @@ int stratagusMain(int argc, char **argv) // Initialise AI module InitAiModule(); - // Setup sound card + // Setup sound card, must be done before loading sounds, so that + // SDL_mixer can auto-convert to the target format if (!InitSound()) { InitMusic(); } diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index a4706b907..be4d60e5a 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -978,8 +978,6 @@ int HandleKeyModifiersDown(unsigned key, unsigned) return 1; case SDLK_LALT: case SDLK_RALT: - //case SDLK_LMETA: - //case SDLK_RMETA: KeyModifiers |= ModifierAlt; // maxy: disabled if (InterfaceState == IfaceStateNormal) { @@ -1024,8 +1022,6 @@ int HandleKeyModifiersUp(unsigned key, unsigned) return 1; case SDLK_LALT: case SDLK_RALT: - //case SDLK_LMETA: - //case SDLK_RMETA: KeyModifiers &= ~ModifierAlt; // maxy: disabled if (InterfaceState == IfaceStateNormal) { diff --git a/src/ui/ui.cpp b/src/ui/ui.cpp index 892f6604f..2076e68f9 100644 --- a/src/ui/ui.cpp +++ b/src/ui/ui.cpp @@ -247,30 +247,24 @@ void CUserInterface::Load() for (int i = 0; i <= FreeWorkersCount; ++i) { if (Resources[i].G) { Resources[i].G->Load(); - Resources[i].G->UseDisplayFormat(); } } if (InfoPanel.G) { InfoPanel.G->Load(); - InfoPanel.G->UseDisplayFormat(); } if (ButtonPanel.G) { ButtonPanel.G->Load(); - ButtonPanel.G->UseDisplayFormat(); } if (PieMenu.G) { PieMenu.G->Load(); - PieMenu.G->UseDisplayFormat(); } if (Preference.IconFrameG) { Preference.IconFrameG->Load(); - Preference.IconFrameG->UseDisplayFormat(); } if (Preference.PressedIconFrameG) { Preference.PressedIconFrameG->Load(); - Preference.PressedIconFrameG->UseDisplayFormat(); } // Resolve cursors diff --git a/src/video/cursor.cpp b/src/video/cursor.cpp index 54f0552c9..8cb0101aa 100644 --- a/src/video/cursor.cpp +++ b/src/video/cursor.cpp @@ -104,7 +104,6 @@ void LoadCursors(const std::string &race) if (cursor.G && !cursor.G->IsLoaded()) { ShowLoadProgress(_("Cursor %s"), cursor.G->File.c_str()); cursor.G->Load(); - cursor.G->UseDisplayFormat(); } } } @@ -281,9 +280,7 @@ void DrawCursor() } SDL_Rect srcRect = { Sint16(pos.x), Sint16(pos.y), Uint16(GameCursor->G->getWidth()), Uint16(GameCursor->G->getHeight())}; - //SDL_LockSurface(TheScreen); SDL_BlitSurface(TheScreen, &srcRect, HiddenSurface, NULL); - //SDL_UnlockSurface(TheScreen); } // Last, Normal cursor. @@ -301,9 +298,7 @@ void HideCursor() if (!GameRunning && !Editor.Running && GameCursor) { const PixelPos pos = CursorScreenPos - GameCursor->HotPos; SDL_Rect dstRect = {Sint16(pos.x), Sint16(pos.y), 0, 0 }; - //SDL_LockSurface(TheScreen); SDL_BlitSurface(HiddenSurface, NULL, TheScreen, &dstRect); - //SDL_UnlockSurface(TheScreen); } } diff --git a/src/video/font.cpp b/src/video/font.cpp index 2bb3eb7a5..cb28a969d 100644 --- a/src/video/font.cpp +++ b/src/video/font.cpp @@ -142,9 +142,7 @@ static void VideoDrawChar(const CGraphic &g, SDL_Rect drect = {Sint16(x), Sint16(y), 0, 0}; std::vector sdlColors(fc.Colors, fc.Colors + MaxFontColors); SDL_SetPaletteColors(g.Surface->format->palette, &sdlColors[0], 0, MaxFontColors); - //SDL_LockSurface(TheScreen); SDL_BlitSurface(g.Surface, &srect, TheScreen, &drect); - //SDL_UnlockSurface(TheScreen); } /** diff --git a/src/video/graphic.cpp b/src/video/graphic.cpp index a83bbc345..c869ed4f8 100644 --- a/src/video/graphic.cpp +++ b/src/video/graphic.cpp @@ -114,12 +114,9 @@ void CGraphic::DrawSubClip(int gx, int gy, int w, int h, int x, int y) const gx += x - oldx; gy += y - oldy; - //DrawSub(gx + x - oldx, gy + y - oldy, w, h, x, y); SDL_Rect srect = {Sint16(gx), Sint16(gy), Uint16(w), Uint16(h)}; SDL_Rect drect = {Sint16(x), Sint16(y), 0, 0}; - //SDL_LockSurface(TheScreen); SDL_BlitSurface(Surface, &srect, TheScreen, &drect); - //SDL_UnlockSurface(TheScreen); } /** @@ -228,9 +225,7 @@ void CGraphic::DrawFrameX(unsigned frame, int x, int y) const SDL_Rect srect = {frameFlip_map[frame].x, frameFlip_map[frame].y, Uint16(Width), Uint16(Height)}; SDL_Rect drect = {Sint16(x), Sint16(y), 0, 0}; - //SDL_LockSurface(TheScreen); SDL_BlitSurface(SurfaceFlip, &srect, TheScreen, &drect); - //SDL_UnlockSurface(TheScreen); } /** @@ -253,10 +248,8 @@ void CGraphic::DrawFrameClipX(unsigned frame, int x, int y) const SDL_Rect drect = {Sint16(x), Sint16(y), 0, 0}; int ret; - //SDL_LockSurface(TheScreen); //SDL_SetSurfaceAlphaMod(SurfaceFlip, 0xFF); ret = SDL_BlitSurface(SurfaceFlip, &srect, TheScreen, &drect); - //SDL_UnlockSurface(TheScreen); } void CGraphic::DrawFrameTransX(unsigned frame, int x, int y, int alpha) const @@ -267,9 +260,7 @@ void CGraphic::DrawFrameTransX(unsigned frame, int x, int y, int alpha) const SDL_GetSurfaceAlphaMod(SurfaceFlip, &oldalpha); SDL_SetSurfaceAlphaMod(SurfaceFlip, alpha); - //SDL_LockSurface(TheScreen); SDL_BlitSurface(SurfaceFlip, &srect, TheScreen, &drect); - //SDL_UnlockSurface(TheScreen); SDL_SetSurfaceAlphaMod(SurfaceFlip, oldalpha); } @@ -288,9 +279,7 @@ void CGraphic::DrawFrameClipTransX(unsigned frame, int x, int y, int alpha) cons SDL_GetSurfaceAlphaMod(SurfaceFlip, &oldalpha); SDL_SetSurfaceAlphaMod(SurfaceFlip, alpha); - //SDL_LockSurface(TheScreen); SDL_BlitSurface(SurfaceFlip, &srect, TheScreen, &drect); - //SDL_UnlockSurface(TheScreen); SDL_SetSurfaceAlphaMod(SurfaceFlip, oldalpha); } @@ -688,15 +677,12 @@ void CGraphic::Flip() if (!SDL_GetColorKey(Surface, &ckey)) { SDL_SetColorKey(SurfaceFlip, SDL_TRUE, ckey); } - //SDL_SetSurfaceAlphaMod(SurfaceFlip, 0xFF); SDL_SetSurfaceBlendMode(SurfaceFlip, SDL_BLENDMODE_NONE); if (SurfaceFlip->format->BytesPerPixel == 1) { - //SDL_SetPaletteColors(SurfaceFlip->format->palette, Surface->format->palette->colors, 0, Surface->format->palette->ncolors); VideoPaletteListAdd(SurfaceFlip); } SDL_LockSurface(Surface); SDL_LockSurface(s); - //fprintf(stderr, "flipping sprite %s (%dbpp)\n", File.c_str(), 8*s->format->BytesPerPixel); switch (s->format->BytesPerPixel) { case 1: for (int i = 0; i < s->h; ++i) { @@ -721,59 +707,6 @@ void CGraphic::Flip() &((char *)Surface->pixels)[(s->w - j - 1) * 4 + i * Surface->pitch], 4); } } -#if 0 - unsigned int p0 = s->pitch; - unsigned int p1 = Surface->pitch; - const int width = s->w; - int j = 0; - for (int i = 0; i < s->h; ++i) { -#ifdef _MSC_VER - for (j = 0; j < width; ++j) { - *(Uint32 *)&((char *)s->pixels)[j * 4 + p0] = - *(Uint32 *) & ((char *)Surface->pixels)[(width - j - 1) * 4 + p1]; - } -#else - int n = (width + 7) / 8; - switch (width & 7) { - case 0: do { - *(Uint32 *)&((char *)s->pixels)[j * 4 + p0] = - *(Uint32 *) & ((char *)Surface->pixels)[(width - j - 1) * 4 + p1]; - j++; - case 7: - *(Uint32 *)&((char *)s->pixels)[j * 4 + p0] = - *(Uint32 *) & ((char *)Surface->pixels)[(width - j - 1) * 4 + p1]; - j++; - case 6: - *(Uint32 *)&((char *)s->pixels)[j * 4 + p0] = - *(Uint32 *) & ((char *)Surface->pixels)[(width - j - 1) * 4 + p1]; - j++; - case 5: - *(Uint32 *)&((char *)s->pixels)[j * 4 + p0] = - *(Uint32 *) & ((char *)Surface->pixels)[(width - j - 1) * 4 + p1]; - j++; - case 4: - *(Uint32 *)&((char *)s->pixels)[j * 4 + p0] = - *(Uint32 *) & ((char *)Surface->pixels)[(width - j - 1) * 4 + p1]; - j++; - case 3: - *(Uint32 *)&((char *)s->pixels)[j * 4 + p0] = - *(Uint32 *) & ((char *)Surface->pixels)[(width - j - 1) * 4 + p1]; - j++; - case 2: - *(Uint32 *)&((char *)s->pixels)[j * 4 + p0] = - *(Uint32 *) & ((char *)Surface->pixels)[(width - j - 1) * 4 + p1]; - j++; - case 1: - *(Uint32 *)&((char *)s->pixels)[j * 4 + p0] = - *(Uint32 *) & ((char *)Surface->pixels)[(width - j - 1) * 4 + p1]; - j++; - } while (--n > 0); - } -#endif - p0 += s->pitch; - p1 += Surface->pitch; - } -#endif } break; } @@ -790,36 +723,6 @@ void CGraphic::Flip() } } -/** -** Convert the SDL surface to the display format -*/ -void CGraphic::UseDisplayFormat() -{ -#if 0 - SDL_Surface *s = Surface; - - if (s->format->Amask != 0) { - Surface = SDL_DisplayFormatAlpha(s); - } else { - Surface = SDL_DisplayFormat(s); - } - VideoPaletteListRemove(s); - SDL_FreeSurface(s); - - if (SurfaceFlip) { - s = SurfaceFlip; - if (s->format->Amask != 0) { - SurfaceFlip = SDL_DisplayFormatAlpha(s); - } else { - SurfaceFlip = SDL_DisplayFormat(s); - } - VideoPaletteListRemove(s); - SDL_FreeSurface(s); - } -#endif - -} - /** ** Resize a graphic ** @@ -1154,7 +1057,6 @@ void CFiller::Load() if (G) { G->Load(); map.Init(G); - G->UseDisplayFormat(); } } diff --git a/src/video/movie.cpp b/src/video/movie.cpp index 67ddec26a..a25db26cc 100644 --- a/src/video/movie.cpp +++ b/src/video/movie.cpp @@ -107,38 +107,6 @@ static int OutputTheora(OggData *data, SDL_Texture *yuv_overlay, SDL_Rect *rect) theora_decode_YUVout(&data->tstate, &yuv); -#if 0 - if (SDL_MUSTLOCK(TheScreen)) { - if (SDL_LockSurface(TheScreen) < 0) { - return - 1; - } - } - - if (SDL_LockYUVOverlay(yuv_overlay) < 0) { - return -1; - } - - int crop_offset = data->tinfo.offset_x + yuv.y_stride * data->tinfo.offset_y; - for (int i = 0; i < yuv_overlay->h; ++i) { - memcpy(yuv_overlay->pixels[0] + yuv_overlay->pitches[0] * i, - yuv.y + crop_offset + yuv.y_stride * i, yuv_overlay->w); - } - - crop_offset = (data->tinfo.offset_x / 2) + (yuv.uv_stride) * - (data->tinfo.offset_y / 2); - for (int i = 0; i < yuv_overlay->h / 2; ++i) { - memcpy(yuv_overlay->pixels[1] + yuv_overlay->pitches[1] * i, - yuv.v + yuv.uv_stride * i, yuv_overlay->w / 2); - memcpy(yuv_overlay->pixels[2] + yuv_overlay->pitches[2] * i, - yuv.u + crop_offset + yuv.uv_stride * i, yuv_overlay->w / 2); - } - - if (SDL_MUSTLOCK(TheScreen)) { - SDL_UnlockSurface(TheScreen); - } - SDL_UnlockYUVOverlay(yuv_overlay); -#endif - SDL_UpdateYUVTexture(yuv_overlay, NULL, yuv.y, yuv.y_stride, yuv.u, yuv.uv_stride, yuv.v, yuv.uv_stride); SDL_RenderCopy(TheRenderer, yuv_overlay, NULL, NULL); SDL_RenderPresent(TheRenderer); diff --git a/src/video/sdl.cpp b/src/video/sdl.cpp index 2f1b5ed46..2dbe7d199 100644 --- a/src/video/sdl.cpp +++ b/src/video/sdl.cpp @@ -346,6 +346,7 @@ void InitVideoSdl() 0x0000FF00, 0x000000FF, 0); //0xFF000000); + Assert(SDL_MUSTLOCK(TheScreen) == 0); TheTexture = SDL_CreateTexture(TheRenderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, @@ -442,7 +443,6 @@ void InitVideoSdl() */ int VideoValidResolution(int w, int h) { - //return SDL_VideoModeOK(w, h, TheScreen->format->BitsPerPixel, TheScreen->flags); return 1; } diff --git a/src/video/video.cpp b/src/video/video.cpp index 2ce378ae9..2c83ba5bd 100644 --- a/src/video/video.cpp +++ b/src/video/video.cpp @@ -284,6 +284,7 @@ bool CVideo::ResizeScreen(int w, int h) Uint8 bpp = TheScreen->format->BitsPerPixel; SDL_FreeSurface(TheScreen); TheScreen = SDL_CreateRGBSurface(flags, w, h, bpp, rmask, gmask, bmask, amask); + Assert(SDL_MUSTLOCK(TheScreen) == 0); // new texture Uint32 format;