From df7306b25899f3fafa4adb969e70ea83ac567ffb Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 10 Mar 2014 00:25:58 +0300 Subject: Remove duplicate code from renderers. --- src/render/graphicsdef.hpp | 145 +++++++++++++++++++++++++++++++ src/render/mobileopenglgraphics.h | 51 +---------- src/render/normalopenglgraphics.h | 50 +---------- src/render/nullopenglgraphics.h | 51 +---------- src/render/openglgraphicsdef.hpp | 144 ++++++------------------------ src/render/openglgraphicsdefadvanced.hpp | 38 ++++++++ src/render/safeopenglgraphics.h | 37 +------- src/render/sdl2graphics.h | 119 +------------------------ src/render/sdl2softwaregraphics.h | 121 +------------------------- src/render/sdlgraphics.h | 118 +------------------------ src/render/softwaregraphicsdef.hpp | 25 ++++++ 11 files changed, 254 insertions(+), 645 deletions(-) create mode 100644 src/render/graphicsdef.hpp create mode 100644 src/render/openglgraphicsdefadvanced.hpp create mode 100644 src/render/softwaregraphicsdef.hpp (limited to 'src/render') 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 . + */ + +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 . */ - 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 . + */ + +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 . + */ + +public: + void calcTileSDL(ImageVertexes *const vert, + int x, int y) const override final; -- cgit v1.2.3-70-g09d2