summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-06-04 22:37:02 +0300
committerAndrei Karas <akaras@inbox.ru>2012-06-04 22:37:02 +0300
commitb1eac7d3738dcff22a3b553459f1587c18a23c23 (patch)
treee96730e1d46d2345f70f8f3f085194de33f73e7c /src
parent9150a4f7372f46fce8ea14082d5d9ab362334a6e (diff)
downloadplus-b1eac7d3738dcff22a3b553459f1587c18a23c23.tar.gz
plus-b1eac7d3738dcff22a3b553459f1587c18a23c23.tar.bz2
plus-b1eac7d3738dcff22a3b553459f1587c18a23c23.tar.xz
plus-b1eac7d3738dcff22a3b553459f1587c18a23c23.zip
Improve images load speed in openGL modes for correct image sizes.
Diffstat (limited to 'src')
-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)