summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-04-30 19:52:52 +0300
committerAndrei Karas <akaras@inbox.ru>2014-04-30 19:52:52 +0300
commit2c13c60e916768fe09bcfff1d0b568a4c5397a99 (patch)
tree9c1fc71c68c2c7f1b2cb55dd53452f9fee120875 /src
parentdc569bbcb4c12a5a400f9e5701e5c1027badadae (diff)
downloadplus-2c13c60e916768fe09bcfff1d0b568a4c5397a99.tar.gz
plus-2c13c60e916768fe09bcfff1d0b568a4c5397a99.tar.bz2
plus-2c13c60e916768fe09bcfff1d0b568a4c5397a99.tar.xz
plus-2c13c60e916768fe09bcfff1d0b568a4c5397a99.zip
Fix code style in render.
Diffstat (limited to 'src')
-rw-r--r--src/render/mobileopenglgraphics.cpp30
-rw-r--r--src/render/sdl2graphics.cpp17
-rw-r--r--src/render/sdl2softwaregraphics.cpp7
-rw-r--r--src/render/sdlgraphics.cpp7
4 files changed, 35 insertions, 26 deletions
diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp
index ede89f115..3db76a616 100644
--- a/src/render/mobileopenglgraphics.cpp
+++ b/src/render/mobileopenglgraphics.cpp
@@ -53,18 +53,18 @@
tVar[vp + 9] = y2; \
tVar[vp + 10] = x2; \
tVar[vp + 11] = y2; \
- vVar[vp + 0] = dstX; \
- vVar[vp + 1] = dstY; \
- vVar[vp + 2] = dstX + w; \
- vVar[vp + 3] = dstY; \
- vVar[vp + 4] = dstX + w; \
- vVar[vp + 5] = dstY + h; \
- vVar[vp + 6] = dstX; \
- vVar[vp + 7] = dstY; \
- vVar[vp + 8] = dstX; \
- vVar[vp + 9] = dstY + h; \
- vVar[vp + 10] = dstX + w; \
- vVar[vp + 11] = dstY + h;
+ vVar[vp + 0] = static_cast<GLshort>(dstX); \
+ vVar[vp + 1] = static_cast<GLshort>(dstY); \
+ vVar[vp + 2] = static_cast<GLshort>(dstX + w); \
+ vVar[vp + 3] = static_cast<GLshort>(dstY); \
+ vVar[vp + 4] = static_cast<GLshort>(dstX + w); \
+ vVar[vp + 5] = static_cast<GLshort>(dstY + h); \
+ vVar[vp + 6] = static_cast<GLshort>(dstX); \
+ vVar[vp + 7] = static_cast<GLshort>(dstY); \
+ vVar[vp + 8] = static_cast<GLshort>(dstX); \
+ vVar[vp + 9] = static_cast<GLshort>(dstY + h); \
+ vVar[vp + 10] = static_cast<GLshort>(dstX + w); \
+ vVar[vp + 11] = static_cast<GLshort>(dstY + h);
GLuint MobileOpenGLGraphics::mLastImage = 0;
#ifdef DEBUG_DRAW_CALLS
@@ -1163,8 +1163,10 @@ bool MobileOpenGLGraphics::drawNet(const int x1, const int y1,
const GLshort xs2 = static_cast<GLshort>(x2);
const GLshort ys1 = static_cast<GLshort>(y1);
const GLshort ys2 = static_cast<GLshort>(y2);
+ const int16_t width1 = static_cast<int16_t>(width);
+ const int16_t height1 = static_cast<int16_t>(height);
- for (int16_t y = y1; y < y2; y += height)
+ for (int16_t y = static_cast<int16_t>(y1); y < y2; y += height1)
{
mShortVertArray[vp + 0] = xs1;
mShortVertArray[vp + 1] = y;
@@ -1180,7 +1182,7 @@ bool MobileOpenGLGraphics::drawNet(const int x1, const int y1,
}
}
- for (int16_t x = x1; x < x2; x += width)
+ for (int16_t x = static_cast<int16_t>(x1); x < x2; x += width1)
{
mShortVertArray[vp + 0] = x;
mShortVertArray[vp + 1] = ys1;
diff --git a/src/render/sdl2graphics.cpp b/src/render/sdl2graphics.cpp
index c93622920..2b70a8ab0 100644
--- a/src/render/sdl2graphics.cpp
+++ b/src/render/sdl2graphics.cpp
@@ -110,6 +110,13 @@ static int FakeSDL_RenderCopy(SDL_Renderer *const renderer,
#endif
+#define setRenderDrawColor(mColor) \
+ SDL_SetRenderDrawColor(mRenderer, \
+ static_cast<uint8_t>(mColor.r), \
+ static_cast<uint8_t>(mColor.g), \
+ static_cast<uint8_t>(mColor.b), \
+ static_cast<uint8_t>(mColor.a))
+
SDLGraphics::SDLGraphics() :
Graphics(),
mRendererFlags(SDL_RENDERER_SOFTWARE),
@@ -649,7 +656,7 @@ void SDLGraphics::fillRectangle(const Rect &rectangle)
static_cast<int32_t>(rectangle.height)
};
- SDL_SetRenderDrawColor(mRenderer, mColor.r, mColor.g, mColor.b, mColor.a);
+ setRenderDrawColor(mColor);
SDL_RenderFillRects(mRenderer, &rect, 1);
}
@@ -711,7 +718,7 @@ void SDLGraphics::drawPoint(int x, int y)
if (!top.isPointInRect(x, y))
return;
- SDL_SetRenderDrawColor(mRenderer, mColor.r, mColor.g, mColor.b, mColor.a);
+ setRenderDrawColor(mColor);
const SDL_Point point =
{
x,
@@ -725,8 +732,7 @@ void SDLGraphics::drawPoint(int x, int y)
void SDLGraphics::drawRectangle(const Rect &rectangle)
{
const ClipRect &top = mClipStack.top();
-
- SDL_SetRenderDrawColor(mRenderer, mColor.r, mColor.g, mColor.b, mColor.a);
+ setRenderDrawColor(mColor);
const int x1 = rectangle.x + top.xOffset;
const int y1 = rectangle.y + top.yOffset;
@@ -747,8 +753,7 @@ void SDLGraphics::drawRectangle(const Rect &rectangle)
void SDLGraphics::drawLine(int x1, int y1, int x2, int y2)
{
const ClipRect &top = mClipStack.top();
-
- SDL_SetRenderDrawColor(mRenderer, mColor.r, mColor.g, mColor.b, mColor.a);
+ setRenderDrawColor(mColor);
const int x0 = top.xOffset;
const int y0 = top.yOffset;
diff --git a/src/render/sdl2softwaregraphics.cpp b/src/render/sdl2softwaregraphics.cpp
index 54cd010a8..a176b6905 100644
--- a/src/render/sdl2softwaregraphics.cpp
+++ b/src/render/sdl2softwaregraphics.cpp
@@ -1241,8 +1241,9 @@ void SDL2SoftwareGraphics::drawHLine(int x1, int y, int x2)
case 2:
{
uint16_t* q = reinterpret_cast<uint16_t*>(p);
+ const uint16_t pixel1 = static_cast<uint16_t>(pixel);
for (; x1 <= x2; ++x1)
- *(q++) = pixel;
+ *(q++) = pixel1;
break;
}
@@ -1277,7 +1278,7 @@ void SDL2SoftwareGraphics::drawHLine(int x1, int y, int x2)
if (mAlpha)
{
unsigned char a = static_cast<unsigned char>(mColor.a);
- unsigned char a1 = 255 - a;
+ unsigned char a1 = static_cast<unsigned char>(255U - a);
const int b0 = (pixel & 0xff) * a;
const int g0 = (pixel & 0xff00) * a;
const int r0 = (pixel & 0xff0000) * a;
@@ -1406,7 +1407,7 @@ void SDL2SoftwareGraphics::drawVLine(int x, int y1, int y2)
if (mAlpha)
{
unsigned char a = static_cast<unsigned char>(mColor.a);
- unsigned char a1 = 255 - a;
+ unsigned char a1 = static_cast<unsigned char>(255U - a);
const int b0 = (pixel & 0xff) * a;
const int g0 = (pixel & 0xff00) * a;
const int r0 = (pixel & 0xff0000) * a;
diff --git a/src/render/sdlgraphics.cpp b/src/render/sdlgraphics.cpp
index cbd3f0689..ac304b7ab 100644
--- a/src/render/sdlgraphics.cpp
+++ b/src/render/sdlgraphics.cpp
@@ -1238,8 +1238,9 @@ void SDLGraphics::drawHLine(int x1, int y, int x2)
case 2:
{
uint16_t* q = reinterpret_cast<uint16_t*>(p);
+ const uint16_t pixel1 = static_cast<uint16_t>(pixel);
for (; x1 <= x2; ++x1)
- *(q++) = pixel;
+ *(q++) = pixel1;
break;
}
@@ -1274,7 +1275,7 @@ void SDLGraphics::drawHLine(int x1, int y, int x2)
if (mAlpha)
{
unsigned char a = static_cast<unsigned char>(mColor.a);
- unsigned char a1 = 255 - a;
+ unsigned char a1 = static_cast<unsigned char>(255U - a);
const int b0 = (pixel & 0xff) * a;
const int g0 = (pixel & 0xff00) * a;
const int r0 = (pixel & 0xff0000) * a;
@@ -1403,7 +1404,7 @@ void SDLGraphics::drawVLine(int x, int y1, int y2)
if (mAlpha)
{
unsigned char a = static_cast<unsigned char>(mColor.a);
- unsigned char a1 = 255 - a;
+ unsigned char a1 = static_cast<unsigned char>(255U - a);
const int b0 = (pixel & 0xff) * a;
const int g0 = (pixel & 0xff00) * a;
const int r0 = (pixel & 0xff0000) * a;