From bcd99fe009fb7d8b14ca4a711befa7f156b29ae7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 6 May 2012 01:17:00 +0300 Subject: Add const to images in drawing functions. --- src/graphics.cpp | 8 ++++---- src/graphics.h | 11 ++++++----- src/guichan/graphics.cpp | 1 + src/opengl1graphics.cpp | 6 +++--- src/opengl1graphics.h | 4 ++-- src/openglgraphics.cpp | 10 ++++++---- src/openglgraphics.h | 6 +++--- 7 files changed, 25 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/graphics.cpp b/src/graphics.cpp index f72e495c6..193d3b271 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -351,7 +351,7 @@ int Graphics::getHeight() const return mHeight; } -bool Graphics::drawImage(Image *image, int x, int y) +bool Graphics::drawImage(const Image *image, int x, int y) { if (image) { @@ -408,7 +408,7 @@ bool Graphics::drawRescaledImage(Image *image, int srcX, int srcY, return returnValue; } -bool Graphics::drawImage(Image *image, int srcX, int srcY, int dstX, int dstY, +bool Graphics::drawImage(const Image *image, int srcX, int srcY, int dstX, int dstY, int width, int height, bool) { // Check that preconditions for blitting are met. @@ -442,7 +442,7 @@ bool Graphics::drawImage(Image *image, int srcX, int srcY, int dstX, int dstY, } } -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) { // Check that preconditions for blitting are met. if (!mTarget || !image) @@ -639,7 +639,7 @@ void Graphics::drawImageRect2(GraphicsVertexes* vert, const ImageRect &imgRect) } } -void Graphics::drawImagePattern2(GraphicsVertexes *vert, Image *img) +void Graphics::drawImagePattern2(GraphicsVertexes *vert, const Image *img) { // here not checking input parameters diff --git a/src/graphics.h b/src/graphics.h index 805b3a02f..5c3111e0a 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -115,7 +115,7 @@ class Graphics : public gcn::SDLGraphics * @return true if the image was blitted properly * false otherwise. */ - bool drawImage(Image *image, int x, int y); + bool drawImage(const Image *image, int x, int y); /** * Draws a resclaled version of the image @@ -147,13 +147,13 @@ class Graphics : public gcn::SDLGraphics * @return true if the image was blitted properly * false otherwise. */ - virtual bool drawImage(Image *image, + virtual bool drawImage(const Image *image, int srcX, int srcY, int dstX, int dstY, int width, int height, - bool useColor = false); + bool useColor); - virtual void drawImagePattern(Image *image, + virtual void drawImagePattern(const Image *image, int x, int y, int w, int h); @@ -202,7 +202,8 @@ class Graphics : public gcn::SDLGraphics virtual void drawImageRect2(GraphicsVertexes* vert, const ImageRect &imgRect); - virtual void drawImagePattern2(GraphicsVertexes *vert, Image *img); + virtual void drawImagePattern2(GraphicsVertexes *vert, + const Image *img); bool calcWindow(GraphicsVertexes* vert, int x, int y, int w, int h, diff --git a/src/guichan/graphics.cpp b/src/guichan/graphics.cpp index 1c99d899e..1f6cb8a64 100644 --- a/src/guichan/graphics.cpp +++ b/src/guichan/graphics.cpp @@ -145,6 +145,7 @@ namespace gcn void Graphics::drawImage(const Image* image A_UNUSED, int dstX A_UNUSED, int dstY A_UNUSED) { + throw GCN_EXCEPTION("Not implimented."); } void Graphics::setFont(Font* font) diff --git a/src/opengl1graphics.cpp b/src/opengl1graphics.cpp index 33eabc236..dd39adb8b 100644 --- a/src/opengl1graphics.cpp +++ b/src/opengl1graphics.cpp @@ -71,7 +71,7 @@ bool OpenGL1Graphics::setVideoMode(int w, int h, int bpp, bool fs, return setOpenGLMode(); } -static inline void drawQuad(Image *image, +static inline void drawQuad(const Image *image, int srcX, int srcY, int dstX, int dstY, int width, int height) { @@ -148,7 +148,7 @@ static inline void drawRescaledQuad(Image *image, int srcX, int srcY, } -bool OpenGL1Graphics::drawImage(Image *image, int srcX, int srcY, +bool OpenGL1Graphics::drawImage(const Image *image, int srcX, int srcY, int dstX, int dstY, int width, int height, bool useColor) { @@ -259,7 +259,7 @@ bool OpenGL1Graphics::drawRescaledImage(Image *image, int srcX, int srcY, /* Optimising the functions that Graphics::drawImagePattern would call, * so that glBegin...glEnd are outside the main loop. */ -void OpenGL1Graphics::drawImagePattern(Image *image, int x, int y, +void OpenGL1Graphics::drawImagePattern(const Image *image, int x, int y, int w, int h) { if (!image) diff --git a/src/opengl1graphics.h b/src/opengl1graphics.h index 5a2d6c254..113b4b8a7 100644 --- a/src/opengl1graphics.h +++ b/src/opengl1graphics.h @@ -53,7 +53,7 @@ class OpenGL1Graphics : public Graphics bool setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel, bool resize, bool noFrame); - bool drawImage(Image *image, + bool drawImage(const Image *image, int srcX, int srcY, int dstX, int dstY, int width, int height, @@ -77,7 +77,7 @@ class OpenGL1Graphics : public Graphics int desiredWidth, int desiredHeight, bool useColor, bool smooth); - void drawImagePattern(Image *image, + void drawImagePattern(const Image *image, int x, int y, int w, int h); diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp index bf7967254..02e14b77e 100644 --- a/src/openglgraphics.cpp +++ b/src/openglgraphics.cpp @@ -81,7 +81,7 @@ bool OpenGLGraphics::setVideoMode(int w, int h, int bpp, bool fs, return setOpenGLMode(); } -static inline void drawQuad(Image *image, +static inline void drawQuad(const Image *image, int srcX, int srcY, int dstX, int dstY, int width, int height) { @@ -205,7 +205,7 @@ static inline void drawRescaledQuad(Image *image, } -bool OpenGLGraphics::drawImage(Image *image, int srcX, int srcY, +bool OpenGLGraphics::drawImage(const Image *image, int srcX, int srcY, int dstX, int dstY, int width, int height, bool useColor) { @@ -308,7 +308,8 @@ bool OpenGLGraphics::drawRescaledImage(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; @@ -592,7 +593,8 @@ void OpenGLGraphics::drawRescaledImagePattern(Image *image, static_cast(mColor.a)); } -void OpenGLGraphics::drawImagePattern2(GraphicsVertexes *vert, Image *image) +void OpenGLGraphics::drawImagePattern2(GraphicsVertexes *vert, + const Image *image) { if (!image) return; diff --git a/src/openglgraphics.h b/src/openglgraphics.h index 944b8c917..8d90ec72a 100644 --- a/src/openglgraphics.h +++ b/src/openglgraphics.h @@ -55,7 +55,7 @@ class OpenGLGraphics : public Graphics bool setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel, bool resize, bool noFrame); - bool drawImage(Image *image, + bool drawImage(const Image *image, int srcX, int srcY, int dstX, int dstY, int width, int height, @@ -79,7 +79,7 @@ class OpenGLGraphics : public Graphics int desiredWidth, int desiredHeight, bool useColor, bool smooth); - void drawImagePattern(Image *image, + void drawImagePattern(const Image *image, int x, int y, int w, int h); @@ -97,7 +97,7 @@ class OpenGLGraphics : public Graphics void drawTile(ImageVertexes *vert); - void drawImagePattern2(GraphicsVertexes *vert, Image *image); + void drawImagePattern2(GraphicsVertexes *vert, const Image *image); void updateScreen(); -- cgit v1.2.3-70-g09d2