summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-08-11 21:37:02 +0300
committerAndrei Karas <akaras@inbox.ru>2016-08-11 21:40:17 +0300
commitfacd5ec45b0c75eef9e97983a00c19ff2ecf1fe7 (patch)
tree3668b1fc4be470d2edb4b385de9729d250c300f6 /src
parent27946f189154cc6a4079d68e895aaf0bbd8172f5 (diff)
downloadmv-facd5ec45b0c75eef9e97983a00c19ff2ecf1fe7.tar.gz
mv-facd5ec45b0c75eef9e97983a00c19ff2ecf1fe7.tar.bz2
mv-facd5ec45b0c75eef9e97983a00c19ff2ecf1fe7.tar.xz
mv-facd5ec45b0c75eef9e97983a00c19ff2ecf1fe7.zip
Add asserts into imagehelpers.
Diffstat (limited to 'src')
-rw-r--r--src/resources/openglimagehelper.cpp15
-rw-r--r--src/resources/sdl2imagehelper.cpp4
-rw-r--r--src/resources/sdlimagehelper.cpp8
3 files changed, 17 insertions, 10 deletions
diff --git a/src/resources/openglimagehelper.cpp b/src/resources/openglimagehelper.cpp
index e63295c8c..c67ec8a1c 100644
--- a/src/resources/openglimagehelper.cpp
+++ b/src/resources/openglimagehelper.cpp
@@ -43,6 +43,7 @@
#include "resources/image/image.h"
+#include "utils/checkutils.h"
#include "utils/sdlcheckutils.h"
#include <SDL_image.h>
@@ -70,7 +71,7 @@ Image *OpenGLImageHelper::load(SDL_RWops *const rw, Dye const &dye)
SDL_Surface *const tmpImage = loadPng(rw);
if (!tmpImage)
{
- logger->log("Error, image load failed: %s", IMG_GetError());
+ reportAlways("Error, image load failed: %s", IMG_GetError());
return nullptr;
}
@@ -156,8 +157,8 @@ SDL_Surface *OpenGLImageHelper::convertSurfaceNormalize(SDL_Surface *tmpImage,
if (realWidth < width || realHeight < height)
{
- logger->log("Warning: image too large, cropping to %dx%d texture!",
- tmpImage->w, tmpImage->h);
+ reportAlways("Warning: image too large, cropping to %dx%d texture!",
+ tmpImage->w, tmpImage->h);
}
#ifdef USE_SDL2
@@ -196,7 +197,7 @@ SDL_Surface *OpenGLImageHelper::convertSurfaceNormalize(SDL_Surface *tmpImage,
if (!tmpImage)
{
- logger->log("Error, image convert failed: out of memory");
+ reportAlways("Error, image convert failed: out of memory");
return nullptr;
}
SDL_BlitSurface(oldImage, nullptr, tmpImage, nullptr);
@@ -245,7 +246,7 @@ SDL_Surface *OpenGLImageHelper::convertSurface(SDL_Surface *tmpImage,
if (!tmpImage)
{
- logger->log("Error, image convert failed: out of memory");
+ reportAlways("Error, image convert failed: out of memory");
return nullptr;
}
SDL_BlitSurface(oldImage, nullptr, tmpImage, nullptr);
@@ -299,7 +300,7 @@ void OpenGLImageHelper::bindTexture(const GLuint texture)
case RENDER_NULL:
case RENDER_LAST:
default:
- logger->log("Unknown OpenGL backend: %d", mUseOpenGL);
+ reportAlways("Unknown OpenGL backend: %d", mUseOpenGL);
break;
}
}
@@ -394,7 +395,7 @@ Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
if (error)
{
std::string errmsg = GraphicsManager::errorToString(error);
- logger->log("Error: Image GL import failed: %s (%u)",
+ reportAlways("Error: Image GL import failed: %s (%u)",
errmsg.c_str(), error);
// return nullptr;
}
diff --git a/src/resources/sdl2imagehelper.cpp b/src/resources/sdl2imagehelper.cpp
index 7d2c3d8ef..99aa53d2f 100644
--- a/src/resources/sdl2imagehelper.cpp
+++ b/src/resources/sdl2imagehelper.cpp
@@ -26,6 +26,7 @@
#include "resources/image/image.h"
+#include "utils/checkutils.h"
#include "utils/sdlcheckutils.h"
#include "debug.h"
@@ -70,7 +71,10 @@ Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage)
SDL_Texture *const texture = SDL_CreateTextureFromSurface(
mRenderer, tmpImage);
if (!texture)
+ {
+ reportAlways("Texture from surface creation failed");
return nullptr;
+ }
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
return new Image(texture, tmpImage->w, tmpImage->h);
}
diff --git a/src/resources/sdlimagehelper.cpp b/src/resources/sdlimagehelper.cpp
index 4a8c4eb62..54d9c46c8 100644
--- a/src/resources/sdlimagehelper.cpp
+++ b/src/resources/sdlimagehelper.cpp
@@ -31,6 +31,7 @@
#include "resources/image/image.h"
+#include "utils/checkutils.h"
#include "utils/sdlcheckutils.h"
#include <SDL_gfxBlitFunc.h>
@@ -49,7 +50,8 @@ Image *SDLImageHelper::load(SDL_RWops *const rw, Dye const &dye)
SDL_Surface *const tmpImage = loadPng(rw);
if (!tmpImage)
{
- logger->log("Error, image load failed: %s", IMG_GetError());
+ reportAlways("Error, image load failed: %s",
+ IMG_GetError());
return nullptr;
}
@@ -173,7 +175,7 @@ Image *SDLImageHelper::createTextSurface(SDL_Surface *const tmpImage,
if (!image)
{
- logger->log1("Error: Image convert failed.");
+ reportAlways("Error: Image convert failed.");
delete [] alphaChannel;
return nullptr;
}
@@ -272,7 +274,7 @@ Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage)
if (!image)
{
- logger->log1("Error: Image convert failed.");
+ reportAlways("Error: Image convert failed.");
delete [] alphaChannel;
return nullptr;
}