summaryrefslogtreecommitdiff
path: root/src/render
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-12-30 18:19:40 +0300
committerAndrei Karas <akaras@inbox.ru>2013-12-30 18:21:13 +0300
commit00d8cfee5bc76c59e5c3195f4434c4a4fb741d0e (patch)
treec536958c8cf2308bd38d92a414e6af0a64a3c844 /src/render
parent252bfdaf28d9cfa449e6b0af7a15b66483b9c5bd (diff)
downloadplus-00d8cfee5bc76c59e5c3195f4434c4a4fb741d0e.tar.gz
plus-00d8cfee5bc76c59e5c3195f4434c4a4fb741d0e.tar.bz2
plus-00d8cfee5bc76c59e5c3195f4434c4a4fb741d0e.tar.xz
plus-00d8cfee5bc76c59e5c3195f4434c4a4fb741d0e.zip
add drawImageRect into each renderer. but copy function body to shared file.
Diffstat (limited to 'src/render')
-rw-r--r--src/render/graphics.cpp64
-rw-r--r--src/render/graphics.h17
-rw-r--r--src/render/mobileopenglgraphics.cpp7
-rw-r--r--src/render/mobileopenglgraphics.h7
-rw-r--r--src/render/normalopenglgraphics.cpp7
-rw-r--r--src/render/normalopenglgraphics.h7
-rw-r--r--src/render/nullopenglgraphics.cpp7
-rw-r--r--src/render/nullopenglgraphics.h7
-rw-r--r--src/render/openglgraphics_drawImageRect.hpp83
-rw-r--r--src/render/safeopenglgraphics.cpp7
-rw-r--r--src/render/safeopenglgraphics.h7
-rw-r--r--src/render/sdl2graphics.cpp7
-rw-r--r--src/render/sdl2graphics.h8
-rw-r--r--src/render/sdl2softwaregraphics.cpp7
-rw-r--r--src/render/sdl2softwaregraphics.h7
-rw-r--r--src/render/sdlgraphics.cpp7
-rw-r--r--src/render/sdlgraphics.h7
-rw-r--r--src/render/surfacegraphics.h9
18 files changed, 194 insertions, 78 deletions
diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp
index c83595b56..abb696bc9 100644
--- a/src/render/graphics.cpp
+++ b/src/render/graphics.cpp
@@ -440,70 +440,6 @@ int Graphics::getHeight() const
return mHeight;
}
-void Graphics::drawImageRect(const int x, const int y,
- const int w, const int h,
- const ImageRect &imgRect)
-{
- BLOCK_START("Graphics::drawImageRect")
-
- 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();
- drawPattern(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();
- drawPattern(top, x + lw, y, w - lw - rw, th);
- drawPattern(bottom, x + lw, h - bh + y, w - lw - rw, bh);
- drawPattern(left, x, y + th, lw, h - th - bh);
- if (w > rw)
- drawPattern(right, x + w - rw, th + y, rw, h - th - bh);
- }
- // Draw the corners
- if (drawMain)
- {
- drawImage2(topLeft, x, y);
- const int trw = topRight->getWidth();
- if (w > trw)
- {
- drawImage2(topRight, x + w - trw, y);
- }
- drawImage2(bottomLeft, x, h - bottomLeft->getHeight() + y);
- const int brw = bottomRight->getWidth();
- if (w > brw)
- {
- drawImage2(bottomRight,
- x + w - brw,
- y + h - bottomRight->getHeight());
- }
- }
- BLOCK_END("Graphics::drawImageRect")
-}
-
bool Graphics::drawNet(const int x1, const int y1, const int x2, const int y2,
const int width, const int height)
{
diff --git a/src/render/graphics.h b/src/render/graphics.h
index 93b2977d6..8567b4c1f 100644
--- a/src/render/graphics.h
+++ b/src/render/graphics.h
@@ -170,12 +170,9 @@ class Graphics : public gcn::Graphics
const int scaledWidth,
const int scaledHeight) = 0;
- /**
- * 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);
+ virtual void drawImageRect(const int x, const int y,
+ const int w, const int h,
+ const ImageRect &imgRect) = 0;
bool calcImageRect(ImageVertexes *const vert,
const int x, const int y,
@@ -215,14 +212,6 @@ class Graphics : public gcn::Graphics
const int w, const int h,
const ImageRect &imgRect) = 0;
- /**
- * Draws a rectangle using images. 4 corner images, 4 side images and 1
- * image for the inside.
- */
- inline void drawImageRect(const gcn::Rectangle &area,
- const ImageRect &imgRect)
- { drawImageRect(area.x, area.y, area.width, area.height, imgRect); }
-
virtual void fillRectangle(const gcn::Rectangle& rectangle)
override = 0;
diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp
index 5efcd8060..33adf6e92 100644
--- a/src/render/mobileopenglgraphics.cpp
+++ b/src/render/mobileopenglgraphics.cpp
@@ -1258,6 +1258,13 @@ void MobileOpenGLGraphics::restoreColor()
mByteColor = mColor;
}
+void MobileOpenGLGraphics::drawImageRect(const int x, const int y,
+ const int w, const int h,
+ const ImageRect &imgRect)
+{
+ #include "render/openglgraphics_drawImageRect.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 ea85beee1..08e1979f2 100644
--- a/src/render/mobileopenglgraphics.h
+++ b/src/render/mobileopenglgraphics.h
@@ -75,6 +75,13 @@ class MobileOpenGLGraphics final : public Graphics
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; }
diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp
index 5f24eda2c..2088214c0 100644
--- a/src/render/normalopenglgraphics.cpp
+++ b/src/render/normalopenglgraphics.cpp
@@ -1545,6 +1545,13 @@ void NormalOpenGLGraphics::restoreColor()
mByteColor = mColor;
}
+void NormalOpenGLGraphics::drawImageRect(const int x, const int y,
+ const int w, const int h,
+ const ImageRect &imgRect)
+{
+ #include "render/openglgraphics_drawImageRect.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 3a888caca..62d0fffb6 100644
--- a/src/render/normalopenglgraphics.h
+++ b/src/render/normalopenglgraphics.h
@@ -85,6 +85,13 @@ class NormalOpenGLGraphics final : public Graphics
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; }
diff --git a/src/render/nullopenglgraphics.cpp b/src/render/nullopenglgraphics.cpp
index da9163294..aa5a5861b 100644
--- a/src/render/nullopenglgraphics.cpp
+++ b/src/render/nullopenglgraphics.cpp
@@ -1133,6 +1133,13 @@ void NullOpenGLGraphics::restoreColor()
mByteColor = mColor;
}
+void NullOpenGLGraphics::drawImageRect(const int x, const int y,
+ const int w, const int h,
+ const ImageRect &imgRect)
+{
+ #include "render/openglgraphics_drawImageRect.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 d047f1035..35aa8d3de 100644
--- a/src/render/nullopenglgraphics.h
+++ b/src/render/nullopenglgraphics.h
@@ -81,6 +81,13 @@ class NullOpenGLGraphics final : public Graphics
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; }
diff --git a/src/render/openglgraphics_drawImageRect.hpp b/src/render/openglgraphics_drawImageRect.hpp
new file mode 100644
index 000000000..734bc8b83
--- /dev/null
+++ b/src/render/openglgraphics_drawImageRect.hpp
@@ -0,0 +1,83 @@
+/*
+ * 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/>.
+ */
+
+
+//void GraphicsX::drawImageRect(const int x, const int y,
+// const int w, const int h,
+// const ImageRect &imgRect)
+
+BLOCK_START("Graphics::drawImageRect")
+
+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();
+ drawPattern(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();
+ drawPattern(top, x + lw, y, w - lw - rw, th);
+ drawPattern(bottom, x + lw, h - bh + y, w - lw - rw, bh);
+ drawPattern(left, x, y + th, lw, h - th - bh);
+ if (w > rw)
+ drawPattern(right, x + w - rw, th + y, rw, h - th - bh);
+}
+// Draw the corners
+if (drawMain)
+{
+ drawImage2(topLeft, x, y);
+ const int trw = topRight->getWidth();
+ if (w > trw)
+ drawImage2(topRight, x + w - trw, y);
+ drawImage2(bottomLeft, x, h - bottomLeft->getHeight() + y);
+ const int brw = bottomRight->getWidth();
+ if (w > brw)
+ {
+ drawImage2(bottomRight,
+ x + w - brw,
+ y + h - bottomRight->getHeight());
+ }
+}
+BLOCK_END("Graphics::drawImageRect")
diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp
index f92455e58..b2e7cd3c0 100644
--- a/src/render/safeopenglgraphics.cpp
+++ b/src/render/safeopenglgraphics.cpp
@@ -656,4 +656,11 @@ void SafeOpenGLGraphics::restoreColor()
mByteColor = mColor;
}
+void SafeOpenGLGraphics::drawImageRect(const int x, const int y,
+ const int w, const int h,
+ const ImageRect &imgRect)
+{
+ #include "render/openglgraphics_drawImageRect.hpp"
+}
+
#endif // USE_OPENGL
diff --git a/src/render/safeopenglgraphics.h b/src/render/safeopenglgraphics.h
index 8d9b38e5a..a6a32771c 100644
--- a/src/render/safeopenglgraphics.h
+++ b/src/render/safeopenglgraphics.h
@@ -52,6 +52,13 @@ class SafeOpenGLGraphics final : public Graphics
#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);
+
protected:
void setTexturingAndBlending(const bool enable);
diff --git a/src/render/sdl2graphics.cpp b/src/render/sdl2graphics.cpp
index dfa9cfb3f..dbfe7ed1e 100644
--- a/src/render/sdl2graphics.cpp
+++ b/src/render/sdl2graphics.cpp
@@ -716,4 +716,11 @@ bool SDLGraphics::setVideoMode(const int w, const int h, const int bpp,
return videoInfo();
}
+void SDLGraphics::drawImageRect(const int x, const int y,
+ const int w, const int h,
+ const ImageRect &imgRect)
+{
+ #include "render/openglgraphics_drawImageRect.hpp"
+}
+
#endif // USE_SDL2
diff --git a/src/render/sdl2graphics.h b/src/render/sdl2graphics.h
index b489f2475..91e789640 100644
--- a/src/render/sdl2graphics.h
+++ b/src/render/sdl2graphics.h
@@ -146,10 +146,18 @@ class SDLGraphics final : public Graphics
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);
+
protected:
uint32_t mRendererFlags;
uint32_t mOldPixel;
int mOldAlpha;
+
};
#endif // USE_SDL2
diff --git a/src/render/sdl2softwaregraphics.cpp b/src/render/sdl2softwaregraphics.cpp
index 53efc85ed..fbd6e670b 100644
--- a/src/render/sdl2softwaregraphics.cpp
+++ b/src/render/sdl2softwaregraphics.cpp
@@ -1479,4 +1479,11 @@ bool SDL2SoftwareGraphics::resizeScreen(const int width, const int height)
return ret;
}
+void SDL2SoftwareGraphics::drawImageRect(const int x, const int y,
+ const int w, const int h,
+ const ImageRect &imgRect)
+{
+ #include "render/openglgraphics_drawImageRect.hpp"
+}
+
#endif // USE_SDL2
diff --git a/src/render/sdl2softwaregraphics.h b/src/render/sdl2softwaregraphics.h
index 658f1d127..441167d01 100644
--- a/src/render/sdl2softwaregraphics.h
+++ b/src/render/sdl2softwaregraphics.h
@@ -148,6 +148,13 @@ class SDL2SoftwareGraphics final : public Graphics
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);
+
protected:
int SDL_FakeUpperBlit(const SDL_Surface *const src,
SDL_Rect *const srcrect,
diff --git a/src/render/sdlgraphics.cpp b/src/render/sdlgraphics.cpp
index a8e1d84b6..2860f871c 100644
--- a/src/render/sdlgraphics.cpp
+++ b/src/render/sdlgraphics.cpp
@@ -1458,4 +1458,11 @@ bool SDLGraphics::setVideoMode(const int w, const int h, const int bpp,
return videoInfo();
}
+void SDLGraphics::drawImageRect(const int x, const int y,
+ const int w, const int h,
+ const ImageRect &imgRect)
+{
+ #include "render/openglgraphics_drawImageRect.hpp"
+}
+
#endif // USE_SDL2
diff --git a/src/render/sdlgraphics.h b/src/render/sdlgraphics.h
index c705368e9..1b447c4a4 100644
--- a/src/render/sdlgraphics.h
+++ b/src/render/sdlgraphics.h
@@ -143,6 +143,13 @@ class SDLGraphics final : public Graphics
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);
+
protected:
int SDL_FakeUpperBlit(const SDL_Surface *const src,
SDL_Rect *const srcrect,
diff --git a/src/render/surfacegraphics.h b/src/render/surfacegraphics.h
index dc26ac05e..2973bc006 100644
--- a/src/render/surfacegraphics.h
+++ b/src/render/surfacegraphics.h
@@ -193,6 +193,15 @@ class SurfaceGraphics final : public Graphics
void completeCache() override final;
+ /**
+ * Draws a rectangle using images. 4 corner images, 4 side images and 1
+ * image for the inside.
+ */
+ void drawImageRect(const int x, const int y,
+ const int w, const int h,
+ const ImageRect &imgRect)
+ { }
+
protected:
BlitMode mBlitMode;
SDL_Surface *mTarget;