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/include/guichan/sdl/sdlpixel.hpp | 74 ++++++++++++++-------------- src/guichan/sdl/sdlgraphics.cpp | 69 ++++++++++++++------------ 2 files changed, 73 insertions(+), 70 deletions(-) (limited to 'src/guichan') diff --git a/src/guichan/include/guichan/sdl/sdlpixel.hpp b/src/guichan/include/guichan/sdl/sdlpixel.hpp index 23298ef37..0aaa3c5fb 100644 --- a/src/guichan/include/guichan/sdl/sdlpixel.hpp +++ b/src/guichan/include/guichan/sdl/sdlpixel.hpp @@ -1,4 +1,4 @@ -/* _______ __ __ __ ______ __ __ _______ __ __ +/* _______ __ __ __ ______ __ __ _______ __ __ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / @@ -68,7 +68,7 @@ namespace gcn SDL_LockSurface(surface); - Uint8 *p = static_cast(surface->pixels) + Uint8 *p = static_cast(surface->pixels) + y * surface->pitch + x * bpp; unsigned int color = 0; @@ -124,33 +124,35 @@ namespace gcn SDL_LockSurface(surface); - Uint8 *p = static_cast(surface->pixels) + Uint8 *p = static_cast(surface->pixels) + y * surface->pitch + x * bpp; - Uint32 pixel = SDL_MapRGB(surface->format, color.r, color.g, color.b); + Uint32 pixel = SDL_MapRGB(surface->format, + static_cast(color.r), static_cast(color.g), + static_cast(color.b)); switch (bpp) { case 1: - *p = pixel; + *p = static_cast(pixel); break; case 2: - *reinterpret_cast(p) = pixel; + *reinterpret_cast(p) = static_cast(pixel); break; case 3: if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { - 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); } else { - 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); } break; @@ -232,54 +234,50 @@ namespace gcn SDL_LockSurface(surface); - Uint8 *p = static_cast(surface->pixels) + Uint8 *p = static_cast(surface->pixels) + y * surface->pitch + x * bpp; - Uint32 pixel = SDL_MapRGB(surface->format, color.r, color.g, color.b); + Uint32 pixel = SDL_MapRGB(surface->format, static_cast(color.r), + static_cast(color.g), static_cast(color.b)); switch (bpp) { case 1: - *p = pixel; + *p = static_cast(pixel); break; case 2: - *reinterpret_cast(p) = SDLAlpha16(pixel, - *reinterpret_cast(p), color.a, surface->format); + *reinterpret_cast(p) = SDLAlpha16( + static_cast(pixel), + *reinterpret_cast(p), + static_cast(color.a), surface->format); break; case 3: if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { - unsigned int r = (p[0] * (255 - color.a) - + color.r * color.a) >> 8; - unsigned int g = (p[1] * (255 - color.a) - + color.g * color.a) >> 8; - unsigned int b = (p[2] * (255 - color.a) - + color.b * color.a) >> 8; - - p[2] = b; - p[1] = g; - p[0] = r; + p[2] = static_cast((p[2] * (255 - color.a) + + color.b * color.a) >> 8); + p[1] = static_cast((p[1] * (255 - color.a) + + color.g * color.a) >> 8); + p[0] = static_cast((p[0] * (255 - color.a) + + color.r * color.a) >> 8); } else { - unsigned int r = (p[2] * (255 - color.a) - + color.r * color.a) >> 8; - unsigned int g = (p[1] * (255 - color.a) - + color.g * color.a) >> 8; - unsigned int b = (p[0] * (255 - color.a) - + color.b * color.a) >> 8; - - p[0] = b; - p[1] = g; - p[2] = r; + p[0] = static_cast((p[0] * (255 - color.a) + + color.b * color.a) >> 8); + p[1] = static_cast((p[1] * (255 - color.a) + + color.g * color.a) >> 8); + p[2] = static_cast((p[2] * (255 - color.a) + + color.r * color.a) >> 8); } break; case 4: *reinterpret_cast(p) = SDLAlpha32(pixel, - *reinterpret_cast(p), color.a); + *reinterpret_cast(p), + static_cast(color.a)); break; default: break; 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