From 2c13c60e916768fe09bcfff1d0b568a4c5397a99 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 30 Apr 2014 19:52:52 +0300 Subject: Fix code style in render. --- src/render/mobileopenglgraphics.cpp | 30 ++++++++++++++++-------------- src/render/sdl2graphics.cpp | 17 +++++++++++------ src/render/sdl2softwaregraphics.cpp | 7 ++++--- src/render/sdlgraphics.cpp | 7 ++++--- 4 files changed, 35 insertions(+), 26 deletions(-) (limited to 'src/render') 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(dstX); \ + vVar[vp + 1] = static_cast(dstY); \ + vVar[vp + 2] = static_cast(dstX + w); \ + vVar[vp + 3] = static_cast(dstY); \ + vVar[vp + 4] = static_cast(dstX + w); \ + vVar[vp + 5] = static_cast(dstY + h); \ + vVar[vp + 6] = static_cast(dstX); \ + vVar[vp + 7] = static_cast(dstY); \ + vVar[vp + 8] = static_cast(dstX); \ + vVar[vp + 9] = static_cast(dstY + h); \ + vVar[vp + 10] = static_cast(dstX + w); \ + vVar[vp + 11] = static_cast(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(x2); const GLshort ys1 = static_cast(y1); const GLshort ys2 = static_cast(y2); + const int16_t width1 = static_cast(width); + const int16_t height1 = static_cast(height); - for (int16_t y = y1; y < y2; y += height) + for (int16_t y = static_cast(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(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(mColor.r), \ + static_cast(mColor.g), \ + static_cast(mColor.b), \ + static_cast(mColor.a)) + SDLGraphics::SDLGraphics() : Graphics(), mRendererFlags(SDL_RENDERER_SOFTWARE), @@ -649,7 +656,7 @@ void SDLGraphics::fillRectangle(const Rect &rectangle) static_cast(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(p); + const uint16_t pixel1 = static_cast(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(mColor.a); - unsigned char a1 = 255 - a; + unsigned char a1 = static_cast(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(mColor.a); - unsigned char a1 = 255 - a; + unsigned char a1 = static_cast(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(p); + const uint16_t pixel1 = static_cast(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(mColor.a); - unsigned char a1 = 255 - a; + unsigned char a1 = static_cast(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(mColor.a); - unsigned char a1 = 255 - a; + unsigned char a1 = static_cast(255U - a); const int b0 = (pixel & 0xff) * a; const int g0 = (pixel & 0xff00) * a; const int r0 = (pixel & 0xff0000) * a; -- cgit v1.2.3-60-g2f50