summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-07-07 02:12:24 +0300
committerAndrei Karas <akaras@inbox.ru>2011-07-07 03:17:16 +0300
commit7d151c8fc05cd7feaf1e1cee33fd8289208fa18d (patch)
treecc246201d9aafb94087efbe85cd13b4b18eacaaf /src/resources
parent95c8a3c0b4d2f0d39c81a6671452e1aa34a626f9 (diff)
downloadmv-7d151c8fc05cd7feaf1e1cee33fd8289208fa18d.tar.gz
mv-7d151c8fc05cd7feaf1e1cee33fd8289208fa18d.tar.bz2
mv-7d151c8fc05cd7feaf1e1cee33fd8289208fa18d.tar.xz
mv-7d151c8fc05cd7feaf1e1cee33fd8289208fa18d.zip
Add map reduce feature for software drawing.
Now invisible tiles will be removed if this mode enabled.
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/image.cpp15
-rw-r--r--src/resources/image.h12
-rw-r--r--src/resources/mapreader.cpp1
3 files changed, 27 insertions, 1 deletions
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index 2d3676304..fdcf210c3 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -53,7 +53,8 @@ Image::Image(SDL_Surface *image, bool hasAlphaChannel, Uint8 *alphaChannel):
mAlpha(1.0f),
mHasAlphaChannel(hasAlphaChannel),
mSDLSurface(image),
- mAlphaChannel(alphaChannel)
+ mAlphaChannel(alphaChannel),
+ mIsAlphaVisible(hasAlphaChannel)
{
#ifdef USE_OPENGL
mGLImage = 0;
@@ -88,6 +89,7 @@ Image::Image(GLuint glimage, int width, int height,
mSDLSurface(0),
mAlphaChannel(0),
mUseAlphaCache(false),
+ mIsAlphaVisible(true),
mGLImage(glimage),
mTexWidth(texWidth),
mTexHeight(texHeight)
@@ -792,11 +794,13 @@ SubImage::SubImage(Image *parent, SDL_Surface *image,
mParent->incRef();
mParent->SDLTerminateAlphaCache();
mHasAlphaChannel = mParent->hasAlphaChannel();
+ mIsAlphaVisible = mHasAlphaChannel;
mAlphaChannel = mParent->SDLgetAlphaChannel();
}
else
{
mHasAlphaChannel = false;
+ mIsAlphaVisible = false;
mAlphaChannel = 0;
}
@@ -805,6 +809,10 @@ SubImage::SubImage(Image *parent, SDL_Surface *image,
mBounds.y = static_cast<short>(y);
mBounds.w = static_cast<Uint16>(width);
mBounds.h = static_cast<Uint16>(height);
+ mInternalBounds.x = mParent->mBounds.x;
+ mInternalBounds.y = mParent->mBounds.y;
+ mInternalBounds.w = mParent->mBounds.w;
+ mInternalBounds.h = mParent->mBounds.h;
mUseAlphaCache = false;
}
@@ -823,6 +831,11 @@ SubImage::SubImage(Image *parent, GLuint image,
mBounds.y = static_cast<short>(y);
mBounds.w = static_cast<Uint16>(width);
mBounds.h = static_cast<Uint16>(height);
+ mInternalBounds.x = mParent->mBounds.x;
+ mInternalBounds.y = mParent->mBounds.y;
+ mInternalBounds.w = mParent->mBounds.w;
+ mInternalBounds.h = mParent->mBounds.h;
+ mIsAlphaVisible = mHasAlphaChannel;
}
#endif
diff --git a/src/resources/image.h b/src/resources/image.h
index 72b85cc1e..ee341af75 100644
--- a/src/resources/image.h
+++ b/src/resources/image.h
@@ -208,6 +208,15 @@ class Image : public Resource
int getTextureHeight() const
{ return mTexHeight; }
+ bool isHasAlphaChannel()
+ { return mHasAlphaChannel; }
+
+ bool isAlphaVisible()
+ { return mIsAlphaVisible; }
+
+ void setAlphaVisible(bool b)
+ { mIsAlphaVisible = b; }
+
static int getTextureType()
{ return mTextureType; }
@@ -247,6 +256,7 @@ class Image : public Resource
std::map<float, SDL_Surface*> mAlphaCache;
bool mUseAlphaCache;
+ bool mIsAlphaVisible;
static bool mEnableAlphaCache;
static bool mEnableAlpha;
@@ -305,6 +315,8 @@ class SubImage : public Image
*/
Image *getSubImage(int x, int y, int width, int height);
+ SDL_Rect mInternalBounds;
+
private:
Image *mParent;
};
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 098af0909..35267533f 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -376,6 +376,7 @@ Map *MapReader::readMap(xmlNodePtr node, const std::string &path)
map->initializeAmbientLayers();
map->clearIndexedTilesets();
map->setActorsFix(0, atoi(map->getProperty("actorsfix").c_str()));
+ map->reduce();
return map;
}