kill dead code

This commit is contained in:
Tim Felgentreff 2020-04-17 09:59:36 +02:00
parent 11589fe432
commit 4015a88c50
20 changed files with 14 additions and 453 deletions

View file

@ -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; \

View file

@ -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")

View file

@ -56,9 +56,6 @@
#define GCN_SDL_HPP
#include <guichan/sdl/sdlgraphics.h>
#ifdef USE_SDL_IMAGE
#include <guichan/sdl/sdlimageloader.h>
#endif
#include <guichan/sdl/sdlinput.h>
#include "platform.h"

View file

@ -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<int>(area.x + area.width, top.x + top.width);
int y2 = std::min<int>(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
{

View file

@ -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<P ` _: :+' .' "{[
* .)j(] .d_/ '-( P . S
* License: (BSD) <Td/Z <fP"5(\"??"\a. .L
* Redistribution and use in source and _dV>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<<WP+k/);. _W=j f
* 1. Redistributions of source code must .$%w\/]Q . ."' . mj$
* retain the above copyright notice, ]E.pYY(Q]>. a J@\
* this list of conditions and the j(]1u<sE"L,. . ./^ ]{a
* following disclaimer. 4'_uomm\. )L);-4 (3=
* 2. Redistributions in binary form must )_]X{Z('a_"a7'<a"a, ]"[
* reproduce the above copyright notice, #}<]m7`Za??4,P-"'7. ).m
* this list of conditions and the ]d2e)Q(<Q( ?94 b- LQ/
* following disclaimer in the <B!</]C)d_, '(<' .f. =C+m
* documentation and/or other materials .Z!=J ]e []('-4f _ ) -.)m]'
* provided with the distribution. .w[5]' _[ /.)_-"+? _/ <W"
* 3. Neither the name of Guichan nor the :$we` _! + _/ . j?
* names of its contributors may be used =3)= _f (_yQmWW$#( "
* to endorse or promote products derived - W, sQQQQmZQ#Wwa]..
* from this software without specific (js, \[QQW$QWW#?!V"".
* prior written permission. ]y:.<\.. .
* -]n w/ ' [.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT )/ )/ !
* HOLDERS AND CONTRIBUTORS "AS IS" AND ANY < (; sac , '
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, ]^ .- %
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF c < r
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR aga< <La
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 5% )P'-3L
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR _bQf` y`..)a
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ,J?4P'.P"_(\?d'.,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES _Pa,)!f/<[]/ ?"
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT _2-..:. .r+_,.. .
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ?a.<%"' " -'.a_ _,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ^
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* For comments regarding functions please see the header file.
*/
#ifdef USE_SDL_IMAGE
#include <SDL/SDL_image.h>
#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

View file

@ -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;

View file

@ -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);

View file

@ -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);

View file

@ -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();
}

View file

@ -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

View file

@ -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<SDL_Color> 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);
}
/**

View file

@ -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();
}

View file

@ -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) {

View file

@ -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

View file

@ -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);
}
}

View file

@ -142,9 +142,7 @@ static void VideoDrawChar(const CGraphic &g,
SDL_Rect drect = {Sint16(x), Sint16(y), 0, 0};
std::vector<SDL_Color> 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);
}
/**

View file

@ -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();
}
}

View file

@ -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);

View file

@ -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;
}

View file

@ -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;