From c649cf883480071c9b93909c4ea4ee5ec98155b2 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 6 Jun 2014 14:49:47 +0300 Subject: Remove some duplicate code. --- src/render/sdl2softwaregraphics.cpp | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) (limited to 'src/render/sdl2softwaregraphics.cpp') diff --git a/src/render/sdl2softwaregraphics.cpp b/src/render/sdl2softwaregraphics.cpp index 8a5729027..49e450507 100644 --- a/src/render/sdl2softwaregraphics.cpp +++ b/src/render/sdl2softwaregraphics.cpp @@ -48,6 +48,15 @@ static unsigned int *cG = nullptr; static unsigned int *cB = nullptr; #endif +#define defRectFromArea(rect, area) \ + const SDL_Rect rect = \ + { \ + static_cast(area.x), \ + static_cast(area.y), \ + static_cast(area.width), \ + static_cast(area.height) \ + } + SDL2SoftwareGraphics::SDL2SoftwareGraphics() : Graphics(), mRendererFlags(SDL_RENDERER_SOFTWARE), @@ -1085,14 +1094,7 @@ void SDL2SoftwareGraphics::fillRectangle(const Rect &rectangle) } else { - SDL_Rect rect = - { - static_cast(area.x), - static_cast(area.y), - static_cast(area.width), - static_cast(area.height) - }; - + defRectFromArea(rect, area); const uint32_t color = SDL_MapRGBA(mSurface->format, static_cast(mColor.r), static_cast(mColor.g), @@ -1117,13 +1119,7 @@ bool SDL2SoftwareGraphics::pushClipArea(const Rect &area) const bool result = Graphics::pushClipArea(area); const ClipRect &carea = mClipStack.top(); - const SDL_Rect rect = - { - static_cast(carea.x), - static_cast(carea.y), - static_cast(carea.width), - static_cast(carea.height) - }; + defRectFromArea(rect, carea); SDL_SetClipRect(mSurface, &rect); return result; } @@ -1136,14 +1132,7 @@ void SDL2SoftwareGraphics::popClipArea() return; const ClipRect &carea = mClipStack.top(); - const SDL_Rect rect = - { - static_cast(carea.x), - static_cast(carea.y), - static_cast(carea.width), - static_cast(carea.height) - }; - + defRectFromArea(rect, carea); SDL_SetClipRect(mSurface, &rect); } -- cgit v1.2.3-60-g2f50