diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-09-01 23:38:52 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-09-01 23:38:52 +0300 |
commit | 987141c4340c508b14ec085f977754bb48dcfe0e (patch) | |
tree | bcf9b747ebdf79a4c45a9d19a4c22725d48f4b99 /src | |
parent | 2ab3f0d8d04374b330c91a9f065efa0f526d7824 (diff) | |
download | manaplus-987141c4340c508b14ec085f977754bb48dcfe0e.tar.gz manaplus-987141c4340c508b14ec085f977754bb48dcfe0e.tar.bz2 manaplus-987141c4340c508b14ec085f977754bb48dcfe0e.tar.xz manaplus-987141c4340c508b14ec085f977754bb48dcfe0e.zip |
improve speed in software renderer in SDL2.
now it works almost with same speed like SDL1.2
Diffstat (limited to 'src')
-rw-r--r-- | src/render/graphics.h | 2 | ||||
-rw-r--r-- | src/render/sdl2softwaregraphics.cpp | 15 | ||||
-rw-r--r-- | src/render/sdl2softwaregraphics.h | 2 | ||||
-rw-r--r-- | src/resources/sdl2softwareimagehelper.cpp | 10 | ||||
-rw-r--r-- | src/resources/sdl2softwareimagehelper.h | 10 |
5 files changed, 20 insertions, 19 deletions
diff --git a/src/render/graphics.h b/src/render/graphics.h index c2fd7480a..eec6e4c9d 100644 --- a/src/render/graphics.h +++ b/src/render/graphics.h @@ -142,7 +142,7 @@ class Graphics : public gcn::Graphics /** * Resize the window to the specified size. */ - bool resizeScreen(const int width, const int height); + virtual bool resizeScreen(const int width, const int height); /** * Blits an image onto the screen. diff --git a/src/render/sdl2softwaregraphics.cpp b/src/render/sdl2softwaregraphics.cpp index 857909636..ac9f962ac 100644 --- a/src/render/sdl2softwaregraphics.cpp +++ b/src/render/sdl2softwaregraphics.cpp @@ -32,7 +32,7 @@ #include "logger.h" #include "resources/imagehelper.h" -#include "resources/sdl2imagehelper.h" +#include "resources/sdl2softwareimagehelper.h" #include <guichan/sdl/sdlpixel.hpp> @@ -1267,7 +1267,8 @@ bool SDL2SoftwareGraphics::setVideoMode(const int w, const int h, } mSurface = SDL_GetWindowSurface(mWindow); - logger->log("window surface: %p", mSurface); + imageHelper->dumpSurfaceFormat(mSurface); + SDL2SoftwareImageHelper::setFormat(mSurface->format); int w1 = 0; int h1 = 0; @@ -1276,8 +1277,16 @@ bool SDL2SoftwareGraphics::setVideoMode(const int w, const int h, mRect.h = h1; mRenderer = graphicsManager.createRenderer(mWindow, mRendererFlags); - SDLImageHelper::setRenderer(mRenderer); return videoInfo(); } +bool SDL2SoftwareGraphics::resizeScreen(const int width, const int height) +{ + const bool ret = Graphics::resizeScreen(width, height); + + mSurface = SDL_GetWindowSurface(mWindow); + SDL2SoftwareImageHelper::setFormat(mSurface->format); + return ret; +} + #endif // USE_SDL2 diff --git a/src/render/sdl2softwaregraphics.h b/src/render/sdl2softwaregraphics.h index 7ddba5018..9fd53909d 100644 --- a/src/render/sdl2softwaregraphics.h +++ b/src/render/sdl2softwaregraphics.h @@ -131,6 +131,8 @@ class SDL2SoftwareGraphics : public Graphics void setRendererFlags(const uint32_t flags) { mRendererFlags = flags; } + bool resizeScreen(const int width, const int height); + protected: virtual bool drawImage2(const Image *const image, int srcX, int srcY, diff --git a/src/resources/sdl2softwareimagehelper.cpp b/src/resources/sdl2softwareimagehelper.cpp index 3511b8298..7c4ff3d5d 100644 --- a/src/resources/sdl2softwareimagehelper.cpp +++ b/src/resources/sdl2softwareimagehelper.cpp @@ -40,7 +40,7 @@ #include "debug.h" bool SDL2SoftwareImageHelper::mEnableAlphaCache = false; -SDL_Renderer *SDL2SoftwareImageHelper::mRenderer = nullptr; +SDL_PixelFormat *SDL2SoftwareImageHelper::mFormat = nullptr; Image *SDL2SoftwareImageHelper::load(SDL_RWops *const rw, Dye const &dye) const { @@ -137,13 +137,7 @@ Image *SDL2SoftwareImageHelper::_SDLload(SDL_Surface *tmpImage) const if (!tmpImage) return nullptr; -// SDL_Texture *const texture = SDL_CreateTextureFromSurface( -// mRenderer, tmpImage); -// if (!texture) -// return nullptr; -// SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND); -// return new Image(texture, tmpImage->w, tmpImage->h); - SDL_Surface *image = convertTo32Bit(tmpImage); + SDL_Surface *image = SDL_ConvertSurface(tmpImage, mFormat, 0); return new Image(image, false, nullptr); } diff --git a/src/resources/sdl2softwareimagehelper.h b/src/resources/sdl2softwareimagehelper.h index 877ae9032..907d2242e 100644 --- a/src/resources/sdl2softwareimagehelper.h +++ b/src/resources/sdl2softwareimagehelper.h @@ -94,19 +94,15 @@ class SDL2SoftwareImageHelper final : public ImageHelper SDL_Surface *const dst, SDL_Rect *const dstrect); -#ifdef USE_SDL2 - static void setRenderer(SDL_Renderer *const renderer) - { mRenderer = renderer; } -#endif + static void setFormat(SDL_PixelFormat *const format) + { mFormat = format; } protected: /** SDL_Surface to SDL_Surface Image loader */ Image *_SDLload(SDL_Surface *tmpImage) const A_WARN_UNUSED; static bool mEnableAlphaCache; -#ifdef USE_SDL2 - static SDL_Renderer *mRenderer; -#endif + static SDL_PixelFormat *mFormat; }; #endif // USE_SDL2 |