diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-06-06 14:49:47 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-06-06 14:49:47 +0300 |
commit | c649cf883480071c9b93909c4ea4ee5ec98155b2 (patch) | |
tree | 71022fd2db59c643c19c78c5524ffcd038e35a7f /src/render/sdl2graphics.cpp | |
parent | 4cab6fc78e19799f223d951d5ccc9afb303b65f2 (diff) | |
download | mv-c649cf883480071c9b93909c4ea4ee5ec98155b2.tar.gz mv-c649cf883480071c9b93909c4ea4ee5ec98155b2.tar.bz2 mv-c649cf883480071c9b93909c4ea4ee5ec98155b2.tar.xz mv-c649cf883480071c9b93909c4ea4ee5ec98155b2.zip |
Remove some duplicate code.
Diffstat (limited to 'src/render/sdl2graphics.cpp')
-rw-r--r-- | src/render/sdl2graphics.cpp | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/src/render/sdl2graphics.cpp b/src/render/sdl2graphics.cpp index 9c93c6e38..1acca0a6c 100644 --- a/src/render/sdl2graphics.cpp +++ b/src/render/sdl2graphics.cpp @@ -118,6 +118,15 @@ static int FakeSDL_RenderCopy(SDL_Renderer *const renderer, static_cast<uint8_t>(mColor.b), \ static_cast<uint8_t>(mColor.a)) +#define defRectFromArea(rect, area) \ + const SDL_Rect rect = \ + { \ + static_cast<int32_t>(area.x), \ + static_cast<int32_t>(area.y), \ + static_cast<int32_t>(area.width), \ + static_cast<int32_t>(area.height) \ + } + SDLGraphics::SDLGraphics() : Graphics(), mRendererFlags(SDL_RENDERER_SOFTWARE), @@ -662,13 +671,7 @@ bool SDLGraphics::pushClipArea(const Rect &area) const bool result = Graphics::pushClipArea(area); const ClipRect &carea = mClipStack.top(); - const SDL_Rect rect = - { - static_cast<int32_t>(carea.x), - static_cast<int32_t>(carea.y), - static_cast<int32_t>(carea.width), - static_cast<int32_t>(carea.height) - }; + defRectFromArea(rect, carea); SDL_RenderSetClipRect(mRenderer, &rect); return result; } @@ -681,14 +684,7 @@ void SDLGraphics::popClipArea() return; const ClipRect &carea = mClipStack.top(); - const SDL_Rect rect = - { - static_cast<int32_t>(carea.x), - static_cast<int32_t>(carea.y), - static_cast<int32_t>(carea.width), - static_cast<int32_t>(carea.height) - }; - + defRectFromArea(rect, carea); SDL_RenderSetClipRect(mRenderer, &rect); } |