summaryrefslogtreecommitdiff
path: root/src/render
diff options
context:
space:
mode:
Diffstat (limited to 'src/render')
-rw-r--r--src/render/sdl2graphics.cpp26
-rw-r--r--src/render/sdl2softwaregraphics.cpp35
2 files changed, 23 insertions, 38 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);
}
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<int32_t>(area.x), \
+ static_cast<int32_t>(area.y), \
+ static_cast<int32_t>(area.width), \
+ static_cast<int32_t>(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<int16_t>(area.x),
- static_cast<int16_t>(area.y),
- static_cast<uint16_t>(area.width),
- static_cast<uint16_t>(area.height)
- };
-
+ defRectFromArea(rect, area);
const uint32_t color = SDL_MapRGBA(mSurface->format,
static_cast<int8_t>(mColor.r),
static_cast<int8_t>(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<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_SetClipRect(mSurface, &rect);
return result;
}
@@ -1136,14 +1132,7 @@ void SDL2SoftwareGraphics::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_SetClipRect(mSurface, &rect);
}