summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/image.cpp29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index da20719ac..9bb824ea1 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -761,18 +761,28 @@ Image *Image::_GLload(SDL_Surface *tmpImage)
amask = 0xff000000;
#endif
- SDL_Surface *oldImage = tmpImage;
- tmpImage = SDL_CreateRGBSurface(SDL_SWSURFACE, realWidth, realHeight,
- 32, rmask, gmask, bmask, amask);
+ SDL_Surface *oldImage = nullptr;
+ if (tmpImage->format->BitsPerPixel != 32
+ || realWidth != width || realHeight != height)
+ {
+ oldImage = tmpImage;
+ tmpImage = SDL_CreateRGBSurface(SDL_SWSURFACE, realWidth, realHeight,
+ 32, rmask, gmask, bmask, amask);
- if (!tmpImage)
+ if (!tmpImage)
+ {
+ logger->log("Error, image convert failed: out of memory");
+ return nullptr;
+ }
+ SDL_BlitSurface(oldImage, nullptr, tmpImage, nullptr);
+ }
+ else
{
- logger->log("Error, image convert failed: out of memory");
- return nullptr;
+ static int cnt = 0;
+ cnt ++;
+ logger->log("fast load: %d", cnt);
}
- SDL_BlitSurface(oldImage, nullptr, tmpImage, nullptr);
-
GLuint texture;
glGenTextures(1, &texture);
if (mUseOpenGL == 1)
@@ -816,7 +826,8 @@ Image *Image::_GLload(SDL_Surface *tmpImage)
if (SDL_MUSTLOCK(tmpImage))
SDL_UnlockSurface(tmpImage);
- SDL_FreeSurface(tmpImage);
+ if (oldImage)
+ SDL_FreeSurface(tmpImage);
GLenum error = glGetError();
if (error)