summaryrefslogtreecommitdiff
path: root/src/utils/sdlpixel.h
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-02-20 22:36:48 +0300
committerAndrei Karas <akaras@inbox.ru>2014-02-20 22:36:48 +0300
commitd83c6dd523827087681f019ebfca8798380dc968 (patch)
tree65515ef8405399007fef057bc37dc39ab1911000 /src/utils/sdlpixel.h
parent26f9aad24bc50d4e9fd161d185df049c9e7a62cf (diff)
downloadmv-d83c6dd523827087681f019ebfca8798380dc968.tar.gz
mv-d83c6dd523827087681f019ebfca8798380dc968.tar.bz2
mv-d83c6dd523827087681f019ebfca8798380dc968.tar.xz
mv-d83c6dd523827087681f019ebfca8798380dc968.zip
fix code style.
Diffstat (limited to 'src/utils/sdlpixel.h')
-rw-r--r--src/utils/sdlpixel.h29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/utils/sdlpixel.h b/src/utils/sdlpixel.h
index 692615688..a01858831 100644
--- a/src/utils/sdlpixel.h
+++ b/src/utils/sdlpixel.h
@@ -80,14 +80,14 @@ inline void SDLputPixel(SDL_Surface* surface, int x, int y,
if (!surface)
return;
- int bpp = surface->format->BytesPerPixel;
+ const int bpp = surface->format->BytesPerPixel;
SDL_LockSurface(surface);
- Uint8 *p = static_cast<uint8_t*>(surface->pixels)
+ Uint8 *const p = static_cast<uint8_t*>(surface->pixels)
+ y * surface->pitch + x * bpp;
- Uint32 pixel = SDL_MapRGB(surface->format,
+ const Uint32 pixel = SDL_MapRGB(surface->format,
static_cast<uint8_t>(color.r), static_cast<uint8_t>(color.g),
static_cast<uint8_t>(color.b));
@@ -131,13 +131,14 @@ inline void SDLputPixel(SDL_Surface* surface, int x, int y,
* @param dst the destination color.
* @param a alpha.
*/
-inline unsigned int SDLAlpha32(unsigned int src, unsigned int dst,
- unsigned char a)
+inline unsigned int SDLAlpha32(const unsigned int src,
+ const unsigned int dst,
+ const unsigned char a)
{
- unsigned int b = ((src & 0xff) * a + (dst & 0xff) * (255 - a)) >> 8;
- unsigned int g = ((src & 0xff00) * a + (dst & 0xff00)
+ const unsigned int b = ((src & 0xff) * a + (dst & 0xff) * (255 - a)) >> 8;
+ const unsigned int g = ((src & 0xff00) * a + (dst & 0xff00)
* (255 - a)) >> 8;
- unsigned int r = ((src & 0xff0000) * a + (dst & 0xff0000)
+ const unsigned int r = ((src & 0xff0000) * a + (dst & 0xff0000)
* (255 - a)) >> 8;
return (b & 0xff) | (g & 0xff00) | (r & 0xff0000);
@@ -150,8 +151,10 @@ inline unsigned int SDLAlpha32(unsigned int src, unsigned int dst,
* @param dst the destination color.
* @param a alpha.
*/
-inline unsigned short SDLAlpha16(unsigned short src, unsigned short dst,
- unsigned char a, const SDL_PixelFormat *f)
+inline unsigned short SDLAlpha16(const unsigned short src,
+ const unsigned short dst,
+ const unsigned char a,
+ const SDL_PixelFormat *const f)
{
unsigned int b = ((src & f->Rmask) * a + (dst & f->Rmask)
* (255 - a)) >> 8;
@@ -174,14 +177,14 @@ inline unsigned short SDLAlpha16(unsigned short src, unsigned short dst,
inline void SDLputPixelAlpha(SDL_Surface* surface, int x, int y,
const gcn::Color& color)
{
- int bpp = surface->format->BytesPerPixel;
+ const int bpp = surface->format->BytesPerPixel;
SDL_LockSurface(surface);
- Uint8 *p = static_cast<uint8_t*>(surface->pixels)
+ Uint8 *const p = static_cast<uint8_t*>(surface->pixels)
+ y * surface->pitch + x * bpp;
- Uint32 pixel = SDL_MapRGB(surface->format,
+ const Uint32 pixel = SDL_MapRGB(surface->format,
static_cast<uint8_t>(color.r),
static_cast<uint8_t>(color.g),
static_cast<uint8_t>(color.b));