summaryrefslogtreecommitdiff
path: root/src/resources/image
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-06-06 23:34:34 +0300
committerAndrei Karas <akaras@inbox.ru>2017-06-07 19:23:40 +0300
commit36ba43d6ea38062b17f7e63ef659962bfc51c64d (patch)
tree190156cb88b13a38a6d13c69ee0742cc078065a1 /src/resources/image
parentf1518dd8476c968a43fa57cfb06198e290a4f77a (diff)
downloadmv-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.gz
mv-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.bz2
mv-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.xz
mv-36ba43d6ea38062b17f7e63ef659962bfc51c64d.zip
Fix clang-tidy check readability-implicit-bool-cast.
Diffstat (limited to 'src/resources/image')
-rw-r--r--src/resources/image/image.cpp28
-rw-r--r--src/resources/image/subimage.cpp12
2 files changed, 20 insertions, 20 deletions
diff --git a/src/resources/image/image.cpp b/src/resources/image/image.cpp
index 7d96cb0af..b1b23ce13 100644
--- a/src/resources/image/image.cpp
+++ b/src/resources/image/image.cpp
@@ -147,7 +147,7 @@ Image::Image(SDL_Surface *restrict const image, const bool hasAlphaChannel0,
mBounds.x = 0;
mBounds.y = 0;
- if (mSDLSurface)
+ if (mSDLSurface != nullptr)
{
mBounds.w = CAST_U16(mSDLSurface->w);
mBounds.h = CAST_U16(mSDLSurface->h);
@@ -191,7 +191,7 @@ Image::Image(const GLuint glimage, const int width, const int height,
mBounds.w = CAST_U16(width);
mBounds.h = CAST_U16(height);
- if (mGLImage)
+ if (mGLImage != 0u)
{
mLoaded = true;
}
@@ -225,7 +225,7 @@ void Image::unload()
{
mLoaded = false;
- if (mSDLSurface)
+ if (mSDLSurface != nullptr)
{
SDLCleanCache();
// Free the image surface.
@@ -244,7 +244,7 @@ void Image::unload()
#endif // USE_SDL2
#ifdef USE_OPENGL
- if (mGLImage)
+ if (mGLImage != 0u)
{
glDeleteTextures(1, &mGLImage);
mGLImage = 0;
@@ -286,12 +286,12 @@ void Image::setAlpha(const float alpha)
if (alpha < 0.0F || alpha > 1.0F)
return;
- if (mSDLSurface)
+ if (mSDLSurface != nullptr)
{
if (mUseAlphaCache)
{
SDL_Surface *surface = getByAlpha(mAlpha);
- if (!surface)
+ if (surface == nullptr)
{
if (mAlphaCache.size() > 100)
{
@@ -308,7 +308,7 @@ void Image::setAlpha(const float alpha)
SDLCleanCache();
}
surface = mSDLSurface;
- if (surface)
+ if (surface != nullptr)
mAlphaCache[mAlpha] = surface;
}
else
@@ -317,7 +317,7 @@ void Image::setAlpha(const float alpha)
}
surface = getByAlpha(alpha);
- if (surface)
+ if (surface != nullptr)
{
if (mSDLSurface == surface)
logger->log("bug");
@@ -329,7 +329,7 @@ void Image::setAlpha(const float alpha)
else
{
mSDLSurface = SDLImageHelper::SDLDuplicateSurface(mSDLSurface);
- if (!mSDLSurface)
+ if (mSDLSurface == nullptr)
return;
}
}
@@ -368,7 +368,7 @@ void Image::setAlpha(const float alpha)
const uint8_t aloss = fmt->Aloss;
const uint8_t ashift = fmt->Ashift;
- if (!bx && bxw == sw)
+ if ((bx == 0) && bxw == sw)
{
const int i2 = (maxHeight - 1) * sw + maxWidth - 1;
for (int i = i1; i <= i2; i++)
@@ -443,7 +443,7 @@ Image* Image::SDLgetScaledImage(const int width, const int height) const
Image* scaledImage = nullptr;
- if (mSDLSurface)
+ if (mSDLSurface != nullptr)
{
SDL_Surface *const scaledSurface = zoomSurface(mSDLSurface,
static_cast<double>(width) / mBounds.w,
@@ -452,7 +452,7 @@ Image* Image::SDLgetScaledImage(const int width, const int height) const
// The load function takes care of the SDL<->OpenGL implementation
// and about freeing the given SDL_surface*.
- if (scaledSurface)
+ if (scaledSurface != nullptr)
{
scaledImage = imageHelper->loadSurface(scaledSurface);
MSDL_FreeSurface(scaledSurface);
@@ -508,7 +508,7 @@ int Image::calcMemoryLocal() const
int sz = static_cast<int>(sizeof(Image) +
sizeof(std::map<float, SDL_Surface*>)) +
Resource::calcMemoryLocal();
- if (mSDLSurface)
+ if (mSDLSurface != nullptr)
{
sz += CAST_S32(mAlphaCache.size()) *
memoryManager.getSurfaceSize(mSDLSurface);
@@ -519,7 +519,7 @@ int Image::calcMemoryLocal() const
#ifdef USE_OPENGL
void Image::decRef()
{
- if (mGLImage && mRefCount <= 1)
+ if ((mGLImage != 0u) && mRefCount <= 1)
OpenGLImageHelper::invalidate(mGLImage);
Resource::decRef();
}
diff --git a/src/resources/image/subimage.cpp b/src/resources/image/subimage.cpp
index 7d936ecbf..77d0eb889 100644
--- a/src/resources/image/subimage.cpp
+++ b/src/resources/image/subimage.cpp
@@ -90,7 +90,7 @@ SubImage::SubImage(Image *const parent,
mInternalBounds(),
mParent(parent)
{
- if (mParent)
+ if (mParent != nullptr)
{
mParent->incRef();
mParent->SDLTerminateAlphaCache();
@@ -118,7 +118,7 @@ SubImage::SubImage(Image *const parent,
mBounds.y = CAST_S16(y);
mBounds.w = CAST_U16(width);
mBounds.h = CAST_U16(height);
- if (mParent)
+ if (mParent != nullptr)
{
mInternalBounds.x = mParent->mBounds.x;
mInternalBounds.y = mParent->mBounds.y;
@@ -145,7 +145,7 @@ SubImage::SubImage(Image *const parent,
mInternalBounds(),
mParent(parent)
{
- if (mParent)
+ if (mParent != nullptr)
mParent->incRef();
// Set up the rectangle.
@@ -153,7 +153,7 @@ SubImage::SubImage(Image *const parent,
mBounds.y = CAST_S16(y);
mBounds.w = CAST_U16(width);
mBounds.h = CAST_U16(height);
- if (mParent)
+ if (mParent != nullptr)
{
mInternalBounds.x = mParent->mBounds.x;
mInternalBounds.y = mParent->mBounds.y;
@@ -196,7 +196,7 @@ SubImage::~SubImage()
#ifdef USE_OPENGL
mGLImage = 0;
#endif // USE_OPENGL
- if (mParent)
+ if (mParent != nullptr)
{
#ifdef DEBUG_IMAGES
logger->log("decref from subminage: %p, parent: %p",
@@ -211,7 +211,7 @@ SubImage::~SubImage()
Image *SubImage::getSubImage(const int x, const int y,
const int w, const int h)
{
- if (mParent)
+ if (mParent != nullptr)
return mParent->getSubImage(mBounds.x + x, mBounds.y + y, w, h);
else
return nullptr;