summaryrefslogtreecommitdiff
path: root/src/render
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-12-14 16:59:21 +0300
committerAndrei Karas <akaras@inbox.ru>2013-12-14 16:59:21 +0300
commitd9a77eb8ac5d507665cbf8b20f5d8187148ebfd1 (patch)
treedb2f8a25d466ce6aa5ca1747216156f7869a06d1 /src/render
parent2851324a6847efa7ea6f556941b369e9e304dc23 (diff)
downloadplus-d9a77eb8ac5d507665cbf8b20f5d8187148ebfd1.tar.gz
plus-d9a77eb8ac5d507665cbf8b20f5d8187148ebfd1.tar.bz2
plus-d9a77eb8ac5d507665cbf8b20f5d8187148ebfd1.tar.xz
plus-d9a77eb8ac5d507665cbf8b20f5d8187148ebfd1.zip
Improve a bit separate images drawing.
Diffstat (limited to 'src/render')
-rw-r--r--src/render/graphics.cpp8
-rw-r--r--src/render/graphics.h25
-rw-r--r--src/render/mobileopenglgraphics.h12
-rw-r--r--src/render/normalopenglgraphics.h12
-rw-r--r--src/render/nullopenglgraphics.h12
-rw-r--r--src/render/safeopenglgraphics.h10
-rw-r--r--src/render/sdl2graphics.h2
-rw-r--r--src/render/sdl2softwaregraphics.h2
-rw-r--r--src/render/sdlgraphics.h2
-rw-r--r--src/render/surfacegraphics.h2
10 files changed, 48 insertions, 39 deletions
diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp
index 5a0adfeef..561ce3a90 100644
--- a/src/render/graphics.cpp
+++ b/src/render/graphics.cpp
@@ -494,10 +494,10 @@ void Graphics::drawImageRect(const int x, const int y,
// Draw the corners
if (drawMain)
{
- drawImage(topLeft, x, y);
- drawImage(topRight, x + w - topRight->getWidth(), y);
- drawImage(bottomLeft, x, h - bottomLeft->getHeight() + y);
- drawImage(bottomRight,
+ DRAW_IMAGE(this, topLeft, x, y);
+ DRAW_IMAGE(this, topRight, x + w - topRight->getWidth(), y);
+ DRAW_IMAGE(this, bottomLeft, x, h - bottomLeft->getHeight() + y);
+ DRAW_IMAGE(this, bottomRight,
x + w - bottomRight->getWidth(),
y + h - bottomRight->getHeight());
}
diff --git a/src/render/graphics.h b/src/render/graphics.h
index 7d4d7c524..cb009291b 100644
--- a/src/render/graphics.h
+++ b/src/render/graphics.h
@@ -47,6 +47,15 @@ struct SDL_Window;
static const int defaultScreenWidth = 800;
static const int defaultScreenHeight = 600;
+#define DRAW_IMAGE(graphics, image, x, y) \
+ { \
+ if (image) \
+ { \
+ (graphics)->drawImage2(image, 0, 0, x, y, \
+ (image)->mBounds.w, (image)->mBounds.h, false); \
+ } \
+ }
+
/**
* 9 images defining a rectangle. 4 corners, 4 sides and a middle area. The
* topology is as follows:
@@ -370,14 +379,6 @@ class Graphics : public gcn::Graphics
virtual void setRendererFlags(const uint32_t flags A_UNUSED)
{ }
#endif
- int mWidth;
- int mHeight;
-
- protected:
- /**
- * Constructor.
- */
- Graphics();
/**
* Blits an image onto the screen.
@@ -391,6 +392,14 @@ class Graphics : public gcn::Graphics
const int width, const int height,
const bool useColor) = 0;
+ int mWidth;
+ int mHeight;
+
+ protected:
+ /**
+ * Constructor.
+ */
+ Graphics();
void setMainFlags(const int w, const int h, const int bpp,
const bool fs, const bool hwaccel,
diff --git a/src/render/mobileopenglgraphics.h b/src/render/mobileopenglgraphics.h
index 75a171766..55283010e 100644
--- a/src/render/mobileopenglgraphics.h
+++ b/src/render/mobileopenglgraphics.h
@@ -184,6 +184,12 @@ class MobileOpenGLGraphics final : public Graphics
void updateTextureFormat();
+ bool drawImage2(const Image *const image,
+ int srcX, int srcY,
+ int dstX, int dstY,
+ const int width, const int height,
+ const bool useColor) override final;
+
#ifdef DEBUG_DRAW_CALLS
unsigned int getDrawCalls() const
{ return mLastDrawCalls; }
@@ -198,12 +204,6 @@ class MobileOpenGLGraphics final : public Graphics
static GLuint mLastImage;
protected:
- bool drawImage2(const Image *const image,
- int srcX, int srcY,
- int dstX, int dstY,
- const int width, const int height,
- const bool useColor) override final;
-
void setTexturingAndBlending(const bool enable);
void debugBindTexture(const Image *const image);
diff --git a/src/render/normalopenglgraphics.h b/src/render/normalopenglgraphics.h
index f59e02880..3af6ad00a 100644
--- a/src/render/normalopenglgraphics.h
+++ b/src/render/normalopenglgraphics.h
@@ -191,6 +191,12 @@ class NormalOpenGLGraphics final : public Graphics
void updateTextureFormat();
+ bool drawImage2(const Image *const image,
+ int srcX, int srcY,
+ int dstX, int dstY,
+ const int width, const int height,
+ const bool useColor) override final;
+
#ifdef DEBUG_DRAW_CALLS
unsigned int getDrawCalls() const
{ return mLastDrawCalls; }
@@ -208,12 +214,6 @@ class NormalOpenGLGraphics final : public Graphics
static GLuint mLastImage;
protected:
- bool drawImage2(const Image *const image,
- int srcX, int srcY,
- int dstX, int dstY,
- const int width, const int height,
- const bool useColor) override final;
-
void setTexturingAndBlending(const bool enable);
void debugBindTexture(const Image *const image);
diff --git a/src/render/nullopenglgraphics.h b/src/render/nullopenglgraphics.h
index cdd9df0f6..620baa59d 100644
--- a/src/render/nullopenglgraphics.h
+++ b/src/render/nullopenglgraphics.h
@@ -191,6 +191,12 @@ class NullOpenGLGraphics final : public Graphics
void updateTextureFormat();
+ bool drawImage2(const Image *const image,
+ int srcX, int srcY,
+ int dstX, int dstY,
+ const int width, const int height,
+ const bool useColor) override final;
+
#ifdef DEBUG_DRAW_CALLS
unsigned int getDrawCalls() const
{ return mLastDrawCalls; }
@@ -205,12 +211,6 @@ class NullOpenGLGraphics final : public Graphics
static GLuint mLastImage;
protected:
- bool drawImage2(const Image *const image,
- int srcX, int srcY,
- int dstX, int dstY,
- const int width, const int height,
- const bool useColor) override final;
-
void setTexturingAndBlending(const bool enable);
void debugBindTexture(const Image *const image);
diff --git a/src/render/safeopenglgraphics.h b/src/render/safeopenglgraphics.h
index 773657261..6ece1bc88 100644
--- a/src/render/safeopenglgraphics.h
+++ b/src/render/safeopenglgraphics.h
@@ -154,17 +154,17 @@ class SafeOpenGLGraphics final : public Graphics
void prepareScreenshot() override final;
- static void bindTexture(const GLenum target, const GLuint texture);
-
- static GLuint mLastImage;
-
- protected:
bool drawImage2(const Image *const image,
int srcX, int srcY,
int dstX, int dstY,
const int width, const int height,
const bool useColor) override final;
+ static void bindTexture(const GLenum target, const GLuint texture);
+
+ static GLuint mLastImage;
+
+ protected:
void setTexturingAndBlending(const bool enable);
private:
diff --git a/src/render/sdl2graphics.h b/src/render/sdl2graphics.h
index 0e1801b0e..57e60135f 100644
--- a/src/render/sdl2graphics.h
+++ b/src/render/sdl2graphics.h
@@ -142,13 +142,13 @@ class SDLGraphics : public Graphics
void setRendererFlags(const uint32_t flags)
{ mRendererFlags = flags; }
- protected:
virtual bool drawImage2(const Image *const image,
int srcX, int srcY,
int dstX, int dstY,
const int width, const int height,
const bool useColor) override final;
+ protected:
uint32_t mRendererFlags;
uint32_t mOldPixel;
int mOldAlpha;
diff --git a/src/render/sdl2softwaregraphics.h b/src/render/sdl2softwaregraphics.h
index ab71f33e4..9c2b00ad9 100644
--- a/src/render/sdl2softwaregraphics.h
+++ b/src/render/sdl2softwaregraphics.h
@@ -145,13 +145,13 @@ class SDL2SoftwareGraphics : public Graphics
bool resizeScreen(const int width, const int height) override final;
- protected:
virtual bool drawImage2(const Image *const image,
int srcX, int srcY,
int dstX, int dstY,
const int width, const int height,
const bool useColor) override final;
+ protected:
int SDL_FakeUpperBlit(const SDL_Surface *const src,
SDL_Rect *const srcrect,
const SDL_Surface *const dst,
diff --git a/src/render/sdlgraphics.h b/src/render/sdlgraphics.h
index 17540543e..dd33fcc0c 100644
--- a/src/render/sdlgraphics.h
+++ b/src/render/sdlgraphics.h
@@ -139,13 +139,13 @@ class SDLGraphics : public Graphics
const bool resize,
const bool noFrame) override final;
- protected:
virtual bool drawImage2(const Image *const image,
int srcX, int srcY,
int dstX, int dstY,
const int width, const int height,
const bool useColor) override final;
+ protected:
int SDL_FakeUpperBlit(const SDL_Surface *const src,
SDL_Rect *const srcrect,
const SDL_Surface *const dst,
diff --git a/src/render/surfacegraphics.h b/src/render/surfacegraphics.h
index 3d62b5c22..d10ea938a 100644
--- a/src/render/surfacegraphics.h
+++ b/src/render/surfacegraphics.h
@@ -180,13 +180,13 @@ class SurfaceGraphics : public Graphics
const bool noFrame A_UNUSED) override final
{ return false; }
- protected:
bool drawImage2(const Image *const image,
int srcX, int srcY,
int dstX, int dstY,
const int width, const int height,
const bool useColor) override final;
+ protected:
BlitMode mBlitMode;
SDL_Surface *mTarget;
};