diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-08-25 19:36:20 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-08-25 23:26:55 +0300 |
commit | d5847d54a527c41006cb4cade15d0b6346490e77 (patch) | |
tree | 5146fc48f6e2d10eb3f41f1b20eac16f66b36f28 /src/resources/subimage.cpp | |
parent | 5b20a3d95717f75d33801c4dd2b093e106d90541 (diff) | |
download | manaverse-d5847d54a527c41006cb4cade15d0b6346490e77.tar.gz manaverse-d5847d54a527c41006cb4cade15d0b6346490e77.tar.bz2 manaverse-d5847d54a527c41006cb4cade15d0b6346490e77.tar.xz manaverse-d5847d54a527c41006cb4cade15d0b6346490e77.zip |
add partial support for software mode with SDL2.
Diffstat (limited to 'src/resources/subimage.cpp')
-rw-r--r-- | src/resources/subimage.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/resources/subimage.cpp b/src/resources/subimage.cpp index b2343c71c..d37eda91a 100644 --- a/src/resources/subimage.cpp +++ b/src/resources/subimage.cpp @@ -36,6 +36,59 @@ #include "debug.h" +#ifdef USE_SDL2 +SubImage::SubImage(Image *const parent, SDL_Texture *const image, + const int x, const int y, + const int width, const int height) : + Image(image, width, height), + mInternalBounds(), + mParent(parent) +{ + if (mParent) + { + mParent->incRef(); + mParent->SDLTerminateAlphaCache(); + mHasAlphaChannel = mParent->hasAlphaChannel(); + mIsAlphaVisible = mHasAlphaChannel; + mAlphaChannel = mParent->SDLgetAlphaChannel(); + mSource = parent->getIdPath(); +#ifdef DEBUG_IMAGES + logger->log("set name2 %p, %s", this, mSource.c_str()); +#endif +#ifdef DEBUG_BIND_TEXTURE + mIdPath = parent->getIdPath(); +#endif + } + else + { + mHasAlphaChannel = false; + mIsAlphaVisible = false; + mAlphaChannel = nullptr; + } + + // Set up the rectangle. + mBounds.x = static_cast<int16_t>(x); + mBounds.y = static_cast<int16_t>(y); + mBounds.w = static_cast<uint16_t>(width); + mBounds.h = static_cast<uint16_t>(height); + if (mParent) + { + mInternalBounds.x = mParent->mBounds.x; + mInternalBounds.y = mParent->mBounds.y; + mInternalBounds.w = mParent->mBounds.w; + mInternalBounds.h = mParent->mBounds.h; + } + else + { + mInternalBounds.x = 0; + mInternalBounds.y = 0; + mInternalBounds.w = 1; + mInternalBounds.h = 1; + } + mUseAlphaCache = false; +} +#endif + SubImage::SubImage(Image *const parent, SDL_Surface *const image, const int x, const int y, const int width, const int height) : |