diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-03-10 00:25:58 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-03-10 00:31:05 +0300 |
commit | df7306b25899f3fafa4adb969e70ea83ac567ffb (patch) | |
tree | 2ce725beb08a139852e34bf4748e96481835fcb7 /src | |
parent | bd88033a7d721102544c21d449a541ceb3bcc285 (diff) | |
download | manaverse-df7306b25899f3fafa4adb969e70ea83ac567ffb.tar.gz manaverse-df7306b25899f3fafa4adb969e70ea83ac567ffb.tar.bz2 manaverse-df7306b25899f3fafa4adb969e70ea83ac567ffb.tar.xz manaverse-df7306b25899f3fafa4adb969e70ea83ac567ffb.zip |
Remove duplicate code from renderers.
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/render/graphicsdef.hpp | 145 | ||||
-rw-r--r-- | src/render/mobileopenglgraphics.h | 51 | ||||
-rw-r--r-- | src/render/normalopenglgraphics.h | 50 | ||||
-rw-r--r-- | src/render/nullopenglgraphics.h | 51 | ||||
-rw-r--r-- | src/render/openglgraphicsdef.hpp | 144 | ||||
-rw-r--r-- | src/render/openglgraphicsdefadvanced.hpp | 38 | ||||
-rw-r--r-- | src/render/safeopenglgraphics.h | 37 | ||||
-rw-r--r-- | src/render/sdl2graphics.h | 119 | ||||
-rw-r--r-- | src/render/sdl2softwaregraphics.h | 121 | ||||
-rw-r--r-- | src/render/sdlgraphics.h | 118 | ||||
-rw-r--r-- | src/render/softwaregraphicsdef.hpp | 25 |
13 files changed, 261 insertions, 645 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index effb17201..02a7240f1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -720,11 +720,13 @@ SET(SRCS notifications.h notifymanager.cpp notifymanager.h + render/graphicsdef.hpp render/graphics_calcImageRect.hpp render/graphics_drawImageRect.hpp render/nullopenglgraphics.cpp render/nullopenglgraphics.h render/openglgraphicsdef.hpp + render/openglgraphicsdefadvanced.hpp render/renderers.cpp render/renderers.h render/rendererslistsdl.h @@ -757,6 +759,7 @@ SET(SRCS render/sdl2softwaregraphics.h render/sdlgraphics.cpp render/sdlgraphics.h + render/softwaregraphicsdef.hpp sdlshared.h shopitem.cpp shopitem.h diff --git a/src/Makefile.am b/src/Makefile.am index 5bbea38d5..8483fa994 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -62,6 +62,7 @@ dyecmd_SOURCES += dyetool/dyemain.cpp \ render/sdl2graphics.h \ render/sdlgraphics.cpp \ render/sdlgraphics.h \ + render/softwaregraphicsdef.hpp \ resources/action.cpp \ resources/action.h \ resources/animation.cpp \ @@ -799,11 +800,13 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ notifications.h \ notifymanager.cpp \ notifymanager.h \ + render/graphicsdef.hpp \ render/graphics_calcImageRect.hpp \ render/graphics_drawImageRect.hpp \ render/nullopenglgraphics.cpp \ render/nullopenglgraphics.h \ render/openglgraphicsdef.hpp \ + render/openglgraphicsdefadvanced.hpp \ render/renderers.cpp \ render/renderers.h \ render/rendererslistsdl.h \ @@ -836,6 +839,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ render/sdl2softwaregraphics.h \ render/sdlgraphics.cpp \ render/sdlgraphics.h \ + render/softwaregraphicsdef.hpp \ sdlshared.h \ shopitem.cpp \ shopitem.h \ diff --git a/src/render/graphicsdef.hpp b/src/render/graphicsdef.hpp new file mode 100644 index 000000000..bd9e80b37 --- /dev/null +++ b/src/render/graphicsdef.hpp @@ -0,0 +1,145 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +public: + /** + * Draws a rectangle using images. 4 corner images, 4 side images and 1 + * image for the inside. + */ + void drawImageRect(int x, int y, + int w, int h, + const ImageRect &imgRect); + + bool drawNet(const int x1, const int y1, + const int x2, const int y2, + const int width, const int height) override final; + + void _beginDraw(); + + void _endDraw(); + + bool pushClipArea(Rect area) override final; + + void popClipArea() override final; + + /** + * Draws a resclaled version of the image + */ + bool drawRescaledImage(const Image *const image, + int dstX, int dstY, + const int desiredWidth, + const int desiredHeight) override final; + + void drawPattern(const Image *const image, + const int x, const int y, + const int w, const int h) override final; + + void inline drawPatternInline(const Image *const image, + const int x, const int y, + const int w, const int h); + + void drawRescaledPattern(const Image *const image, + const int x, const int y, + const int w, const int h, + const int scaledWidth, + const int scaledHeight) override final; + + void calcPattern(ImageVertexes *const vert, + const Image *const image, + const int x, const int y, + const int w, const int h) const override final; + + void calcPattern(ImageCollection *const vert, + const Image *const image, + const int x, const int y, + const int w, const int h) const override final; + + void calcTileVertexes(ImageVertexes *const vert, + const Image *const image, + int x, int y) const override final; + + void calcTileCollection(ImageCollection *const vertCol, + const Image *const image, + int x, int y) override final; + + void drawTileVertexes(const ImageVertexes *const vert) override final; + + void drawTileCollection(const ImageCollection *const vertCol) override final; + + void updateScreen() override final; + + /** + * Takes a screenshot and returns it as SDL surface. + */ + SDL_Surface *getScreenshot() override final A_WARN_UNUSED; + + void calcWindow(ImageCollection *const vertCol, + const int x, const int y, + const int w, const int h, + const ImageRect &imgRect) override final; + + void drawRectangle(const Rect &rect) override final; + + void fillRectangle(const Rect &rect) override final; + + void drawPoint(int x, int y) override final; + + void drawLine(int x1, int y1, + int x2, int y2) override final; + + bool setVideoMode(const int w, const int h, + const int scalle, + const int bpp, + const bool fs, + const bool hwaccel, + const bool resize, + const bool noFrame) override final; + + bool drawImage(const Image *const image, + int dstX, int dstY) override final; + + void drawImageCached(const Image *const image, + int x, int y) override final; + + void drawPatternCached(const Image *const image, + const int x, const int y, + const int w, const int h) override final; + + void completeCache() override final; + +private: + void inline calcImageRect(ImageVertexes *const vert, + int x, int y, + int w, int h, + const ImageRect &imgRect); + + void inline calcPatternInline(ImageVertexes *const vert, + const Image *const image, + const int x, const int y, + const int w, const int h) const; + + void inline calcTileVertexesInline(ImageVertexes *const vert, + const Image *const image, + int x, int y) const; + + bool inline drawImageInline(const Image *const image, + int dstX, int dstY); diff --git a/src/render/mobileopenglgraphics.h b/src/render/mobileopenglgraphics.h index 0b9cd83e2..6161c7f29 100644 --- a/src/render/mobileopenglgraphics.h +++ b/src/render/mobileopenglgraphics.h @@ -56,8 +56,6 @@ class MobileOpenGLGraphics final : public Graphics ~MobileOpenGLGraphics(); - #include "render/openglgraphicsdef.hpp" - inline void drawTriangleArrayfs(const GLshort *const shortVertArray, const GLfloat *const floatTexArray, const int size); @@ -68,56 +66,13 @@ class MobileOpenGLGraphics final : public Graphics inline void drawLineArrays(const int size); - inline void drawVertexes(const NormalOpenGLGraphicsVertexes &ogl); - - bool drawNet(const int x1, const int y1, const int x2, const int y2, - const int width, const int height) override final; - - void initArrays() override final; - - /** - * Draws a rectangle using images. 4 corner images, 4 side images and 1 - * image for the inside. - */ - void drawImageRect(int x, int y, int w, int h, - const ImageRect &imgRect); - -#ifdef DEBUG_DRAW_CALLS - unsigned int getDrawCalls() const - { return mLastDrawCalls; } - - static unsigned int mDrawCalls; - - static unsigned int mLastDrawCalls; -#endif + #include "render/graphicsdef.hpp" - protected: - void setTexturingAndBlending(const bool enable); + #include "render/openglgraphicsdef.hpp" - void debugBindTexture(const Image *const image); + #include "render/openglgraphicsdefadvanced.hpp" private: - void inline setColorAlpha(const float alpha); - - void inline restoreColor(); - - void inline calcImageRect(ImageVertexes *const vert, - int x, int y, - int w, int h, - const ImageRect &imgRect); - - void inline calcPatternInline(ImageVertexes *const vert, - const Image *const image, - const int x, const int y, - const int w, const int h) const; - - void inline calcTileVertexesInline(ImageVertexes *const vert, - const Image *const image, - int x, int y) const; - - bool inline drawImageInline(const Image *const image, - int dstX, int dstY); - GLfloat *mFloatTexArray; GLshort *mShortVertArray; GLfloat *mFloatTexArrayCached; diff --git a/src/render/normalopenglgraphics.h b/src/render/normalopenglgraphics.h index 214954e3c..6de8d9397 100644 --- a/src/render/normalopenglgraphics.h +++ b/src/render/normalopenglgraphics.h @@ -56,8 +56,6 @@ class NormalOpenGLGraphics final : public Graphics ~NormalOpenGLGraphics(); - #include "render/openglgraphicsdef.hpp" - inline void drawQuadArrayfi(const int size); inline void drawQuadArrayfiCached(const int size); @@ -78,60 +76,18 @@ class NormalOpenGLGraphics final : public Graphics inline void drawLineArrayf(const int size); - inline void drawVertexes(const NormalOpenGLGraphicsVertexes &ogl); - - bool drawNet(const int x1, const int y1, const int x2, const int y2, - const int width, const int height) override final; - - void initArrays() override final; + #include "render/graphicsdef.hpp" - /** - * Draws a rectangle using images. 4 corner images, 4 side images and 1 - * image for the inside. - */ - void drawImageRect(int x, int y, int w, int h, - const ImageRect &imgRect); - -#ifdef DEBUG_DRAW_CALLS - unsigned int getDrawCalls() const - { return mLastDrawCalls; } + #include "render/openglgraphicsdef.hpp" - static unsigned int mDrawCalls; + #include "render/openglgraphicsdefadvanced.hpp" - static unsigned int mLastDrawCalls; -#endif #ifdef DEBUG_BIND_TEXTURE unsigned int getBinds() const { return mLastBinds; } #endif - protected: - void setTexturingAndBlending(const bool enable); - - void debugBindTexture(const Image *const image); - private: - void inline setColorAlpha(const float alpha); - - void inline restoreColor(); - - void inline calcImageRect(ImageVertexes *const vert, - int x, int y, - int w, int h, - const ImageRect &imgRect); - - void inline calcPatternInline(ImageVertexes *const vert, - const Image *const image, - const int x, const int y, - const int w, const int h) const; - - void inline calcTileVertexesInline(ImageVertexes *const vert, - const Image *const image, - int x, int y) const; - - bool inline drawImageInline(const Image *const image, - int dstX, int dstY); - GLfloat *mFloatTexArray; GLint *mIntTexArray; GLint *mIntVertArray; diff --git a/src/render/nullopenglgraphics.h b/src/render/nullopenglgraphics.h index ee2a5d189..ebecbe7dd 100644 --- a/src/render/nullopenglgraphics.h +++ b/src/render/nullopenglgraphics.h @@ -56,8 +56,6 @@ class NullOpenGLGraphics final : public Graphics ~NullOpenGLGraphics(); - #include "render/openglgraphicsdef.hpp" - inline void drawQuadArrayfi(const int size); inline void drawQuadArrayfi(const GLint *const intVertArray, @@ -74,56 +72,13 @@ class NullOpenGLGraphics final : public Graphics inline void drawLineArrayf(const int size); - inline void drawVertexes(const NormalOpenGLGraphicsVertexes &ogl); - - bool drawNet(const int x1, const int y1, const int x2, const int y2, - const int width, const int height) override final; - - void initArrays() override final; - - /** - * Draws a rectangle using images. 4 corner images, 4 side images and 1 - * image for the inside. - */ - void drawImageRect(int x, int y, int w, int h, - const ImageRect &imgRect); - -#ifdef DEBUG_DRAW_CALLS - unsigned int getDrawCalls() const - { return mLastDrawCalls; } - - static unsigned int mDrawCalls; - - static unsigned int mLastDrawCalls; -#endif + #include "render/graphicsdef.hpp" - protected: - void setTexturingAndBlending(const bool enable); + #include "render/openglgraphicsdef.hpp" - void debugBindTexture(const Image *const image); + #include "render/openglgraphicsdefadvanced.hpp" private: - void inline setColorAlpha(const float alpha); - - void inline restoreColor(); - - void inline calcImageRect(ImageVertexes *const vert, - int x, int y, - int w, int h, - const ImageRect &imgRect); - - void inline calcPatternInline(ImageVertexes* const vert, - const Image *const image, - const int x, const int y, - const int w, const int h) const; - - void inline calcTileVertexesInline(ImageVertexes *const vert, - const Image *const image, - int x, int y) const; - - bool inline drawImageInline(const Image *const image, - int dstX, int dstY); - GLfloat *mFloatTexArray; GLint *mIntTexArray; GLint *mIntVertArray; diff --git a/src/render/openglgraphicsdef.hpp b/src/render/openglgraphicsdef.hpp index 5e8e3390c..c8937717b 100644 --- a/src/render/openglgraphicsdef.hpp +++ b/src/render/openglgraphicsdef.hpp @@ -20,131 +20,43 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - bool setVideoMode(const int w, const int h, - const int scalle, - const int bpp, - const bool fs, - const bool hwaccel, - const bool resize, - const bool noFrame) override final; +public: + void setColor(const Color &color) override final + { + mColor = color; + mColor2 = color; + mColorAlpha = (color.a != 255); + } + void setColorAll(const Color &color, const Color &color2) + { + mColor = color; + mColor2 = color2; + mColorAlpha = (color.a != 255); + } - /** - * Draws a resclaled version of the image - */ - bool drawRescaledImage(const Image *const image, - int dstX, int dstY, - const int desiredWidth, - const int desiredHeight) override final; + void drawRectangle(const Rect &rect, + const bool filled); - void inline drawPatternInline(const Image *const image, - const int x, const int y, - const int w, const int h); + static void dumpSettings(); - void drawPattern(const Image *const image, - const int x, const int y, - const int w, const int h) override final; + void prepareScreenshot() override final; - /** - * Draw a pattern based on a rescaled version of the given image... - */ - void drawRescaledPattern(const Image *const image, - const int x, const int y, - const int w, const int h, - const int scaledWidth, - const int scaledHeight) override final; + int getMemoryUsage() A_WARN_UNUSED; - void calcPattern(ImageVertexes* const vert, - const Image *const image, - const int x, const int y, - const int w, const int h) const override final; + void updateTextureFormat(); - void calcPattern(ImageCollection* const vert, - const Image *const image, - const int x, const int y, - const int w, const int h) const override final; + bool isAllowScale() const override final + { return true; } - void calcTileVertexes(ImageVertexes *const vert, - const Image *const image, - int x, int y) const override final; + static void bindTexture(const GLenum target, const GLuint texture); - void calcTileCollection(ImageCollection *const vertCol, - const Image *const image, - int x, int y) override final; + static GLuint mLastImage; - void drawTileCollection(const ImageCollection *const vertCol) - override final; +protected: + void setTexturingAndBlending(const bool enable); - void drawTileVertexes(const ImageVertexes *const vert) override final; +private: + void inline setColorAlpha(const float alpha); - void calcWindow(ImageCollection *const vertCol, - const int x, const int y, - const int w, const int h, - const ImageRect &imgRect) override final; - - void updateScreen() override final; - - void _beginDraw() override final; - - void _endDraw() override final; - - bool pushClipArea(Rect area) override final; - - void popClipArea() override final; - - void setColor(const Color &color) override final - { - mColor = color; - mColor2 = color; - mColorAlpha = (color.a != 255); - } - - void setColorAll(const Color &color, const Color &color2) - { - mColor = color; - mColor2 = color2; - mColorAlpha = (color.a != 255); - } - - void drawPoint(int x, int y) override final; - - void drawLine(int x1, int y1, int x2, int y2) override final; - - void drawRectangle(const Rect &rect, - const bool filled); - - void drawRectangle(const Rect &rect) override final; - - void fillRectangle(const Rect &rect) override final; - - static void dumpSettings(); - - /** - * Takes a screenshot and returns it as SDL surface. - */ - SDL_Surface *getScreenshot() override final A_WARN_UNUSED; - - void prepareScreenshot() override final; - - int getMemoryUsage() A_WARN_UNUSED; - - void updateTextureFormat(); - - bool drawImage(const Image *const image, - int dstX, int dstY) override final; - - void drawImageCached(const Image *const image, - int x, int y) override final; - - void drawPatternCached(const Image *const image, - const int x, const int y, - const int w, const int h) override final; - - void completeCache() override final; - - bool isAllowScale() const override final - { return true; } - - static void bindTexture(const GLenum target, const GLuint texture); - - static GLuint mLastImage; + void inline restoreColor(); diff --git a/src/render/openglgraphicsdefadvanced.hpp b/src/render/openglgraphicsdefadvanced.hpp new file mode 100644 index 000000000..07c706af3 --- /dev/null +++ b/src/render/openglgraphicsdefadvanced.hpp @@ -0,0 +1,38 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +public: + inline void drawVertexes(const NormalOpenGLGraphicsVertexes &ogl); + + void initArrays() override final; + +#ifdef DEBUG_DRAW_CALLS + unsigned int getDrawCalls() const + { return mLastDrawCalls; } + + static unsigned int mDrawCalls; + + static unsigned int mLastDrawCalls; +#endif + +protected: + void debugBindTexture(const Image *const image); diff --git a/src/render/safeopenglgraphics.h b/src/render/safeopenglgraphics.h index fbb156c6c..80a10a5eb 100644 --- a/src/render/safeopenglgraphics.h +++ b/src/render/safeopenglgraphics.h @@ -50,44 +50,11 @@ class SafeOpenGLGraphics final : public Graphics ~SafeOpenGLGraphics(); - #include "render/openglgraphicsdef.hpp" - - /** - * Draws a rectangle using images. 4 corner images, 4 side images and 1 - * image for the inside. - */ - void drawImageRect(int x, int y, int w, int h, - const ImageRect &imgRect); - - bool drawNet(const int x1, const int y1, - const int x2, const int y2, - const int width, const int height) override final; + #include "render/graphicsdef.hpp" - protected: - void setTexturingAndBlending(const bool enable); + #include "render/openglgraphicsdef.hpp" private: - void inline setColorAlpha(const float alpha); - - void inline restoreColor(); - - void inline calcImageRect(ImageVertexes *const vert, - int x, int y, - int w, int h, - const ImageRect &imgRect); - - void calcPatternInline(ImageVertexes *const vert, - const Image *const image, - const int x, const int y, - const int w, const int h) const; - - void inline calcTileVertexesInline(ImageVertexes *const vert, - const Image *const image, - int x, int y) const; - - bool inline drawImageInline(const Image *const image, - int dstX, int dstY); - bool mTexture; bool mIsByteColor; Color mByteColor; diff --git a/src/render/sdl2graphics.h b/src/render/sdl2graphics.h index 9f604d9b5..9d341aca8 100644 --- a/src/render/sdl2graphics.h +++ b/src/render/sdl2graphics.h @@ -97,132 +97,17 @@ class SDLGraphics final : public Graphics */ ~SDLGraphics(); - void _beginDraw() override final; - - void _endDraw() override final; - - bool pushClipArea(Rect rect) override final; - - void popClipArea() override final; - - bool drawRescaledImage(const Image *const image, - int dstX, int dstY, - const int desiredWidth, - const int desiredHeight) override final; - - void drawPattern(const Image *const image, - const int x, const int y, - const int w, const int h) override final; - - void inline drawPatternInline(const Image *const image, - const int x, const int y, - const int w, const int h); - - void drawRescaledPattern(const Image *const image, - const int x, const int y, - const int w, const int h, - const int scaledWidth, - const int scaledHeight) override final; - - void calcPattern(ImageVertexes *const vert, - const Image *const image, - const int x, const int y, - const int w, const int h) const override final; - - void calcPattern(ImageCollection *const vert, - const Image *const image, - const int x, const int y, - const int w, const int h) const override final; - - void calcTileVertexes(ImageVertexes *const vert, - const Image *const image, - int x, int y) const override final; - - void calcTileSDL(ImageVertexes *const vert, - int x, int y) const override final; - - void calcTileCollection(ImageCollection *const vertCol, - const Image *const image, - int x, int y) override final; - - void drawTileVertexes(const ImageVertexes *const vert) override final; - - void drawTileCollection(const ImageCollection *const vertCol) - override final; - - void updateScreen() override final; - - SDL_Surface *getScreenshot() override final A_WARN_UNUSED; - - bool drawNet(const int x1, const int y1, - const int x2, const int y2, - const int width, const int height) override final; - - void calcWindow(ImageCollection *const vertCol, - const int x, const int y, - const int w, const int h, - const ImageRect &imgRect) override final; - - void fillRectangle(const Rect &rect) override final; - - void drawRectangle(const Rect &rect) override final; - - void drawPoint(int x, int y) override final; - - void drawLine(int x1, int y1, int x2, int y2) override final; - - bool setVideoMode(const int w, const int h, - const int scale, - const int bpp, - const bool fs, - const bool hwaccel, - const bool resize, - const bool noFrame) override final; - void setRendererFlags(const uint32_t flags) { mRendererFlags = flags; } - bool drawImage(const Image *const image, - int dstX, int dstY) override final; - - void drawImageCached(const Image *const image, - int x, int y) override final; + #include "render/graphicsdef.hpp" - void drawPatternCached(const Image *const image, - const int x, const int y, - const int w, const int h) override final; - - void completeCache() override final; - - /** - * Draws a rectangle using images. 4 corner images, 4 side images and 1 - * image for the inside. - */ - void drawImageRect(int x, int y, int w, int h, - const ImageRect &imgRect); + #include "render/softwaregraphicsdef.hpp" protected: uint32_t mRendererFlags; uint32_t mOldPixel; unsigned int mOldAlpha; - - private: - void inline calcImageRect(ImageVertexes *const vert, - int x, int y, - int w, int h, - const ImageRect &imgRect); - - void inline calcPatternInline(ImageVertexes *const vert, - const Image *const image, - const int x, const int y, - const int w, const int h) const; - - void inline calcTileVertexesInline(ImageVertexes *const vert, - const Image *const image, - int x, int y) const; - - bool inline drawImageInline(const Image *const image, - int dstX, int dstY); }; #endif // USE_SDL2 diff --git a/src/render/sdl2softwaregraphics.h b/src/render/sdl2softwaregraphics.h index 6ef750dbd..caf8517be 100644 --- a/src/render/sdl2softwaregraphics.h +++ b/src/render/sdl2softwaregraphics.h @@ -54,111 +54,14 @@ class SDL2SoftwareGraphics final : public Graphics */ ~SDL2SoftwareGraphics(); - void _beginDraw(); - - void _endDraw(); - - bool pushClipArea(Rect rect); - - void popClipArea(); - - bool drawRescaledImage(const Image *const image, - int dstX, int dstY, - const int desiredWidth, - const int desiredHeight) override final; - - void drawPattern(const Image *const image, - const int x, const int y, - const int w, const int h) override final; - - void inline drawPatternInline(const Image *const image, - const int x, const int y, - const int w, const int h); - - void drawRescaledPattern(const Image *const image, - const int x, const int y, - const int w, const int h, - const int scaledWidth, - const int scaledHeight) override final; - - void calcPattern(ImageVertexes *const vert, - const Image *const image, - const int x, const int y, - const int w, const int h) const override final; - - void calcPattern(ImageCollection *const vert, - const Image *const image, - const int x, const int y, - const int w, const int h) const override final; - - void calcTileVertexes(ImageVertexes *const vert, - const Image *const image, - int x, int y) const override final; - - void calcTileSDL(ImageVertexes *const vert, - int x, int y) const override final; - - void calcTileCollection(ImageCollection *const vertCol, - const Image *const image, - int x, int y) override final; - - void drawTileVertexes(const ImageVertexes *const vert) override final; - - void drawTileCollection(const ImageCollection *const vertCol) - override final; - - void updateScreen() override final; - - SDL_Surface *getScreenshot() override final A_WARN_UNUSED; - - bool drawNet(const int x1, const int y1, - const int x2, const int y2, - const int width, const int height) override final; - - void calcWindow(ImageCollection *const vertCol, - const int x, const int y, - const int w, const int h, - const ImageRect &imgRect) override final; - - void fillRectangle(const Rect &rect) override final; - - void drawRectangle(const Rect &rect) override final; - - void drawPoint(int x, int y) override final; - - void drawLine(int x1, int y1, int x2, int y2) override final; - - bool setVideoMode(const int w, const int h, - const int scale, - const int bpp, - const bool fs, - const bool hwaccel, - const bool resize, - const bool noFrame) override final; - void setRendererFlags(const uint32_t flags) override final { mRendererFlags = flags; } - bool resizeScreen(const int width, const int height) override final; - - bool drawImage(const Image *const image, - int dstX, int dstY) override final; - - void drawImageCached(const Image *const image, - int x, int y) override final; + #include "render/graphicsdef.hpp" - void drawPatternCached(const Image *const image, - const int x, const int y, - const int w, const int h) override final; + #include "render/softwaregraphicsdef.hpp" - void completeCache() override final; - - /** - * Draws a rectangle using images. 4 corner images, 4 side images and 1 - * image for the inside. - */ - void drawImageRect(int x, int y, int w, int h, - const ImageRect &imgRect); + bool resizeScreen(const int width, const int height) override final; protected: int SDL_FakeUpperBlit(const SDL_Surface *const src, @@ -174,24 +77,6 @@ class SDL2SoftwareGraphics final : public Graphics SDL_Surface *mSurface; uint32_t mOldPixel; unsigned int mOldAlpha; - - private: - void inline calcImageRect(ImageVertexes *const vert, - const int x, const int y, - const int w, const int h, - const ImageRect &imgRect); - - void inline calcPatternInline(ImageVertexes *const vert, - const Image *const image, - const int x, const int y, - const int w, const int h) const; - - void inline calcTileVertexesInline(ImageVertexes *const vert, - const Image *const image, - int x, int y) const; - - bool inline drawImageInline(const Image *const image, - int dstX, int dstY); }; #endif // USE_SDL2 diff --git a/src/render/sdlgraphics.h b/src/render/sdlgraphics.h index 170c0010b..9d023e199 100644 --- a/src/render/sdlgraphics.h +++ b/src/render/sdlgraphics.h @@ -54,106 +54,9 @@ class SDLGraphics final : public Graphics */ ~SDLGraphics(); - void _beginDraw() override final; + #include "render/graphicsdef.hpp" - void _endDraw() override final; - - bool pushClipArea(Rect rect) override final; - - void popClipArea() override final; - - bool drawRescaledImage(const Image *const image, - int dstX, int dstY, - const int desiredWidth, - const int desiredHeight) override final; - - void drawPattern(const Image *const image, - const int x, const int y, - const int w, const int h) override final; - - void inline drawPatternInline(const Image *const image, - const int x, const int y, - const int w, const int h); - - void drawRescaledPattern(const Image *const image, - const int x, const int y, - const int w, const int h, - const int scaledWidth, - const int scaledHeight) override final; - - void calcPattern(ImageVertexes *const vert, - const Image *const image, - const int x, const int y, - const int w, const int h) const override final; - - void calcPattern(ImageCollection *const vert, - const Image *const image, - const int x, const int y, - const int w, const int h) const override final; - - void calcTileVertexes(ImageVertexes *const vert, - const Image *const image, - int x, int y) const override final; - - void calcTileSDL(ImageVertexes *const vert, - int x, int y) const override final; - - void calcTileCollection(ImageCollection *const vertCol, - const Image *const image, - int x, int y) override final; - - void drawTileVertexes(const ImageVertexes *const vert) override final; - - void drawTileCollection(const ImageCollection *const vertCol) - override final; - - void updateScreen() override final; - - SDL_Surface *getScreenshot() override final A_WARN_UNUSED; - - bool drawNet(const int x1, const int y1, - const int x2, const int y2, - const int width, const int height) override final; - - void calcWindow(ImageCollection *const vertCol, - const int x, const int y, - const int w, const int h, - const ImageRect &imgRect) override final; - - void fillRectangle(const Rect &rect) override final; - - void drawRectangle(const Rect &rect) override final; - - void drawPoint(int x, int y) override final; - - void drawLine(int x1, int y1, int x2, int y2) override final; - - bool setVideoMode(const int w, const int h, - const int scale, - const int bpp, - const bool fs, - const bool hwaccel, - const bool resize, - const bool noFrame) override final; - - bool drawImage(const Image *const image, - int dstX, int dstY) override final; - - void drawImageCached(const Image *const image, - int x, int y) override final; - - void drawPatternCached(const Image *const image, - const int x, const int y, - const int w, const int h) override final; - - void completeCache() override final; - - /** - * Draws a rectangle using images. 4 corner images, 4 side images and 1 - * image for the inside. - */ - void drawImageRect(int x, int y, int w, int h, - const ImageRect &imgRect); + #include "render/softwaregraphicsdef.hpp" protected: int SDL_FakeUpperBlit(const SDL_Surface *const src, @@ -167,23 +70,6 @@ class SDLGraphics final : public Graphics uint32_t mOldPixel; unsigned int mOldAlpha; - - private: - void inline calcImageRect(ImageVertexes *const vert, - int x, int y, - int w, int h, - const ImageRect &imgRect); - - void inline calcPatternInline(ImageVertexes *const vert, - const Image *const image, - const int x, const int y, - const int w, const int h) const; - - void inline calcTileVertexesInline(ImageVertexes *const vert, - const Image *const image, - int x, int y) const; - bool inline drawImageInline(const Image *const image, - int dstX, int dstY); }; #endif // USE_SDL2 diff --git a/src/render/softwaregraphicsdef.hpp b/src/render/softwaregraphicsdef.hpp new file mode 100644 index 000000000..db0014635 --- /dev/null +++ b/src/render/softwaregraphicsdef.hpp @@ -0,0 +1,25 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +public: + void calcTileSDL(ImageVertexes *const vert, + int x, int y) const override final; |