From f199b9ba7da47cb6f9aa95f843c0628621899aa9 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 10 Jun 2012 00:11:20 +0300 Subject: Move SubImage class to separate file. --- src/resources/image.cpp | 104 +----------------------------------------------- 1 file changed, 1 insertion(+), 103 deletions(-) (limited to 'src/resources/image.cpp') diff --git a/src/resources/image.cpp b/src/resources/image.cpp index 0e0937ce6..5496a10d8 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -37,6 +37,7 @@ #include "utils/stringutils.h" #include "resources/imagehelper.h" +#include "resources/subimage.h" #include #include @@ -335,106 +336,3 @@ void Image::SDLTerminateAlphaCache() SDLCleanCache(); mUseAlphaCache = false; } - -//============================================================================ -// SubImage Class -//============================================================================ - -SubImage::SubImage(Image *parent, SDL_Surface *image, - int x, int y, int width, int height): - Image(image), - mParent(parent) -{ - if (mParent) - { - mParent->incRef(); - mParent->SDLTerminateAlphaCache(); - mHasAlphaChannel = mParent->hasAlphaChannel(); - mIsAlphaVisible = mHasAlphaChannel; - mAlphaChannel = mParent->SDLgetAlphaChannel(); - } - 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; -} - -#ifdef USE_OPENGL -SubImage::SubImage(Image *parent, GLuint image, - int x, int y, int width, int height, - int texWidth, int texHeight): - Image(image, width, height, texWidth, texHeight), - mParent(parent) -{ - if (mParent) - mParent->incRef(); - - // 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; - } - mIsAlphaVisible = mHasAlphaChannel; -} -#endif - -SubImage::~SubImage() -{ - // Avoid destruction of the image - mSDLSurface = nullptr; - // Avoid possible destruction of its alpha channel - mAlphaChannel = nullptr; -#ifdef USE_OPENGL - mGLImage = 0; -#endif - if (mParent) - { - mParent->decRef(); - mParent = nullptr; - } -} - -Image *SubImage::getSubImage(int x, int y, int w, int h) -{ - if (mParent) - return mParent->getSubImage(mBounds.x + x, mBounds.y + y, w, h); - else - return nullptr; -} -- cgit v1.2.3-60-g2f50