diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-04-09 14:45:27 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-10-18 08:21:32 +0000 |
commit | eb206d0a5a9b8d73b103c094e376c5e13cd4c218 (patch) | |
tree | 22b91f5bfd466e1894194822dfbef79550a6b0ef /src | |
parent | e7790891cf0bd6211b71d084044324a6e95573d8 (diff) | |
download | mana-eb206d0a5a9b8d73b103c094e376c5e13cd4c218.tar.gz mana-eb206d0a5a9b8d73b103c094e376c5e13cd4c218.tar.bz2 mana-eb206d0a5a9b8d73b103c094e376c5e13cd4c218.tar.xz mana-eb206d0a5a9b8d73b103c094e376c5e13cd4c218.zip |
Take only const pointers to images in Graphics
Helps making sure we're not modifying the images in the rendering code.
Re-applies 4eea727b7649726670d8963d11ab4fd429624b3e (and reverts
363f71157a8107190b3bd2ba656faf0a0e63ab36).
Diffstat (limited to 'src')
-rw-r--r-- | src/graphics.cpp | 22 | ||||
-rw-r--r-- | src/graphics.h | 26 | ||||
-rw-r--r-- | src/openglgraphics.cpp | 18 | ||||
-rw-r--r-- | src/openglgraphics.h | 8 | ||||
-rw-r--r-- | src/sdlgraphics.cpp | 6 | ||||
-rw-r--r-- | src/sdlgraphics.h | 6 |
6 files changed, 43 insertions, 43 deletions
diff --git a/src/graphics.cpp b/src/graphics.cpp index 13089b0c..afdac4f6 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -39,7 +39,7 @@ void Graphics::updateSize(int width, int height, float /*scale*/) mHeight = height; } -bool Graphics::drawImage(Image *image, int x, int y) +bool Graphics::drawImage(const Image *image, int x, int y) { if (!image) return false; @@ -47,7 +47,7 @@ bool Graphics::drawImage(Image *image, int x, int y) return drawImage(image, 0, 0, x, y, image->getWidth(), image->getHeight()); } -bool Graphics::drawImageF(Image *image, float x, float y) +bool Graphics::drawImageF(const Image *image, float x, float y) { if (!image) return false; @@ -55,7 +55,7 @@ bool Graphics::drawImageF(Image *image, float x, float y) return drawImageF(image, 0, 0, x, y, image->getWidth(), image->getHeight()); } -bool Graphics::drawRescaledImageF(Image *image, int srcX, int srcY, float dstX, float dstY, int width, int height, float desiredWidth, float desiredHeight, bool useColor) +bool Graphics::drawRescaledImageF(const Image *image, int srcX, int srcY, float dstX, float dstY, int width, int height, float desiredWidth, float desiredHeight, bool useColor) { return drawRescaledImage(image, srcX, srcY, @@ -67,7 +67,7 @@ bool Graphics::drawRescaledImageF(Image *image, int srcX, int srcY, float dstX, useColor); } -bool Graphics::drawImage(Image *image, +bool Graphics::drawImage(const Image *image, int srcX, int srcY, int dstX, int dstY, int width, int height, @@ -80,7 +80,7 @@ bool Graphics::drawImage(Image *image, width, height, useColor); } -bool Graphics::drawImageF(Image *image, int srcX, int srcY, float dstX, float dstY, int width, int height, bool useColor) +bool Graphics::drawImageF(const Image *image, int srcX, int srcY, float dstX, float dstY, int width, int height, bool useColor) { return drawRescaledImageF(image, srcX, srcY, @@ -89,7 +89,7 @@ bool Graphics::drawImageF(Image *image, int srcX, int srcY, float dstX, float ds width, height, useColor); } -void Graphics::drawImagePattern(Image *image, int x, int y, int w, int h) +void Graphics::drawImagePattern(const Image *image, int x, int y, int w, int h) { if (!image) return; @@ -99,11 +99,11 @@ void Graphics::drawImagePattern(Image *image, int x, int y, int w, int h) } void Graphics::drawImageRect(int x, int y, int w, int h, - Image *topLeft, Image *topRight, - Image *bottomLeft, Image *bottomRight, - Image *top, Image *right, - Image *bottom, Image *left, - Image *center) + const Image *topLeft, const Image *topRight, + const Image *bottomLeft, const Image *bottomRight, + const Image *top, const Image *right, + const Image *bottom, const Image *left, + const Image *center) { pushClipArea(gcn::Rectangle(x, y, w, h)); diff --git a/src/graphics.h b/src/graphics.h index 55f67568..9db92034 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -93,7 +93,7 @@ class Graphics : public gcn::Graphics * @return <code>true</code> if the image was blitted properly * <code>false</code> otherwise. */ - bool drawImage(Image *image, int x, int y); + bool drawImage(const Image *image, int x, int y); /** * Blits an image onto the screen. @@ -101,12 +101,12 @@ class Graphics : public gcn::Graphics * @return <code>true</code> if the image was blitted properly * <code>false</code> otherwise. */ - bool drawImageF(Image *image, float x, float y); + bool drawImageF(const Image *image, float x, float y); /** * Draws a rescaled version of the image. */ - virtual bool drawRescaledImage(Image *image, int srcX, int srcY, + virtual bool drawRescaledImage(const Image *image, int srcX, int srcY, int dstX, int dstY, int width, int height, int desiredWidth, int desiredHeight, @@ -115,7 +115,7 @@ class Graphics : public gcn::Graphics /** * Draws a rescaled version of the image. */ - virtual bool drawRescaledImageF(Image *image, int srcX, int srcY, + virtual bool drawRescaledImageF(const Image *image, int srcX, int srcY, float dstX, float dstY, int width, int height, float desiredWidth, float desiredHeight, @@ -127,7 +127,7 @@ class Graphics : public gcn::Graphics * @return <code>true</code> if the image was blitted properly * <code>false</code> otherwise. */ - virtual bool drawImage(Image *image, + virtual bool drawImage(const Image *image, int srcX, int srcY, int dstX, int dstY, int width, int height, @@ -139,20 +139,20 @@ class Graphics : public gcn::Graphics * @return <code>true</code> if the image was blitted properly * <code>false</code> otherwise. */ - virtual bool drawImageF(Image *image, + virtual bool drawImageF(const Image *image, int srcX, int srcY, float dstX, float dstY, int width, int height, bool useColor = false); - virtual void drawImagePattern(Image *image, + virtual void drawImagePattern(const Image *image, int x, int y, int w, int h); /** * Draw a pattern based on a rescaled version of the given image... */ - virtual void drawRescaledImagePattern(Image *image, + virtual void drawRescaledImagePattern(const Image *image, int x, int y, int w, int h, int scaledWidth, @@ -163,11 +163,11 @@ class Graphics : public gcn::Graphics * image for the inside. */ void drawImageRect(int x, int y, int w, int h, - Image *topLeft, Image *topRight, - Image *bottomLeft, Image *bottomRight, - Image *top, Image *right, - Image *bottom, Image *left, - Image *center); + const Image *topLeft, const Image *topRight, + const Image *bottomLeft, const Image *bottomRight, + const Image *top, const Image *right, + const Image *bottom, const Image *left, + const Image *center); /** * Draws a rectangle using images. 4 corner images, 4 side images and 1 diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp index 56c16586..cb242ff7 100644 --- a/src/openglgraphics.cpp +++ b/src/openglgraphics.cpp @@ -154,7 +154,7 @@ void OpenGLGraphics::updateSize(int windowWidth, int windowHeight, float scale) glOrtho(0.0, (double)mWidth, (double)mHeight, 0.0, -1.0, 1.0); } -static inline void drawRescaledQuad(Image *image, +static inline void drawRescaledQuad(const Image *image, int srcX, int srcY, float dstX, float dstY, int width, int height, @@ -218,7 +218,7 @@ static inline void drawRescaledQuad(Image *image, } -bool OpenGLGraphics::drawRescaledImage(Image *image, int srcX, int srcY, +bool OpenGLGraphics::drawRescaledImage(const Image *image, int srcX, int srcY, int dstX, int dstY, int width, int height, int desiredWidth, int desiredHeight, @@ -229,7 +229,7 @@ bool OpenGLGraphics::drawRescaledImage(Image *image, int srcX, int srcY, useColor); } -bool OpenGLGraphics::drawRescaledImageF(Image *image, int srcX, int srcY, +bool OpenGLGraphics::drawRescaledImageF(const Image *image, int srcX, int srcY, float dstX, float dstY, int width, int height, float desiredWidth, float desiredHeight, @@ -263,7 +263,7 @@ bool OpenGLGraphics::drawRescaledImageF(Image *image, int srcX, int srcY, return true; } -void OpenGLGraphics::drawImagePattern(Image *image, int x, int y, int w, int h) +void OpenGLGraphics::drawImagePattern(const Image *image, int x, int y, int w, int h) { if (!image) return; @@ -394,7 +394,7 @@ void OpenGLGraphics::drawImagePattern(Image *image, int x, int y, int w, int h) static_cast<GLubyte>(mColor.a)); } -void OpenGLGraphics::drawRescaledImagePattern(Image *image, +void OpenGLGraphics::drawRescaledImagePattern(const Image *image, int x, int y, int w, int h, int scaledWidth, @@ -653,7 +653,7 @@ void OpenGLGraphics::popClipArea() glScissor(x, y, width, height); } -void OpenGLGraphics::setColor(const gcn::Color& color) +void OpenGLGraphics::setColor(const gcn::Color &color) { Graphics::setColor(color); glColor4ub(color.r, color.g, color.b, color.a); @@ -684,12 +684,12 @@ void OpenGLGraphics::drawLine(int x1, int y1, int x2, int y2) glEnd(); } -void OpenGLGraphics::drawRectangle(const gcn::Rectangle& rect) +void OpenGLGraphics::drawRectangle(const gcn::Rectangle &rect) { drawRectangle(rect, false); } -void OpenGLGraphics::fillRectangle(const gcn::Rectangle& rect) +void OpenGLGraphics::fillRectangle(const gcn::Rectangle &rect) { drawRectangle(rect, true); } @@ -732,7 +732,7 @@ void OpenGLGraphics::setTexturingAndBlending(bool enable) } } -void OpenGLGraphics::drawRectangle(const gcn::Rectangle& rect, bool filled) +void OpenGLGraphics::drawRectangle(const gcn::Rectangle &rect, bool filled) { const float offset = filled ? 0 : 0.5f; diff --git a/src/openglgraphics.h b/src/openglgraphics.h index 654a7194..7178128b 100644 --- a/src/openglgraphics.h +++ b/src/openglgraphics.h @@ -60,27 +60,27 @@ class OpenGLGraphics final : public Graphics /** * Draws a rescaled version of the image */ - bool drawRescaledImage(Image *image, int srcX, int srcY, + bool drawRescaledImage(const Image *image, int srcX, int srcY, int dstX, int dstY, int width, int height, int desiredWidth, int desiredHeight, bool useColor) override; - bool drawRescaledImageF(Image *image, + bool drawRescaledImageF(const Image *image, int srcX, int srcY, float dstX, float dstY, int width, int height, float desiredWidth, float desiredHeight, bool useColor) override; - void drawImagePattern(Image *image, + void drawImagePattern(const Image *image, int x, int y, int w, int h) override; /** * Draw a pattern based on a rescaled version of the given image... */ - void drawRescaledImagePattern(Image *image, + void drawRescaledImagePattern(const Image *image, int x, int y, int w, int h, int scaledWidth, int scaledHeight) override; diff --git a/src/sdlgraphics.cpp b/src/sdlgraphics.cpp index d3ff72e2..37643190 100644 --- a/src/sdlgraphics.cpp +++ b/src/sdlgraphics.cpp @@ -106,7 +106,7 @@ void SDLGraphics::updateSize(int windowWidth, int windowHeight, float scale) SDL_RenderSetScale(mRenderer, scaleX, scaleY); } -bool SDLGraphics::drawRescaledImage(Image *image, +bool SDLGraphics::drawRescaledImage(const Image *image, int srcX, int srcY, int dstX, int dstY, int width, int height, @@ -136,7 +136,7 @@ bool SDLGraphics::drawRescaledImage(Image *image, } #if SDL_VERSION_ATLEAST(2, 0, 10) -bool SDLGraphics::drawRescaledImageF(Image *image, +bool SDLGraphics::drawRescaledImageF(const Image *image, int srcX, int srcY, float dstX, float dstY, int width, int height, @@ -166,7 +166,7 @@ bool SDLGraphics::drawRescaledImageF(Image *image, } #endif -void SDLGraphics::drawRescaledImagePattern(Image *image, +void SDLGraphics::drawRescaledImagePattern(const Image *image, int x, int y, int w, int h, int scaledWidth, diff --git a/src/sdlgraphics.h b/src/sdlgraphics.h index 3ed31ca3..e2d9b5a5 100644 --- a/src/sdlgraphics.h +++ b/src/sdlgraphics.h @@ -41,7 +41,7 @@ public: void updateSize(int windowWidth, int windowHeight, float scale) override; - bool drawRescaledImage(Image *image, + bool drawRescaledImage(const Image *image, int srcX, int srcY, int dstX, int dstY, int width, int height, @@ -49,7 +49,7 @@ public: bool useColor) override; #if SDL_VERSION_ATLEAST(2, 0, 10) - bool drawRescaledImageF(Image *image, + bool drawRescaledImageF(const Image *image, int srcX, int srcY, float dstX, float dstY, int width, int height, @@ -57,7 +57,7 @@ public: bool useColor) override; #endif - void drawRescaledImagePattern(Image *image, + void drawRescaledImagePattern(const Image *image, int x, int y, int w, int h, int scaledWidth, |