From b248aaf8089fdd4ac41136f1eef3b8668e24fcc3 Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Tue, 10 Apr 2012 22:33:43 +0200 Subject: [PATCH] Surface cleanup. Use unsigned ints for width and height, like SDL does. We're using the SDL typedefs there after all. Include argument names in header when type name does tell everything. Use whitespace in argument lists. --- src/surface.cpp | 28 ++++++++++++++-------------- src/surface.h | 12 ++++++------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/surface.cpp b/src/surface.cpp index 3b45c43..182f9f7 100644 --- a/src/surface.cpp +++ b/src/surface.cpp @@ -146,15 +146,15 @@ bool Surface::blitRight(Surface *destination, int x, int y, int w, int h, int a) return blitRight(destination->raw,x,y,w,h,a); } -int Surface::box(Sint16 x, Sint16 y, Sint16 w, Sint16 h, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { - return boxRGBA(raw,x,y,x+w-1,y+h-1,r,g,b,a); +int Surface::box(Sint16 x, Sint16 y, Uint16 w, Uint16 h, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { + return boxRGBA(raw, x, y, x + w - 1, y + h - 1, r, g, b, a); } -int Surface::box(Sint16 x, Sint16 y, Sint16 w, Sint16 h, Uint8 r, Uint8 g, Uint8 b) { - SDL_Rect re = {x,y,w,h}; - return SDL_FillRect(raw, &re, SDL_MapRGBA(raw->format,r,g,b,255)); +int Surface::box(Sint16 x, Sint16 y, Uint16 w, Uint16 h, Uint8 r, Uint8 g, Uint8 b) { + SDL_Rect re = { x, y, w, h }; + return SDL_FillRect(raw, &re, SDL_MapRGBA(raw->format, r, g, b, 255)); } -int Surface::box(Sint16 x, Sint16 y, Sint16 w, Sint16 h, RGBAColor c) { - return box(x,y,w,h,c.r,c.g,c.b,c.a); +int Surface::box(Sint16 x, Sint16 y, Uint16 w, Uint16 h, RGBAColor c) { + return box(x, y, w, h, c.r, c.g, c.b, c.a); } int Surface::box(SDL_Rect re, RGBAColor c) { return boxRGBA( @@ -162,18 +162,18 @@ int Surface::box(SDL_Rect re, RGBAColor c) { ); } -int Surface::rectangle(Sint16 x, Sint16 y, Sint16 w, Sint16 h, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { - return rectangleRGBA(raw,x,y,x+w-1,y+h-1,r,g,b,a); +int Surface::rectangle(Sint16 x, Sint16 y, Uint16 w, Uint16 h, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { + return rectangleRGBA(raw, x, y, x + w - 1, y + h - 1, r, g, b, a); } -int Surface::rectangle(Sint16 x, Sint16 y, Sint16 w, Sint16 h, RGBAColor c) { - return rectangle(x,y,w,h,c.r,c.g,c.b,c.a); +int Surface::rectangle(Sint16 x, Sint16 y, Uint16 w, Uint16 h, RGBAColor c) { + return rectangle(x, y, w, h, c.r, c.g, c.b, c.a); } int Surface::rectangle(SDL_Rect re, RGBAColor c) { - return rectangle(re.x,re.y,re.w,re.h,c.r,c.g,c.b,c.a); + return rectangle(re.x, re.y, re.w, re.h, c.r, c.g, c.b, c.a); } -int Surface::hline(Sint16 x, Sint16 y, Sint16 w, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { - return hlineRGBA(raw,x,x+w-1,y,r,g,b,a); +int Surface::hline(Sint16 x, Sint16 y, Uint16 w, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { + return hlineRGBA(raw, x, x + w - 1, y, r, g, b, a); } void Surface::clearClipRect() { diff --git a/src/surface.h b/src/surface.h index c15a3a6..c9bd04c 100644 --- a/src/surface.h +++ b/src/surface.h @@ -72,14 +72,14 @@ public: font->write(this, text, x, y, halign, valign); } - int box(Sint16, Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8); - int box(Sint16, Sint16, Sint16, Sint16, Uint8, Uint8, Uint8); - int box(Sint16, Sint16, Sint16, Sint16, RGBAColor); + int box(Sint16 x, Sint16 y, Uint16 w, Uint16 h, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + int box(Sint16 x, Sint16 y, Uint16 w, Uint16 h, Uint8 r, Uint8 g, Uint8 b); + int box(Sint16 x, Sint16 y, Uint16 w, Uint16 h, RGBAColor); int box(SDL_Rect, RGBAColor); - int rectangle(Sint16, Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8); - int rectangle(Sint16, Sint16, Sint16, Sint16, RGBAColor); + int rectangle(Sint16, Sint16, Uint16, Uint16, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + int rectangle(Sint16, Sint16, Uint16, Uint16, RGBAColor); int rectangle(SDL_Rect, RGBAColor); - int hline(Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8); + int hline(Sint16 x, Sint16 y, Uint16 h, Uint8 r, Uint8 g, Uint8 b, Uint8 a); private: Surface(SDL_Surface *raw, bool freeWhenDone);