From d5847d54a527c41006cb4cade15d0b6346490e77 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 25 Aug 2013 19:36:20 +0300 Subject: add partial support for software mode with SDL2. --- src/resources/subimage.cpp | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'src/resources/subimage.cpp') 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(x); + mBounds.y = static_cast(y); + mBounds.w = static_cast(width); + mBounds.h = static_cast(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) : -- cgit v1.2.3-60-g2f50