summaryrefslogtreecommitdiff
path: root/src/render
diff options
context:
space:
mode:
Diffstat (limited to 'src/render')
-rw-r--r--src/render/mobileopenglgraphics.cpp20
-rw-r--r--src/render/modernopenglgraphics.cpp24
-rw-r--r--src/render/modernopenglgraphics.h8
-rw-r--r--src/render/normalopenglgraphics.cpp20
-rw-r--r--src/render/nullopenglgraphics.cpp14
-rw-r--r--src/render/safeopenglgraphics.cpp12
-rw-r--r--src/render/sdl2graphics.cpp6
-rw-r--r--src/render/sdl2softwaregraphics.cpp6
-rw-r--r--src/render/sdlgraphics.cpp16
9 files changed, 113 insertions, 13 deletions
diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp
index 2c337c294..b385d8306 100644
--- a/src/render/mobileopenglgraphics.cpp
+++ b/src/render/mobileopenglgraphics.cpp
@@ -154,6 +154,11 @@ bool MobileOpenGLGraphics::setVideoMode(const int w, const int h,
static inline void drawQuad(const Image *const image,
const int srcX, const int srcY,
const int dstX, const int dstY,
+ const int width, const int height) A_NONNULL(1);
+
+static inline void drawQuad(const Image *const image,
+ const int srcX, const int srcY,
+ const int dstX, const int dstY,
const int width, const int height)
{
// if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
@@ -198,6 +203,13 @@ static inline void drawRescaledQuad(const Image *const image,
const int dstX, const int dstY,
const int width, const int height,
const int desiredWidth,
+ const int desiredHeight) A_NONNULL(1);
+
+static inline void drawRescaledQuad(const Image *const image,
+ const int srcX, const int srcY,
+ const int dstX, const int dstY,
+ const int width, const int height,
+ const int desiredWidth,
const int desiredHeight)
{
// if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
@@ -686,6 +698,8 @@ void MobileOpenGLGraphics::calcTileCollection(ImageCollection *const vertCol,
const Image *const image,
int x, int y)
{
+ if (!vertCol || !image)
+ return;
if (vertCol->currentGLImage != image->mGLImage)
{
ImageVertexes *const vert = new ImageVertexes();
@@ -704,6 +718,8 @@ void MobileOpenGLGraphics::calcTileCollection(ImageCollection *const vertCol,
void MobileOpenGLGraphics::drawTileCollection(const ImageCollection
*const vertCol)
{
+ if (!vertCol)
+ return;
const ImageVertexesVector &draws = vertCol->draws;
const ImageCollectionCIter it_end = draws.end();
for (ImageCollectionCIter it = draws.begin(); it != it_end; ++ it)
@@ -726,6 +742,8 @@ void MobileOpenGLGraphics::calcPattern(ImageCollection* const vertCol,
const int x, const int y,
const int w, const int h) const
{
+ if (!vertCol || !image)
+ return;
ImageVertexes *vert = nullptr;
if (vertCol->currentGLImage != image->mGLImage)
{
@@ -823,6 +841,8 @@ void MobileOpenGLGraphics::calcWindow(ImageCollection *const vertCol,
const int w, const int h,
const ImageRect &imgRect)
{
+ if (!vertCol)
+ return;
ImageVertexes *vert = nullptr;
const Image *const image = imgRect.grid[4];
if (vertCol->currentGLImage != image->mGLImage)
diff --git a/src/render/modernopenglgraphics.cpp b/src/render/modernopenglgraphics.cpp
index 9e0644138..9f3bd9809 100644
--- a/src/render/modernopenglgraphics.cpp
+++ b/src/render/modernopenglgraphics.cpp
@@ -257,8 +257,7 @@ void ModernOpenGLGraphics::setColorAlpha(const float alpha)
}
}
-void ModernOpenGLGraphics::drawQuad(const Image *const image A_UNUSED,
- const int srcX, const int srcY,
+void ModernOpenGLGraphics::drawQuad(const int srcX, const int srcY,
const int dstX, const int dstY,
const int width, const int height)
{
@@ -284,8 +283,7 @@ void ModernOpenGLGraphics::drawQuad(const Image *const image A_UNUSED,
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
-void ModernOpenGLGraphics::drawRescaledQuad(const Image *const image A_UNUSED,
- const int srcX, const int srcY,
+void ModernOpenGLGraphics::drawRescaledQuad(const int srcX, const int srcY,
const int dstX, const int dstY,
const int width, const int height,
const int desiredWidth,
@@ -336,8 +334,7 @@ void ModernOpenGLGraphics::drawImageInline(const Image *const image,
const ClipRect &clipArea = mClipStack.top();
const SDL_Rect &imageRect = image->mBounds;
- drawQuad(nullptr,
- imageRect.x, imageRect.y,
+ drawQuad(imageRect.x, imageRect.y,
dstX + clipArea.xOffset, dstY + clipArea.yOffset,
imageRect.w, imageRect.h);
}
@@ -416,8 +413,7 @@ void ModernOpenGLGraphics::drawRescaledImage(const Image *const image,
const ClipRect &clipArea = mClipStack.top();
// Draw a textured quad.
- drawRescaledQuad(nullptr,
- imageRect.x, imageRect.y,
+ drawRescaledQuad(imageRect.x, imageRect.y,
dstX + clipArea.xOffset, dstY + clipArea.yOffset,
imageRect.w, imageRect.h,
desiredWidth, desiredHeight);
@@ -652,6 +648,8 @@ void ModernOpenGLGraphics::calcTileCollection(ImageCollection *const vertCol,
const Image *const image,
int x, int y)
{
+ if (!vertCol || !image)
+ return;
if (vertCol->currentGLImage != image->mGLImage)
{
ImageVertexes *const vert = new ImageVertexes();
@@ -670,6 +668,8 @@ void ModernOpenGLGraphics::calcTileCollection(ImageCollection *const vertCol,
void ModernOpenGLGraphics::drawTileCollection(const ImageCollection
*const vertCol)
{
+ if (!vertCol)
+ return;
setTexturingAndBlending(true);
/*
if (!vertCol)
@@ -699,6 +699,8 @@ void ModernOpenGLGraphics::calcPattern(ImageCollection* const vertCol,
const int x, const int y,
const int w, const int h) const
{
+ if (!vertCol || !image)
+ return;
ImageVertexes *vert = nullptr;
if (vertCol->currentGLImage != image->mGLImage)
{
@@ -791,6 +793,8 @@ void ModernOpenGLGraphics::calcWindow(ImageCollection *const vertCol,
const int w, const int h,
const ImageRect &imgRect)
{
+ if (!vertCol)
+ return;
ImageVertexes *vert = nullptr;
const Image *const image = imgRect.grid[4];
if (vertCol->currentGLImage != image->mGLImage)
@@ -1256,6 +1260,8 @@ void ModernOpenGLGraphics::createGLContext()
void ModernOpenGLGraphics::finalize(ImageCollection *const col)
{
+ if (!col)
+ return;
FOR_EACH (ImageCollectionIter, it, col->draws)
finalize(*it);
}
@@ -1264,6 +1270,8 @@ void ModernOpenGLGraphics::finalize(ImageVertexes *const vert)
{
// in future need convert in each switchVp/continueVp
+ if (!vert)
+ return;
OpenGLGraphicsVertexes &ogl = vert->ogl;
const std::vector<int> &vp = ogl.mVp;
std::vector<int>::const_iterator ivp;
diff --git a/src/render/modernopenglgraphics.h b/src/render/modernopenglgraphics.h
index 0577f5db2..1f55717a3 100644
--- a/src/render/modernopenglgraphics.h
+++ b/src/render/modernopenglgraphics.h
@@ -67,7 +67,7 @@ class ModernOpenGLGraphics final : public Graphics
void testDraw() override final;
void removeArray(const uint32_t id,
- uint32_t *const arr) override final;
+ uint32_t *const arr) override final A_NONNULL(3);
void createGLContext() override final;
@@ -80,13 +80,11 @@ class ModernOpenGLGraphics final : public Graphics
private:
void deleteGLObjects();
- inline void drawQuad(const Image *const image,
- const int srcX, const int srcY,
+ inline void drawQuad(const int srcX, const int srcY,
const int dstX, const int dstY,
const int width, const int height);
- inline void drawRescaledQuad(const Image *const image,
- const int srcX, const int srcY,
+ inline void drawRescaledQuad(const int srcX, const int srcY,
const int dstX, const int dstY,
const int width, const int height,
const int desiredWidth,
diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp
index dd4fe3002..eb5609b19 100644
--- a/src/render/normalopenglgraphics.cpp
+++ b/src/render/normalopenglgraphics.cpp
@@ -206,6 +206,11 @@ static inline void bindPointerInt(const GLint *const vert,
static inline void drawQuad(const Image *const image,
const int srcX, const int srcY,
const int dstX, const int dstY,
+ const int width, const int height) A_NONNULL(1);
+
+static inline void drawQuad(const Image *const image,
+ const int srcX, const int srcY,
+ const int dstX, const int dstY,
const int width, const int height)
{
if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
@@ -270,6 +275,13 @@ static inline void drawRescaledQuad(const Image *const image,
const int dstX, const int dstY,
const int width, const int height,
const int desiredWidth,
+ const int desiredHeight) A_NONNULL(1);
+
+static inline void drawRescaledQuad(const Image *const image,
+ const int srcX, const int srcY,
+ const int dstX, const int dstY,
+ const int width, const int height,
+ const int desiredWidth,
const int desiredHeight)
{
if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
@@ -995,6 +1007,8 @@ void NormalOpenGLGraphics::calcTileCollection(ImageCollection *const vertCol,
const Image *const image,
int x, int y)
{
+ if (!vertCol || !image)
+ return;
if (vertCol->currentGLImage != image->mGLImage)
{
ImageVertexes *const vert = new ImageVertexes();
@@ -1013,6 +1027,8 @@ void NormalOpenGLGraphics::calcTileCollection(ImageCollection *const vertCol,
void NormalOpenGLGraphics::drawTileCollection(const ImageCollection
*const vertCol)
{
+ if (!vertCol)
+ return;
const ImageVertexesVector &draws = vertCol->draws;
const ImageCollectionCIter it_end = draws.end();
for (ImageCollectionCIter it = draws.begin(); it != it_end; ++ it)
@@ -1035,6 +1051,8 @@ void NormalOpenGLGraphics::calcPattern(ImageCollection* const vertCol,
const int x, const int y,
const int w, const int h) const
{
+ if (!vertCol || !image)
+ return;
ImageVertexes *vert = nullptr;
if (vertCol->currentGLImage != image->mGLImage)
{
@@ -1151,6 +1169,8 @@ void NormalOpenGLGraphics::calcWindow(ImageCollection *const vertCol,
const int w, const int h,
const ImageRect &imgRect)
{
+ if (!vertCol)
+ return;
ImageVertexes *vert = nullptr;
Image *const image = imgRect.grid[4];
if (!image)
diff --git a/src/render/nullopenglgraphics.cpp b/src/render/nullopenglgraphics.cpp
index dba15449a..27013f93b 100644
--- a/src/render/nullopenglgraphics.cpp
+++ b/src/render/nullopenglgraphics.cpp
@@ -110,6 +110,12 @@ static inline void drawQuad(const Image *const image A_UNUSED,
const int srcX A_UNUSED, const int srcY A_UNUSED,
const int dstX A_UNUSED, const int dstY A_UNUSED,
const int width A_UNUSED,
+ const int height A_UNUSED) A_NONNULL(1);
+
+static inline void drawQuad(const Image *const image A_UNUSED,
+ const int srcX A_UNUSED, const int srcY A_UNUSED,
+ const int dstX A_UNUSED, const int dstY A_UNUSED,
+ const int width A_UNUSED,
const int height A_UNUSED)
{
if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
@@ -706,6 +712,8 @@ void NullOpenGLGraphics::calcTileCollection(ImageCollection *const vertCol,
const Image *const image,
int x, int y)
{
+ if (!vertCol || !image)
+ return;
if (vertCol->currentGLImage != image->mGLImage)
{
ImageVertexes *const vert = new ImageVertexes();
@@ -724,6 +732,8 @@ void NullOpenGLGraphics::calcTileCollection(ImageCollection *const vertCol,
void NullOpenGLGraphics::drawTileCollection(const ImageCollection
*const vertCol)
{
+ if (!vertCol)
+ return;
const ImageVertexesVector &draws = vertCol->draws;
const ImageCollectionCIter it_end = draws.end();
for (ImageCollectionCIter it = draws.begin(); it != it_end; ++ it)
@@ -746,6 +756,8 @@ void NullOpenGLGraphics::calcPattern(ImageCollection* const vertCol,
const int x, const int y,
const int w, const int h) const
{
+ if (!vertCol || !image)
+ return;
ImageVertexes *vert = nullptr;
if (vertCol->currentGLImage != image->mGLImage)
{
@@ -903,6 +915,8 @@ void NullOpenGLGraphics::calcWindow(ImageCollection *const vertCol,
const int w, const int h,
const ImageRect &imgRect)
{
+ if (!vertCol)
+ return;
ImageVertexes *vert = nullptr;
Image *const image = imgRect.grid[4];
if (!image)
diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp
index 191a95531..eadd794b8 100644
--- a/src/render/safeopenglgraphics.cpp
+++ b/src/render/safeopenglgraphics.cpp
@@ -74,6 +74,11 @@ bool SafeOpenGLGraphics::setVideoMode(const int w, const int h,
static inline void drawQuad(const Image *image,
const int srcX, const int srcY,
const int dstX, const int dstY,
+ const int width, const int height) A_NONNULL(1);
+
+static inline void drawQuad(const Image *image,
+ const int srcX, const int srcY,
+ const int dstX, const int dstY,
const int width, const int height)
{
if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
@@ -113,6 +118,13 @@ static inline void drawRescaledQuad(const Image *const image,
const int dstX, const int dstY,
const int width, const int height,
const int desiredWidth,
+ const int desiredHeight) A_NONNULL(1);
+
+static inline void drawRescaledQuad(const Image *const image,
+ const int srcX, const int srcY,
+ const int dstX, const int dstY,
+ const int width, const int height,
+ const int desiredWidth,
const int desiredHeight)
{
if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
diff --git a/src/render/sdl2graphics.cpp b/src/render/sdl2graphics.cpp
index c9f661d30..3b631caa5 100644
--- a/src/render/sdl2graphics.cpp
+++ b/src/render/sdl2graphics.cpp
@@ -542,6 +542,8 @@ void SDLGraphics::calcTileCollection(ImageCollection *const vertCol,
const Image *const image,
int x, int y)
{
+ if (!vertCol)
+ return;
if (vertCol->currentImage != image)
{
ImageVertexes *const vert = new ImageVertexes();
@@ -560,6 +562,8 @@ void SDLGraphics::calcTileCollection(ImageCollection *const vertCol,
void SDLGraphics::drawTileCollection(const ImageCollection
*const vertCol)
{
+ if (!vertCol)
+ return;
const ImageVertexesVector &draws = vertCol->draws;
const ImageCollectionCIter it_end = draws.end();
for (ImageCollectionCIter it = draws.begin(); it != it_end; ++ it)
@@ -580,6 +584,8 @@ void SDLGraphics::drawTileCollection(const ImageCollection
void SDLGraphics::drawTileVertexes(const ImageVertexes *const vert)
{
+ if (!vert)
+ return;
// vert and img must be != 0
const Image *const img = vert->image;
const DoubleRects *const rects = &vert->sdl;
diff --git a/src/render/sdl2softwaregraphics.cpp b/src/render/sdl2softwaregraphics.cpp
index 1c0958e6e..f7e5b9ee1 100644
--- a/src/render/sdl2softwaregraphics.cpp
+++ b/src/render/sdl2softwaregraphics.cpp
@@ -727,6 +727,8 @@ void SDL2SoftwareGraphics::calcTileCollection(ImageCollection *const vertCol,
const Image *const image,
int x, int y)
{
+ if (!vertCol)
+ return;
if (vertCol->currentImage != image)
{
ImageVertexes *const vert = new ImageVertexes();
@@ -745,6 +747,8 @@ void SDL2SoftwareGraphics::calcTileCollection(ImageCollection *const vertCol,
void SDL2SoftwareGraphics::drawTileCollection(const ImageCollection
*const vertCol)
{
+ if (!vertCol)
+ return;
const ImageVertexesVector &draws = vertCol->draws;
const ImageCollectionCIter it_end = draws.end();
for (ImageCollectionCIter it = draws.begin(); it != it_end; ++ it)
@@ -765,6 +769,8 @@ void SDL2SoftwareGraphics::drawTileCollection(const ImageCollection
void SDL2SoftwareGraphics::drawTileVertexes(const ImageVertexes *const vert)
{
+ if (!vert)
+ return;
// vert and img must be != 0
const Image *const img = vert->image;
const DoubleRects *const rects = &vert->sdl;
diff --git a/src/render/sdlgraphics.cpp b/src/render/sdlgraphics.cpp
index a82f85621..db2d15ae4 100644
--- a/src/render/sdlgraphics.cpp
+++ b/src/render/sdlgraphics.cpp
@@ -646,6 +646,9 @@ void SDLGraphics::calcPattern(ImageCollection* const vertCol,
const int x, const int y,
const int w, const int h) const
{
+ if (!vertCol || !image)
+ return;
+
ImageVertexes *vert = nullptr;
if (vertCol->currentImage != image)
{
@@ -667,6 +670,8 @@ void SDLGraphics::calcTileVertexes(ImageVertexes *const vert,
const Image *const image,
int x, int y) const
{
+ if (!vert || !image)
+ return;
vert->image = image;
calcTileSDL(vert, x, y);
}
@@ -675,6 +680,8 @@ void SDLGraphics::calcTileVertexesInline(ImageVertexes *const vert,
const Image *const image,
int x, int y) const
{
+ if (!vert || !image)
+ return;
vert->image = image;
calcTileSDL(vert, x, y);
}
@@ -711,6 +718,8 @@ void SDLGraphics::calcTileCollection(ImageCollection *const vertCol,
const Image *const image,
int x, int y)
{
+ if (!vertCol)
+ return;
if (vertCol->currentImage != image)
{
ImageVertexes *const vert = new ImageVertexes();
@@ -729,6 +738,8 @@ void SDLGraphics::calcTileCollection(ImageCollection *const vertCol,
void SDLGraphics::drawTileCollection(const ImageCollection
*const vertCol)
{
+ if (!vertCol)
+ return;
const ImageVertexesVector &draws = vertCol->draws;
const ImageCollectionCIter it_end = draws.end();
for (ImageCollectionCIter it = draws.begin(); it != it_end; ++ it)
@@ -749,6 +760,8 @@ void SDLGraphics::drawTileCollection(const ImageCollection
void SDLGraphics::drawTileVertexes(const ImageVertexes *const vert)
{
+ if (!vert)
+ return;
// vert and img must be != 0
const Image *const img = vert->image;
const DoubleRects *const rects = &vert->sdl;
@@ -803,6 +816,9 @@ void SDLGraphics::calcWindow(ImageCollection *const vertCol,
const int w, const int h,
const ImageRect &imgRect)
{
+ if (!vertCol)
+ return;
+
ImageVertexes *vert = nullptr;
Image *const image = imgRect.grid[4];
if (vertCol->currentImage != image)