From 7e0a97d2521b9ce57003176e82a0b5564aa003c2 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 17 Jul 2012 23:26:59 +0300 Subject: Fix more code style and additional warnings. --- src/guichan/sdl/sdlgraphics.cpp | 69 ++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 32 deletions(-) (limited to 'src/guichan/sdl') diff --git a/src/guichan/sdl/sdlgraphics.cpp b/src/guichan/sdl/sdlgraphics.cpp index e50017c38..0be0bfe59 100644 --- a/src/guichan/sdl/sdlgraphics.cpp +++ b/src/guichan/sdl/sdlgraphics.cpp @@ -97,10 +97,10 @@ namespace gcn bool result = Graphics::pushClipArea(area); const ClipRectangle& carea = mClipStack.top(); - rect.x = carea.x; - rect.y = carea.y; - rect.w = carea.width; - rect.h = carea.height; + rect.x = static_cast(carea.x); + rect.y = static_cast(carea.y); + rect.w = static_cast(carea.width); + rect.h = static_cast(carea.height); SDL_SetClipRect(mTarget, &rect); @@ -116,10 +116,10 @@ namespace gcn const ClipRectangle& carea = mClipStack.top(); SDL_Rect rect; - rect.x = carea.x; - rect.y = carea.y; - rect.w = carea.width; - rect.h = carea.height; + rect.x = static_cast(carea.x); + rect.y = static_cast(carea.y); + rect.w = static_cast(carea.width); + rect.h = static_cast(carea.height); SDL_SetClipRect(mTarget, &rect); } @@ -213,21 +213,21 @@ namespace gcn + y * mTarget->pitch + x1 * bpp; uint32_t pixel = SDL_MapRGB(mTarget->format, - mColor.r, - mColor.g, - mColor.b); + static_cast(mColor.r), + static_cast(mColor.g), + static_cast(mColor.b)); switch (bpp) { case 1: for (; x1 <= x2; ++x1) - *(p++) = pixel; + *(p++) = static_cast(pixel); break; case 2: { uint16_t* q = reinterpret_cast(p); for (; x1 <= x2; ++x1) - *(q++) = pixel; + *(q++) = static_cast(pixel); break; } @@ -236,9 +236,9 @@ namespace gcn { for (; x1 <= x2; ++x1) { - p[0] = (pixel >> 16) & 0xff; - p[1] = (pixel >> 8) & 0xff; - p[2] = pixel & 0xff; + p[0] = static_cast((pixel >> 16) & 0xff); + p[1] = static_cast((pixel >> 8) & 0xff); + p[2] = static_cast(pixel & 0xff); p += 3; } } @@ -246,9 +246,9 @@ namespace gcn { for (; x1 <= x2; ++x1) { - p[0] = pixel & 0xff; - p[1] = (pixel >> 8) & 0xff; - p[2] = (pixel >> 16) & 0xff; + p[0] = static_cast(pixel & 0xff); + p[1] = static_cast((pixel >> 8) & 0xff); + p[2] = static_cast((pixel >> 16) & 0xff); p += 3; } } @@ -261,12 +261,13 @@ namespace gcn { if (mAlpha) { - *q = SDLAlpha32(pixel, *q, mColor.a); + *q = SDLAlpha32(pixel, *q, + static_cast(mColor.a)); q++; } else { - *(q++) = pixel; + *(q++) = static_cast(pixel); } } break; @@ -325,15 +326,17 @@ namespace gcn uint8_t *p = static_cast(mTarget->pixels) + y1 * mTarget->pitch + x * bpp; - uint32_t pixel = SDL_MapRGB(mTarget->format, mColor.r, - mColor.g, mColor.b); + uint32_t pixel = SDL_MapRGB(mTarget->format, + static_cast(mColor.r), + static_cast(mColor.g), + static_cast(mColor.b)); switch (bpp) { case 1: for (; y1 <= y2; ++y1) { - *p = pixel; + *p = static_cast(pixel); p += mTarget->pitch; } break; @@ -341,7 +344,8 @@ namespace gcn case 2: for (; y1 <= y2; ++ y1) { - *reinterpret_cast(p) = pixel; + *reinterpret_cast(p) + = static_cast(pixel); p += mTarget->pitch; } break; @@ -351,9 +355,9 @@ namespace gcn { for (; y1 <= y2; ++y1) { - p[0] = (pixel >> 16) & 0xff; - p[1] = (pixel >> 8) & 0xff; - p[2] = pixel & 0xff; + p[0] = static_cast((pixel >> 16) & 0xff); + p[1] = static_cast((pixel >> 8) & 0xff); + p[2] = static_cast(pixel & 0xff); p += mTarget->pitch; } } @@ -361,9 +365,9 @@ namespace gcn { for (; y1 <= y2; ++y1) { - p[0] = pixel & 0xff; - p[1] = (pixel >> 8) & 0xff; - p[2] = (pixel >> 16) & 0xff; + p[0] = static_cast(pixel & 0xff); + p[1] = static_cast((pixel >> 8) & 0xff); + p[2] = static_cast((pixel >> 16) & 0xff); p += mTarget->pitch; } } @@ -375,7 +379,8 @@ namespace gcn if (mAlpha) { *reinterpret_cast(p) = SDLAlpha32(pixel, - *reinterpret_cast(p), mColor.a); + *reinterpret_cast(p), + static_cast(mColor.a)); } else { -- cgit v1.2.3-70-g09d2