From d9a77eb8ac5d507665cbf8b20f5d8187148ebfd1 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 14 Dec 2013 16:59:21 +0300 Subject: Improve a bit separate images drawing. --- src/render/graphics.cpp | 8 ++++---- src/render/graphics.h | 25 +++++++++++++++++-------- src/render/mobileopenglgraphics.h | 12 ++++++------ src/render/normalopenglgraphics.h | 12 ++++++------ src/render/nullopenglgraphics.h | 12 ++++++------ src/render/safeopenglgraphics.h | 10 +++++----- src/render/sdl2graphics.h | 2 +- src/render/sdl2softwaregraphics.h | 2 +- src/render/sdlgraphics.h | 2 +- src/render/surfacegraphics.h | 2 +- 10 files changed, 48 insertions(+), 39 deletions(-) (limited to 'src/render') 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; }; -- cgit v1.2.3-70-g09d2