diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-12-30 20:04:35 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-12-30 20:05:30 +0300 |
commit | bbed1413d3ea2ef67f7fd7db146c372a7181ad43 (patch) | |
tree | bcfd0e1802df442df157d829e9fc3490877ceb0f /src | |
parent | e29a87a240fe2f33c51f4e15067122960f667d66 (diff) | |
download | ManaVerse-bbed1413d3ea2ef67f7fd7db146c372a7181ad43.tar.gz ManaVerse-bbed1413d3ea2ef67f7fd7db146c372a7181ad43.tar.bz2 ManaVerse-bbed1413d3ea2ef67f7fd7db146c372a7181ad43.tar.xz ManaVerse-bbed1413d3ea2ef67f7fd7db146c372a7181ad43.zip |
add calcImageRect into each renderer. but copy function body to shared file.
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/render/graphics.cpp | 70 | ||||
-rw-r--r-- | src/render/graphics.h | 7 | ||||
-rw-r--r-- | src/render/mobileopenglgraphics.cpp | 13 | ||||
-rw-r--r-- | src/render/mobileopenglgraphics.h | 5 | ||||
-rw-r--r-- | src/render/normalopenglgraphics.cpp | 16 | ||||
-rw-r--r-- | src/render/normalopenglgraphics.h | 5 | ||||
-rw-r--r-- | src/render/nullopenglgraphics.cpp | 15 | ||||
-rw-r--r-- | src/render/nullopenglgraphics.h | 5 | ||||
-rw-r--r-- | src/render/openglgraphics_calcImageRect.hpp | 90 | ||||
-rw-r--r-- | src/render/openglgraphicsdef.hpp | 2 | ||||
-rw-r--r-- | src/render/safeopenglgraphics.cpp | 11 | ||||
-rw-r--r-- | src/render/safeopenglgraphics.h | 5 | ||||
-rw-r--r-- | src/render/sdl2graphics.cpp | 14 | ||||
-rw-r--r-- | src/render/sdl2graphics.h | 8 | ||||
-rw-r--r-- | src/render/sdl2softwaregraphics.cpp | 14 | ||||
-rw-r--r-- | src/render/sdl2softwaregraphics.h | 9 | ||||
-rw-r--r-- | src/render/sdlgraphics.cpp | 14 | ||||
-rw-r--r-- | src/render/sdlgraphics.h | 9 | ||||
-rw-r--r-- | src/render/surfacegraphics.h | 4 |
21 files changed, 210 insertions, 108 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f18a4aedd..d8d2ce6c3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -698,6 +698,7 @@ SET(SRCS notifymanager.h render/nullopenglgraphics.cpp render/nullopenglgraphics.h + render/openglgraphics_calcImageRect.hpp render/openglgraphics_drawImageRect.hpp render/openglgraphicsdef.hpp render/renderers.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 28fb3ec2a..8c05c8a2e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -835,6 +835,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ notifymanager.h \ render/nullopenglgraphics.cpp \ render/nullopenglgraphics.h \ + render/openglgraphics_calcImageRect.hpp \ render/openglgraphics_drawImageRect.hpp \ render/openglgraphicsdef.hpp \ render/renderers.cpp \ diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp index abb696bc9..7903b6431 100644 --- a/src/render/graphics.cpp +++ b/src/render/graphics.cpp @@ -452,76 +452,6 @@ bool Graphics::drawNet(const int x1, const int y1, const int x2, const int y2, return true; } -bool Graphics::calcImageRect(ImageVertexes *const vert, - const int x, const int y, - const int w, const int h, - const ImageRect &imgRect) -{ - if (!vert) - return false; - - BLOCK_START("Graphics::calcImageRect") - - const Image *const *const grid = imgRect.grid; - const Image *const topLeft = grid[0]; - const Image *const topRight = grid[2]; - const Image *const bottomLeft = grid[6]; - const Image *const bottomRight = grid[8]; - const Image *const top = grid[1]; - const Image *const right = grid[5]; - const Image *const bottom = grid[7]; - const Image *const left = grid[3]; - const Image *const center = grid[4]; - - const bool drawMain = center && topLeft && topRight - && bottomLeft && bottomRight; - - // Draw the center area - if (center && drawMain) - { - const int tlw = topLeft->getWidth(); - const int tlh = topLeft->getHeight(); - calcPattern(vert, center, tlw + x, tlh + y, - w - tlw - topRight->getWidth(), - h - tlh - bottomLeft->getHeight()); - } - // Draw the sides - if (top && left && bottom && right) - { - const int lw = left->getWidth(); - const int rw = right->getWidth(); - const int th = top->getHeight(); - const int bh = bottom->getHeight(); - calcPattern(vert, top, x + lw, y, w - lw - rw, th); - calcPattern(vert, bottom, x + lw, y + h - bh, w - lw - rw, bh); - calcPattern(vert, left, x, y + th, lw, h - th - bh); - if (w > rw) - calcPattern(vert, right, x + w - rw, y + th, rw, h - th - bh); - } - - calcTileVertexes(vert, topLeft, x, y); - if (topRight) - { - const int trw = topRight->getWidth(); - if (w > trw) - calcTileVertexes(vert, topRight, x + w - trw, y); - } - if (bottomLeft) - calcTileVertexes(vert, bottomLeft, x, y + h - bottomLeft->getHeight()); - if (bottomRight) - { - const int brw = bottomRight->getWidth(); - if (w > brw) - { - calcTileVertexes(vert, bottomRight, x + w - brw, - y + h - bottomRight->getHeight()); - } - } - - BLOCK_END("Graphics::calcImageRect") - return 0; -} - void Graphics::setWindowSize(const int width A_UNUSED, const int height A_UNUSED) { diff --git a/src/render/graphics.h b/src/render/graphics.h index 8567b4c1f..987c8f849 100644 --- a/src/render/graphics.h +++ b/src/render/graphics.h @@ -174,11 +174,6 @@ class Graphics : public gcn::Graphics const int w, const int h, const ImageRect &imgRect) = 0; - bool calcImageRect(ImageVertexes *const vert, - const int x, const int y, - const int w, const int h, - const ImageRect &imgRect); - virtual void calcPattern(ImageVertexes *const vert, const Image *const image, const int x, const int y, @@ -207,7 +202,7 @@ class Graphics : public gcn::Graphics const Image *const image, int x, int y) = 0; - virtual bool calcWindow(ImageCollection *const vertCol, + virtual void calcWindow(ImageCollection *const vertCol, const int x, const int y, const int w, const int h, const ImageRect &imgRect) = 0; diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp index d716582ef..1b57f7160 100644 --- a/src/render/mobileopenglgraphics.cpp +++ b/src/render/mobileopenglgraphics.cpp @@ -771,7 +771,7 @@ void MobileOpenGLGraphics::drawTileVertexes(const ImageVertexes *const vert) drawVertexes(vert->ogl); } -bool MobileOpenGLGraphics::calcWindow(ImageCollection *const vertCol, +void MobileOpenGLGraphics::calcWindow(ImageCollection *const vertCol, const int x, const int y, const int w, const int h, const ImageRect &imgRect) @@ -790,8 +790,7 @@ bool MobileOpenGLGraphics::calcWindow(ImageCollection *const vertCol, { vert = vertCol->currentVert; } - - return calcImageRect(vert, x, y, w, h, imgRect); + calcImageRect(vert, x, y, w, h, imgRect); } void MobileOpenGLGraphics::updateScreen() @@ -1272,6 +1271,14 @@ void MobileOpenGLGraphics::drawImageRect(const int x, const int y, #include "render/openglgraphics_drawImageRect.hpp" } +void MobileOpenGLGraphics::calcImageRect(ImageVertexes *const vert, + const int x, const int y, + const int w, const int h, + const ImageRect &imgRect) +{ + #include "render/openglgraphics_calcImageRect.hpp" +} + #ifdef DEBUG_BIND_TEXTURE void MobileOpenGLGraphics::debugBindTexture(const Image *const image) { diff --git a/src/render/mobileopenglgraphics.h b/src/render/mobileopenglgraphics.h index 08e1979f2..3bc095cda 100644 --- a/src/render/mobileopenglgraphics.h +++ b/src/render/mobileopenglgraphics.h @@ -101,6 +101,11 @@ class MobileOpenGLGraphics final : public Graphics void inline restoreColor(); + void inline calcImageRect(ImageVertexes *const vert, + int x, int y, + int w, int h, + const ImageRect &imgRect); + GLfloat *mFloatTexArray; GLshort *mShortVertArray; GLfloat *mFloatTexArrayCached; diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp index 6626564eb..e3e0d7e19 100644 --- a/src/render/normalopenglgraphics.cpp +++ b/src/render/normalopenglgraphics.cpp @@ -1024,7 +1024,7 @@ void NormalOpenGLGraphics::drawTileVertexes(const ImageVertexes *const vert) drawVertexes(vert->ogl); } -bool NormalOpenGLGraphics::calcWindow(ImageCollection *const vertCol, +void NormalOpenGLGraphics::calcWindow(ImageCollection *const vertCol, const int x, const int y, const int w, const int h, const ImageRect &imgRect) @@ -1032,7 +1032,7 @@ bool NormalOpenGLGraphics::calcWindow(ImageCollection *const vertCol, ImageVertexes *vert = nullptr; Image *const image = imgRect.grid[4]; if (!image) - return false; + return; if (vertCol->currentGLImage != image->mGLImage) { vert = new ImageVertexes(); @@ -1045,9 +1045,7 @@ bool NormalOpenGLGraphics::calcWindow(ImageCollection *const vertCol, { vert = vertCol->currentVert; } - - const Image *const *const grid = &imgRect.grid[0]; - return calcImageRect(vert, x, y, w, h, imgRect); + calcImageRect(vert, x, y, w, h, imgRect); } void NormalOpenGLGraphics::updateScreen() @@ -1559,6 +1557,14 @@ void NormalOpenGLGraphics::drawImageRect(const int x, const int y, #include "render/openglgraphics_drawImageRect.hpp" } +void NormalOpenGLGraphics::calcImageRect(ImageVertexes *const vert, + const int x, const int y, + const int w, const int h, + const ImageRect &imgRect) +{ + #include "render/openglgraphics_calcImageRect.hpp" +} + #ifdef DEBUG_BIND_TEXTURE void NormalOpenGLGraphics::debugBindTexture(const Image *const image) { diff --git a/src/render/normalopenglgraphics.h b/src/render/normalopenglgraphics.h index 62d0fffb6..b88a073c3 100644 --- a/src/render/normalopenglgraphics.h +++ b/src/render/normalopenglgraphics.h @@ -115,6 +115,11 @@ class NormalOpenGLGraphics final : public Graphics void inline restoreColor(); + void inline calcImageRect(ImageVertexes *const vert, + int x, int y, + int w, int h, + const ImageRect &imgRect); + GLfloat *mFloatTexArray; GLint *mIntTexArray; GLint *mIntVertArray; diff --git a/src/render/nullopenglgraphics.cpp b/src/render/nullopenglgraphics.cpp index 3883d7134..3a59f44bc 100644 --- a/src/render/nullopenglgraphics.cpp +++ b/src/render/nullopenglgraphics.cpp @@ -859,7 +859,7 @@ void NullOpenGLGraphics::drawTileVertexes(const ImageVertexes *const vert) drawVertexes(vert->ogl); } -bool NullOpenGLGraphics::calcWindow(ImageCollection *const vertCol, +void NullOpenGLGraphics::calcWindow(ImageCollection *const vertCol, const int x, const int y, const int w, const int h, const ImageRect &imgRect) @@ -867,7 +867,7 @@ bool NullOpenGLGraphics::calcWindow(ImageCollection *const vertCol, ImageVertexes *vert = nullptr; Image *const image = imgRect.grid[4]; if (!image) - return false; + return; if (vertCol->currentGLImage != image->mGLImage) { vert = new ImageVertexes(); @@ -880,8 +880,7 @@ bool NullOpenGLGraphics::calcWindow(ImageCollection *const vertCol, { vert = vertCol->currentVert; } - - return calcImageRect(vert, x, y, w, h, imgRect); + calcImageRect(vert, x, y, w, h, imgRect); } void NullOpenGLGraphics::updateScreen() @@ -1147,6 +1146,14 @@ void NullOpenGLGraphics::drawImageRect(const int x, const int y, #include "render/openglgraphics_drawImageRect.hpp" } +void NullOpenGLGraphics::calcImageRect(ImageVertexes *const vert, + const int x, const int y, + const int w, const int h, + const ImageRect &imgRect) +{ + #include "render/openglgraphics_calcImageRect.hpp" +} + #ifdef DEBUG_BIND_TEXTURE void NullOpenGLGraphics::debugBindTexture(const Image *const image) { diff --git a/src/render/nullopenglgraphics.h b/src/render/nullopenglgraphics.h index 35aa8d3de..bb18da05b 100644 --- a/src/render/nullopenglgraphics.h +++ b/src/render/nullopenglgraphics.h @@ -107,6 +107,11 @@ class NullOpenGLGraphics final : public Graphics void inline restoreColor(); + void inline calcImageRect(ImageVertexes *const vert, + int x, int y, + int w, int h, + const ImageRect &imgRect); + GLfloat *mFloatTexArray; GLint *mIntTexArray; GLint *mIntVertArray; diff --git a/src/render/openglgraphics_calcImageRect.hpp b/src/render/openglgraphics_calcImageRect.hpp new file mode 100644 index 000000000..403c85ba7 --- /dev/null +++ b/src/render/openglgraphics_calcImageRect.hpp @@ -0,0 +1,90 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2013 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/>. + */ + + +//bool Graphics::calcImageRect(ImageVertexes *const vert, +// const int x, const int y, +// const int w, const int h, +// const ImageRect &imgRect) + +if (!vert) + return; + +BLOCK_START("Graphics::calcImageRect") + +const Image *const *const grid = imgRect.grid; +const Image *const topLeft = grid[0]; +const Image *const topRight = grid[2]; +const Image *const bottomLeft = grid[6]; +const Image *const bottomRight = grid[8]; +const Image *const top = grid[1]; +const Image *const right = grid[5]; +const Image *const bottom = grid[7]; +const Image *const left = grid[3]; +const Image *const center = grid[4]; + +const bool drawMain = center && topLeft && topRight + && bottomLeft && bottomRight; + +// Draw the center area +if (center && drawMain) +{ + const int tlw = topLeft->getWidth(); + const int tlh = topLeft->getHeight(); + calcPattern(vert, center, tlw + x, tlh + y, + w - tlw - topRight->getWidth(), + h - tlh - bottomLeft->getHeight()); +} +// Draw the sides +if (top && left && bottom && right) +{ + const int lw = left->getWidth(); + const int rw = right->getWidth(); + const int th = top->getHeight(); + const int bh = bottom->getHeight(); + calcPattern(vert, top, x + lw, y, w - lw - rw, th); + calcPattern(vert, bottom, x + lw, y + h - bh, w - lw - rw, bh); + calcPattern(vert, left, x, y + th, lw, h - th - bh); + if (w > rw) + calcPattern(vert, right, x + w - rw, y + th, rw, h - th - bh); +} + +calcTileVertexes(vert, topLeft, x, y); +if (topRight) +{ + const int trw = topRight->getWidth(); + if (w > trw) + calcTileVertexes(vert, topRight, x + w - trw, y); +} +if (bottomLeft) + calcTileVertexes(vert, bottomLeft, x, y + h - bottomLeft->getHeight()); +if (bottomRight) +{ + const int brw = bottomRight->getWidth(); + if (w > brw) + { + calcTileVertexes(vert, bottomRight, x + w - brw, + y + h - bottomRight->getHeight()); + } +} + +BLOCK_END("Graphics::calcImageRect") diff --git a/src/render/openglgraphicsdef.hpp b/src/render/openglgraphicsdef.hpp index f935f9062..e55deaacf 100644 --- a/src/render/openglgraphicsdef.hpp +++ b/src/render/openglgraphicsdef.hpp @@ -76,7 +76,7 @@ void drawTileVertexes(const ImageVertexes *const vert) override final; - bool calcWindow(ImageCollection *const vertCol, + void calcWindow(ImageCollection *const vertCol, const int x, const int y, const int w, const int h, const ImageRect &imgRect) override final; diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp index 41d9b7f77..90dfe2e5b 100644 --- a/src/render/safeopenglgraphics.cpp +++ b/src/render/safeopenglgraphics.cpp @@ -397,12 +397,11 @@ void SafeOpenGLGraphics::updateScreen() BLOCK_END("Graphics::updateScreen") } -bool SafeOpenGLGraphics::calcWindow(ImageCollection *const vertCol A_UNUSED, +void SafeOpenGLGraphics::calcWindow(ImageCollection *const vertCol A_UNUSED, const int x A_UNUSED, const int y A_UNUSED, const int w A_UNUSED, const int h A_UNUSED, const ImageRect &imgRect A_UNUSED) { - return false; } void SafeOpenGLGraphics::_beginDraw() @@ -668,4 +667,12 @@ void SafeOpenGLGraphics::drawImageRect(const int x, const int y, #include "render/openglgraphics_drawImageRect.hpp" } +void SafeOpenGLGraphics::calcImageRect(ImageVertexes *const vert, + const int x, const int y, + const int w, const int h, + const ImageRect &imgRect) +{ + #include "render/openglgraphics_calcImageRect.hpp" +} + #endif // USE_OPENGL diff --git a/src/render/safeopenglgraphics.h b/src/render/safeopenglgraphics.h index a6a32771c..5a8d7daa4 100644 --- a/src/render/safeopenglgraphics.h +++ b/src/render/safeopenglgraphics.h @@ -67,6 +67,11 @@ class SafeOpenGLGraphics final : public Graphics void inline restoreColor(); + void inline calcImageRect(ImageVertexes *const vert, + int x, int y, + int w, int h, + const ImageRect &imgRect); + bool mTexture; bool mIsByteColor; gcn::Color mByteColor; diff --git a/src/render/sdl2graphics.cpp b/src/render/sdl2graphics.cpp index a91548416..e1b8fecbc 100644 --- a/src/render/sdl2graphics.cpp +++ b/src/render/sdl2graphics.cpp @@ -550,7 +550,7 @@ bool SDLGraphics::drawNet(const int x1, const int y1, return true; } -bool SDLGraphics::calcWindow(ImageCollection *const vertCol, +void SDLGraphics::calcWindow(ImageCollection *const vertCol, const int x, const int y, const int w, const int h, const ImageRect &imgRect) @@ -569,9 +569,7 @@ bool SDLGraphics::calcWindow(ImageCollection *const vertCol, { vert = vertCol->currentVert; } - - const Image *const *const grid = &imgRect.grid[0]; - return calcImageRect(vert, x, y, w, h, imgRect); + calcImageRect(vert, x, y, w, h, imgRect); } void SDLGraphics::fillRectangle(const gcn::Rectangle &rectangle) @@ -730,4 +728,12 @@ void SDLGraphics::drawImageRect(const int x, const int y, #include "render/openglgraphics_drawImageRect.hpp" } +void SDLGraphics::calcImageRect(ImageVertexes *const vert, + const int x, const int y, + const int w, const int h, + const ImageRect &imgRect) +{ + #include "render/openglgraphics_calcImageRect.hpp" +} + #endif // USE_SDL2 diff --git a/src/render/sdl2graphics.h b/src/render/sdl2graphics.h index 25a3a74b3..b7e430f16 100644 --- a/src/render/sdl2graphics.h +++ b/src/render/sdl2graphics.h @@ -115,7 +115,7 @@ class SDLGraphics final : public Graphics const int x2, const int y2, const int width, const int height) override final; - bool calcWindow(ImageCollection *const vertCol, + void calcWindow(ImageCollection *const vertCol, const int x, const int y, const int w, const int h, const ImageRect &imgRect) override final; @@ -162,6 +162,12 @@ class SDLGraphics final : public Graphics uint32_t mOldPixel; int mOldAlpha; + private: + void inline calcImageRect(ImageVertexes *const vert, + int x, int y, + int w, int h, + const ImageRect &imgRect); + }; #endif // USE_SDL2 diff --git a/src/render/sdl2softwaregraphics.cpp b/src/render/sdl2softwaregraphics.cpp index cbcc5f1cb..04be6b4fd 100644 --- a/src/render/sdl2softwaregraphics.cpp +++ b/src/render/sdl2softwaregraphics.cpp @@ -790,7 +790,7 @@ bool SDL2SoftwareGraphics::drawNet(const int x1, const int y1, return true; } -bool SDL2SoftwareGraphics::calcWindow(ImageCollection *const vertCol, +void SDL2SoftwareGraphics::calcWindow(ImageCollection *const vertCol, const int x, const int y, const int w, const int h, const ImageRect &imgRect) @@ -809,9 +809,7 @@ bool SDL2SoftwareGraphics::calcWindow(ImageCollection *const vertCol, { vert = vertCol->currentVert; } - - const Image *const *const grid = &imgRect.grid[0]; - return calcImageRect(vert, x, y, w, h, imgRect); + calcImageRect(vert, x, y, w, h, imgRect); } int SDL2SoftwareGraphics::SDL_FakeUpperBlit(const SDL_Surface *const src, @@ -1493,4 +1491,12 @@ void SDL2SoftwareGraphics::drawImageRect(const int x, const int y, #include "render/openglgraphics_drawImageRect.hpp" } +void SDL2SoftwareGraphics::calcImageRect(ImageVertexes *const vert, + const int x, const int y, + const int w, const int h, + const ImageRect &imgRect) +{ + #include "render/openglgraphics_calcImageRect.hpp" +} + #endif // USE_SDL2 diff --git a/src/render/sdl2softwaregraphics.h b/src/render/sdl2softwaregraphics.h index f6f92a065..eda4e9e34 100644 --- a/src/render/sdl2softwaregraphics.h +++ b/src/render/sdl2softwaregraphics.h @@ -115,7 +115,7 @@ class SDL2SoftwareGraphics final : public Graphics const int x2, const int y2, const int width, const int height) override final; - bool calcWindow(ImageCollection *const vertCol, + void calcWindow(ImageCollection *const vertCol, const int x, const int y, const int w, const int h, const ImageRect &imgRect) override final; @@ -173,6 +173,13 @@ class SDL2SoftwareGraphics final : public Graphics SDL_Surface *mSurface; uint32_t mOldPixel; int mOldAlpha; + + private: + void inline calcImageRect(ImageVertexes *const vert, + const int x, const int y, + const int w, const int h, + const ImageRect &imgRect); + }; #endif // USE_SDL2 diff --git a/src/render/sdlgraphics.cpp b/src/render/sdlgraphics.cpp index 2f13f53f0..ed2f08c4d 100644 --- a/src/render/sdlgraphics.cpp +++ b/src/render/sdlgraphics.cpp @@ -789,7 +789,7 @@ bool SDLGraphics::drawNet(const int x1, const int y1, return true; } -bool SDLGraphics::calcWindow(ImageCollection *const vertCol, +void SDLGraphics::calcWindow(ImageCollection *const vertCol, const int x, const int y, const int w, const int h, const ImageRect &imgRect) @@ -808,9 +808,7 @@ bool SDLGraphics::calcWindow(ImageCollection *const vertCol, { vert = vertCol->currentVert; } - - const Image *const *const grid = &imgRect.grid[0]; - return calcImageRect(vert, x, y, w, h, imgRect); + calcImageRect(vert, x, y, w, h, imgRect); } int SDLGraphics::SDL_FakeUpperBlit(const SDL_Surface *const src, @@ -1472,4 +1470,12 @@ void SDLGraphics::drawImageRect(const int x, const int y, #include "render/openglgraphics_drawImageRect.hpp" } +void SDLGraphics::calcImageRect(ImageVertexes *const vert, + const int x, const int y, + const int w, const int h, + const ImageRect &imgRect) +{ + #include "render/openglgraphics_calcImageRect.hpp" +} + #endif // USE_SDL2 diff --git a/src/render/sdlgraphics.h b/src/render/sdlgraphics.h index 6fb1fd337..b66242f79 100644 --- a/src/render/sdlgraphics.h +++ b/src/render/sdlgraphics.h @@ -115,7 +115,7 @@ class SDLGraphics final : public Graphics const int x2, const int y2, const int width, const int height) override final; - bool calcWindow(ImageCollection *const vertCol, + void calcWindow(ImageCollection *const vertCol, const int x, const int y, const int w, const int h, const ImageRect &imgRect) override final; @@ -166,6 +166,13 @@ class SDLGraphics final : public Graphics uint32_t mOldPixel; int mOldAlpha; + + private: + void inline calcImageRect(ImageVertexes *const vert, + int x, int y, + int w, int h, + const ImageRect &imgRect); + }; #endif // USE_SDL2 diff --git a/src/render/surfacegraphics.h b/src/render/surfacegraphics.h index 2973bc006..8d58fa052 100644 --- a/src/render/surfacegraphics.h +++ b/src/render/surfacegraphics.h @@ -146,11 +146,11 @@ class SurfaceGraphics final : public Graphics const int height A_UNUSED) override final { return false; } - bool calcWindow(ImageCollection *const vertCol A_UNUSED, + void calcWindow(ImageCollection *const vertCol A_UNUSED, const int x A_UNUSED, const int y A_UNUSED, const int w A_UNUSED, const int h A_UNUSED, const ImageRect &imgRect A_UNUSED) override final - { return false; } + { } void setBlitMode(const BlitMode mode) { mBlitMode = mode; } |