summaryrefslogtreecommitdiff
path: root/src/guichan
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-07-17 23:26:59 +0300
committerAndrei Karas <akaras@inbox.ru>2012-07-17 23:26:59 +0300
commit7e0a97d2521b9ce57003176e82a0b5564aa003c2 (patch)
tree5b2cfe1afe09bea1063f783050c1fb549daee76d /src/guichan
parentf68cbf700a99f2f184715a5b8025bcb4b6525391 (diff)
downloadplus-7e0a97d2521b9ce57003176e82a0b5564aa003c2.tar.gz
plus-7e0a97d2521b9ce57003176e82a0b5564aa003c2.tar.bz2
plus-7e0a97d2521b9ce57003176e82a0b5564aa003c2.tar.xz
plus-7e0a97d2521b9ce57003176e82a0b5564aa003c2.zip
Fix more code style and additional warnings.
Diffstat (limited to 'src/guichan')
-rw-r--r--src/guichan/include/guichan/sdl/sdlpixel.hpp74
-rw-r--r--src/guichan/sdl/sdlgraphics.cpp69
2 files changed, 73 insertions, 70 deletions
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<Uint8*>(surface->pixels)
+ Uint8 *p = static_cast<uint8_t*>(surface->pixels)
+ y * surface->pitch + x * bpp;
unsigned int color = 0;
@@ -124,33 +124,35 @@ namespace gcn
SDL_LockSurface(surface);
- Uint8 *p = static_cast<Uint8*>(surface->pixels)
+ Uint8 *p = static_cast<uint8_t*>(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<uint8_t>(color.r), static_cast<uint8_t>(color.g),
+ static_cast<uint8_t>(color.b));
switch (bpp)
{
case 1:
- *p = pixel;
+ *p = static_cast<uint8_t>(pixel);
break;
case 2:
- *reinterpret_cast<Uint16*>(p) = pixel;
+ *reinterpret_cast<uint16_t*>(p) = static_cast<uint16_t>(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<uint8_t>((pixel >> 16) & 0xff);
+ p[1] = static_cast<uint8_t>((pixel >> 8) & 0xff);
+ p[2] = static_cast<uint8_t>((pixel) & 0xff);
}
else
{
- p[0] = pixel & 0xff;
- p[1] = (pixel >> 8) & 0xff;
- p[2] = (pixel >> 16) & 0xff;
+ p[0] = static_cast<uint8_t>((pixel) & 0xff);
+ p[1] = static_cast<uint8_t>((pixel >> 8) & 0xff);
+ p[2] = static_cast<uint8_t>((pixel >> 16) & 0xff);
}
break;
@@ -232,54 +234,50 @@ namespace gcn
SDL_LockSurface(surface);
- Uint8 *p = static_cast<Uint8*>(surface->pixels)
+ Uint8 *p = static_cast<uint8_t*>(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<uint8_t>(color.r),
+ static_cast<uint8_t>(color.g), static_cast<uint8_t>(color.b));
switch (bpp)
{
case 1:
- *p = pixel;
+ *p = static_cast<uint8_t>(pixel);
break;
case 2:
- *reinterpret_cast<Uint16*>(p) = SDLAlpha16(pixel,
- *reinterpret_cast<Uint32*>(p), color.a, surface->format);
+ *reinterpret_cast<Uint16*>(p) = SDLAlpha16(
+ static_cast<unsigned short>(pixel),
+ *reinterpret_cast<unsigned short*>(p),
+ static_cast<unsigned char>(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<uint8_t>((p[2] * (255 - color.a)
+ + color.b * color.a) >> 8);
+ p[1] = static_cast<uint8_t>((p[1] * (255 - color.a)
+ + color.g * color.a) >> 8);
+ p[0] = static_cast<uint8_t>((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<uint8_t>((p[0] * (255 - color.a)
+ + color.b * color.a) >> 8);
+ p[1] = static_cast<uint8_t>((p[1] * (255 - color.a)
+ + color.g * color.a) >> 8);
+ p[2] = static_cast<uint8_t>((p[2] * (255 - color.a)
+ + color.r * color.a) >> 8);
}
break;
case 4:
*reinterpret_cast<Uint32*>(p) = SDLAlpha32(pixel,
- *reinterpret_cast<Uint32*>(p), color.a);
+ *reinterpret_cast<Uint32*>(p),
+ static_cast<unsigned char>(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<int16_t>(carea.x);
+ rect.y = static_cast<int16_t>(carea.y);
+ rect.w = static_cast<int16_t>(carea.width);
+ rect.h = static_cast<int16_t>(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<int16_t>(carea.x);
+ rect.y = static_cast<int16_t>(carea.y);
+ rect.w = static_cast<int16_t>(carea.width);
+ rect.h = static_cast<int16_t>(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<uint8_t>(mColor.r),
+ static_cast<uint8_t>(mColor.g),
+ static_cast<uint8_t>(mColor.b));
switch (bpp)
{
case 1:
for (; x1 <= x2; ++x1)
- *(p++) = pixel;
+ *(p++) = static_cast<uint8_t>(pixel);
break;
case 2:
{
uint16_t* q = reinterpret_cast<uint16_t*>(p);
for (; x1 <= x2; ++x1)
- *(q++) = pixel;
+ *(q++) = static_cast<uint8_t>(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<uint8_t>((pixel >> 16) & 0xff);
+ p[1] = static_cast<uint8_t>((pixel >> 8) & 0xff);
+ p[2] = static_cast<uint8_t>(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<uint8_t>(pixel & 0xff);
+ p[1] = static_cast<uint8_t>((pixel >> 8) & 0xff);
+ p[2] = static_cast<uint8_t>((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<unsigned char>(mColor.a));
q++;
}
else
{
- *(q++) = pixel;
+ *(q++) = static_cast<uint8_t>(pixel);
}
}
break;
@@ -325,15 +326,17 @@ namespace gcn
uint8_t *p = static_cast<uint8_t*>(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<uint8_t>(mColor.r),
+ static_cast<uint8_t>(mColor.g),
+ static_cast<uint8_t>(mColor.b));
switch (bpp)
{
case 1:
for (; y1 <= y2; ++y1)
{
- *p = pixel;
+ *p = static_cast<uint8_t>(pixel);
p += mTarget->pitch;
}
break;
@@ -341,7 +344,8 @@ namespace gcn
case 2:
for (; y1 <= y2; ++ y1)
{
- *reinterpret_cast<uint16_t*>(p) = pixel;
+ *reinterpret_cast<uint16_t*>(p)
+ = static_cast<uint16_t>(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<uint8_t>((pixel >> 16) & 0xff);
+ p[1] = static_cast<uint8_t>((pixel >> 8) & 0xff);
+ p[2] = static_cast<uint8_t>(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<uint8_t>(pixel & 0xff);
+ p[1] = static_cast<uint8_t>((pixel >> 8) & 0xff);
+ p[2] = static_cast<uint8_t>((pixel >> 16) & 0xff);
p += mTarget->pitch;
}
}
@@ -375,7 +379,8 @@ namespace gcn
if (mAlpha)
{
*reinterpret_cast<uint32_t*>(p) = SDLAlpha32(pixel,
- *reinterpret_cast<uint32_t*>(p), mColor.a);
+ *reinterpret_cast<uint32_t*>(p),
+ static_cast<unsigned char>(mColor.a));
}
else
{