From 7d151c8fc05cd7feaf1e1cee33fd8289208fa18d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 7 Jul 2011 02:12:24 +0300 Subject: Add map reduce feature for software drawing. Now invisible tiles will be removed if this mode enabled. --- src/resources/image.cpp | 15 ++++++++++++++- src/resources/image.h | 12 ++++++++++++ src/resources/mapreader.cpp | 1 + 3 files changed, 27 insertions(+), 1 deletion(-) (limited to 'src/resources') 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(y); mBounds.w = static_cast(width); mBounds.h = static_cast(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(y); mBounds.w = static_cast(width); mBounds.h = static_cast(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 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; } -- cgit v1.2.3-70-g09d2