From 987141c4340c508b14ec085f977754bb48dcfe0e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 1 Sep 2013 23:38:52 +0300 Subject: improve speed in software renderer in SDL2. now it works almost with same speed like SDL1.2 --- src/render/graphics.h | 2 +- src/render/sdl2softwaregraphics.cpp | 15 ++++++++++++--- src/render/sdl2softwaregraphics.h | 2 ++ 3 files changed, 15 insertions(+), 4 deletions(-) (limited to 'src/render') 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 @@ -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, -- cgit v1.2.3-70-g09d2