summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-06-10 01:08:32 +0300
committerAndrei Karas <akaras@inbox.ru>2011-06-10 01:08:32 +0300
commitbff595c13f2e6bc98857d6f5d02ec79eefb751cc (patch)
tree17e38c6b9615a49035dc933e6312266eabf7b89d
parent3e9d70d40bfd0205ffaf4db268e6c4a908fc36e9 (diff)
downloadmanaverse-bff595c13f2e6bc98857d6f5d02ec79eefb751cc.tar.gz
manaverse-bff595c13f2e6bc98857d6f5d02ec79eefb751cc.tar.bz2
manaverse-bff595c13f2e6bc98857d6f5d02ec79eefb751cc.tar.xz
manaverse-bff595c13f2e6bc98857d6f5d02ec79eefb751cc.zip
Improve image loading speed in Software mode.
-rw-r--r--src/resources/image.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index 4a89ae636..e9260071f 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -555,35 +555,38 @@ Image *Image::_SDLload(SDL_Surface *tmpImage)
converted = true;
}
+ const int sz = tmpImage->w * tmpImage->h;
// Figure out whether the image uses its alpha layer
if (tmpImage->format->palette == NULL)
{
const SDL_PixelFormat * const fmt = tmpImage->format;
- for (int i = 0; i < tmpImage->w * tmpImage->h; ++ i)
+ if (fmt->Amask)
{
- Uint8 a;
- if (fmt->Amask)
+ for (int i = 0; i < sz; ++ i)
{
unsigned v = ((static_cast<Uint32*>(tmpImage->pixels))[i]
& fmt->Amask) >> fmt->Ashift;
- a = (v << fmt->Aloss) + (v >> (8 - (fmt->Aloss << 1)));
- }
- else
- {
- a = SDL_ALPHA_OPAQUE;
- }
+ Uint8 a = (v << fmt->Aloss) + (v >> (8 - (fmt->Aloss << 1)));
- if (a != 255)
- hasAlpha = true;
+ if (a != 255)
+ hasAlpha = true;
- alphaChannel[i] = a;
+ alphaChannel[i] = a;
+ }
+ }
+ else
+ {
+ if (SDL_ALPHA_OPAQUE != 255)
+ hasAlpha = true;
+ for (int i = 0; i < sz; ++ i)
+ alphaChannel[i] = SDL_ALPHA_OPAQUE;
}
}
else
{
if (SDL_ALPHA_OPAQUE != 255)
hasAlpha = true;
- for (int i = 0; i < tmpImage->w * tmpImage->h; ++ i)
+ for (int i = 0; i < sz; ++ i)
alphaChannel[i] = SDL_ALPHA_OPAQUE;
}