diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-09-23 22:01:44 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-09-23 22:01:44 +0300 |
commit | 3c404128c4669a1f4f190e20a89553677717fc50 (patch) | |
tree | 2db4e5031089c800c4e00fd6244e578f44a7c910 /src/resources/image | |
parent | 89b267d6d73bbc59f7c313b8a22b97fbb27f99a8 (diff) | |
download | manaverse-3c404128c4669a1f4f190e20a89553677717fc50.tar.gz manaverse-3c404128c4669a1f4f190e20a89553677717fc50.tar.bz2 manaverse-3c404128c4669a1f4f190e20a89553677717fc50.tar.xz manaverse-3c404128c4669a1f4f190e20a89553677717fc50.zip |
Add missing comments into defines.
Diffstat (limited to 'src/resources/image')
-rw-r--r-- | src/resources/image/image.cpp | 51 | ||||
-rw-r--r-- | src/resources/image/image.h | 18 | ||||
-rw-r--r-- | src/resources/image/subimage.cpp | 29 | ||||
-rw-r--r-- | src/resources/image/subimage.h | 7 |
4 files changed, 56 insertions, 49 deletions
diff --git a/src/resources/image/image.cpp b/src/resources/image/image.cpp index bb3fe6ce6..379a1c074 100644 --- a/src/resources/image/image.cpp +++ b/src/resources/image/image.cpp @@ -53,7 +53,7 @@ Image::Image(SDL_Texture *restrict const image, mGLImage(0), mTexWidth(0), mTexHeight(0), -#endif +#endif // USE_OPENGL mBounds(), mAlpha(1.0F), mSDLSurface(nullptr), @@ -68,7 +68,7 @@ Image::Image(SDL_Texture *restrict const image, { #ifdef DEBUG_IMAGES logger->log("created image: %p", this); -#endif +#endif // DEBUG_IMAGES mBounds.x = 0; mBounds.y = 0; @@ -86,7 +86,7 @@ Image::Image(SDL_Texture *restrict const image, mBounds.h = 0; } } -#endif +#endif // USE_SDL2 Image::Image(SDL_Surface *restrict const image, const bool hasAlphaChannel0, uint8_t *restrict const alphaChannel) : @@ -95,13 +95,13 @@ Image::Image(SDL_Surface *restrict const image, const bool hasAlphaChannel0, mGLImage(0), mTexWidth(0), mTexHeight(0), -#endif +#endif // USE_OPENGL mBounds(), mAlpha(1.0F), mSDLSurface(image), #ifdef USE_SDL2 mTexture(nullptr), -#endif +#endif // USE_SDL2 mAlphaChannel(alphaChannel), mAlphaCache(), mLoaded(false), @@ -112,7 +112,7 @@ Image::Image(SDL_Surface *restrict const image, const bool hasAlphaChannel0, { #ifdef DEBUG_IMAGES logger->log("created image: %p", static_cast<void*>(this)); -#endif +#endif // DEBUG_IMAGES mBounds.x = 0; mBounds.y = 0; @@ -143,7 +143,7 @@ Image::Image(const GLuint glimage, const int width, const int height, mSDLSurface(nullptr), #ifdef USE_SDL2 mTexture(nullptr), -#endif +#endif // USE_SDL2 mAlphaChannel(nullptr), mAlphaCache(), mLoaded(false), @@ -154,7 +154,7 @@ Image::Image(const GLuint glimage, const int width, const int height, { #ifdef DEBUG_IMAGES logger->log("created image: %p", static_cast<void*>(this)); -#endif +#endif // DEBUG_IMAGES mBounds.x = 0; mBounds.y = 0; @@ -166,14 +166,15 @@ Image::Image(const GLuint glimage, const int width, const int height, mLoaded = true; } } -#endif +#endif // USE_OPENGL Image::~Image() { #ifdef DEBUG_IMAGES logger->log("delete image: %p", static_cast<void*>(this)); logger->log(" %s, %s", mIdPath.c_str(), mSource.c_str()); -#endif +#endif // DEBUG_IMAGES + unload(); } @@ -210,7 +211,7 @@ void Image::unload() SDL_DestroyTexture(mTexture); mTexture = nullptr; } -#endif +#endif // USE_SDL2 #ifdef USE_OPENGL if (mGLImage) @@ -220,9 +221,9 @@ void Image::unload() #ifdef DEBUG_OPENGL_LEAKS if (textures_count > 0) textures_count --; -#endif +#endif // DEBUG_OPENGL_LEAKS } -#endif +#endif // USE_OPENGL } bool Image::hasAlphaChannel() const @@ -233,7 +234,7 @@ bool Image::hasAlphaChannel() const #ifdef USE_OPENGL if (OpenGLImageHelper::mUseOpenGL != RENDER_SOFTWARE) return true; -#endif +#endif // USE_OPENGL return false; } @@ -272,7 +273,8 @@ void Image::setAlpha(const float alpha) { logger->log("alpha: " + toString(i->first)); } -#endif +#endif // DEBUG_ALPHA_CACHE + SDLCleanCache(); } surface = mSDLSurface; @@ -309,11 +311,12 @@ void Image::setAlpha(const float alpha) #ifdef USE_SDL2 SDL_SetSurfaceAlphaMod(mSDLSurface, CAST_U8(255 * mAlpha)); -#else +#else // USE_SDL2 + // Set the alpha value this image is drawn at SDL_SetAlpha(mSDLSurface, SDL_SRCALPHA, CAST_U8(255 * mAlpha)); -#endif +#endif // USE_SDL2 } else { @@ -391,7 +394,7 @@ void Image::setAlpha(const float alpha) SDL_SetTextureAlphaMod(mTexture, CAST_U8(255 * mAlpha)); } -#endif +#endif // USE_SDL2 else { mAlpha = alpha; @@ -446,19 +449,21 @@ Image *Image::getSubImage(const int x, const int y, width, height, mTexWidth, mTexHeight); } -#endif +#endif // USE_OPENGL #ifdef USE_SDL2 #ifndef USE_OPENGL const RenderType mode = ImageHelper::mUseOpenGL; -#endif +#endif // USE_OPENGL + if (mode == RENDER_SOFTWARE) return new SubImage(this, mSDLSurface, x, y, width, height); else return new SubImage(this, mTexture, x, y, width, height); -#else +#else // USE_SDL2 + return new SubImage(this, mSDLSurface, x, y, width, height); -#endif +#endif // USE_SDL2 } void Image::SDLTerminateAlphaCache() @@ -488,4 +493,4 @@ void Image::decRef() OpenGLImageHelper::invalidate(mGLImage); Resource::decRef(); } -#endif +#endif // USE_OPENGL diff --git a/src/resources/image/image.h b/src/resources/image/image.h index ae29a66ae..bb78f685c 100644 --- a/src/resources/image/image.h +++ b/src/resources/image/image.h @@ -33,13 +33,13 @@ #ifdef ANDROID #include <GLES/gl.h> -#else +#else // ANDROID #ifndef USE_SDL2 #define GL_GLEXT_PROTOTYPES 1 -#endif +#endif // USE_SDL2 #include <SDL_opengl.h> -#endif -#endif +#endif // ANDROID +#endif // USE_OPENGL #ifdef USE_SDL2 #include <SDL_render.h> @@ -64,7 +64,7 @@ class Image notfinal : public Resource friend class SDL2SoftwareGraphics; friend class SDL2SoftwareImageHelper; friend class SurfaceImageHelper; -#endif +#endif // USE_SDL2 friend class TestLauncher; #ifdef USE_OPENGL friend class AtlasManager; @@ -171,7 +171,7 @@ class Image notfinal : public Resource GLuint mGLImage; int mTexWidth; int mTexHeight; -#endif +#endif // USE_OPENGL bool isHasAlphaChannel() const A_WARN_UNUSED { return mHasAlphaChannel; } @@ -212,14 +212,14 @@ class Image notfinal : public Resource #ifdef USE_SDL2 Image(SDL_Texture *restrict const image, const int width, const int height); -#endif +#endif // USE_SDL2 SDL_Surface *getByAlpha(const float alpha) A_WARN_UNUSED; SDL_Surface *mSDLSurface; #ifdef USE_SDL2 SDL_Texture *mTexture; -#endif +#endif // USE_SDL2 /** Alpha Channel pointer used for 32bit based SDL surfaces */ uint8_t *mAlphaChannel; @@ -241,7 +241,7 @@ class Image notfinal : public Resource */ Image(const GLuint glimage, const int width, const int height, const int texWidth, const int texHeight); -#endif +#endif // USE_OPENGL }; #endif // RESOURCES_IMAGE_H diff --git a/src/resources/image/subimage.cpp b/src/resources/image/subimage.cpp index 615474334..a26604d75 100644 --- a/src/resources/image/subimage.cpp +++ b/src/resources/image/subimage.cpp @@ -24,7 +24,7 @@ #ifdef DEBUG_IMAGES #include "logger.h" -#endif +#endif // DEBUG_IMAGES #include "debug.h" @@ -47,10 +47,10 @@ SubImage::SubImage(Image *const parent, mSource = parent->getIdPath(); #ifdef DEBUG_IMAGES logger->log("set name2 %p, %s", this, mSource.c_str()); -#endif +#endif // DEBUG_IMAGES #ifdef DEBUG_BIND_TEXTURE mIdPath = parent->getIdPath(); -#endif +#endif // DEBUG_BIND_TEXTURE } else { @@ -80,7 +80,7 @@ SubImage::SubImage(Image *const parent, } mUseAlphaCache = false; } -#endif +#endif // USE_SDL2 SubImage::SubImage(Image *const parent, SDL_Surface *const image, @@ -101,10 +101,10 @@ SubImage::SubImage(Image *const parent, #ifdef DEBUG_IMAGES logger->log("set name2 %p, %s", static_cast<void*>(this), mSource.c_str()); -#endif +#endif // DEBUG_IMAGES #ifdef DEBUG_BIND_TEXTURE mIdPath = parent->getIdPath(); -#endif +#endif // DEBUG_BIND_TEXTURE } else { @@ -163,10 +163,10 @@ SubImage::SubImage(Image *const parent, #ifdef DEBUG_IMAGES logger->log("set name2 %p, %s", static_cast<void*>(this), mSource.c_str()); -#endif +#endif // DEBUG_IMAGES #ifdef DEBUG_BIND_TEXTURE mIdPath = parent->getIdPath(); -#endif +#endif // DEBUG_BIND_TEXTURE } else { @@ -177,14 +177,14 @@ SubImage::SubImage(Image *const parent, } mIsAlphaVisible = mHasAlphaChannel; } -#endif +#endif // USE_OPENGL SubImage::~SubImage() { #ifdef DEBUG_IMAGES logger->log("delete subimage: %p", static_cast<void*>(this)); logger->log(" %s, %s", mIdPath.c_str(), mSource.c_str()); -#endif +#endif // DEBUG_IMAGES // Avoid destruction of the image mSDLSurface = nullptr; // Avoid possible destruction of its alpha channel @@ -192,16 +192,17 @@ SubImage::~SubImage() #ifdef USE_SDL2 // Avoid destruction of texture mTexture = nullptr; -#endif +#endif // USE_SDL2 #ifdef USE_OPENGL mGLImage = 0; -#endif +#endif // USE_OPENGL if (mParent) { #ifdef DEBUG_IMAGES logger->log("decref from subminage: %p, parent: %p", static_cast<void*>(this), static_cast<void*>(mParent)); -#endif +#endif // DEBUG_IMAGES + mParent->decRef(); mParent = nullptr; } @@ -221,7 +222,7 @@ void SubImage::decRef() { Resource::decRef(); } -#endif +#endif // USE_OPENGL int SubImage::calcMemoryLocal() const { diff --git a/src/resources/image/subimage.h b/src/resources/image/subimage.h index 1687081de..14decc14d 100644 --- a/src/resources/image/subimage.h +++ b/src/resources/image/subimage.h @@ -39,14 +39,15 @@ class SubImage final : public Image #ifdef USE_SDL2 SubImage(Image *const parent, SDL_Texture *const image, const int x, const int y, const int width, const int height); -#endif +#endif // USE_SDL2 + SubImage(Image *const parent, SDL_Surface *const image, const int x, const int y, const int width, const int height); #ifdef USE_OPENGL SubImage(Image *const parent, const GLuint image, const int x, const int y, const int width, const int height, const int texWidth, const int textHeight); -#endif +#endif // USE_OPENGL A_DELETE_COPY(SubImage) @@ -72,7 +73,7 @@ class SubImage final : public Image #ifdef USE_OPENGL void decRef() override final; -#endif +#endif // USE_OPENGL SDL_Rect mInternalBounds; |