Date:2014-07-17 18:41:11 (2 months 3 days ago)
Author:Maarten ter Huurne
Commit:2a4b5192824e206b84ca4e70736661fc4edbb226
Message:Removed return code from surface drawing methods

Not a single caller actually checked the return codes.
Files: src/surface.cpp (4 diffs)
src/surface.h (2 diffs)

Change Details

src/surface.cpp
112112    SDL_Flip(raw);
113113}
114114
115bool Surface::blit(SDL_Surface *destination, int x, int y, int w, int h, int a) const {
116    if (destination == NULL || a==0) return false;
115void Surface::blit(SDL_Surface *destination, int x, int y, int w, int h, int a) const {
116    if (destination == NULL || a==0) return;
117117
118118    SDL_Rect src = { 0, 0, static_cast<Uint16>(w), static_cast<Uint16>(h) };
119119    SDL_Rect dest;
...... 
121121    dest.y = y;
122122    if (a>0 && a!=raw->format->alpha)
123123        SDL_SetAlpha(raw, SDL_SRCALPHA|SDL_RLEACCEL, a);
124    return SDL_BlitSurface(raw, (w==0 || h==0) ? NULL : &src, destination, &dest);
124    SDL_BlitSurface(raw, (w==0 || h==0) ? NULL : &src, destination, &dest);
125125}
126bool Surface::blit(Surface *destination, int x, int y, int w, int h, int a) const {
127    return blit(destination->raw,x,y,w,h,a);
126void Surface::blit(Surface *destination, int x, int y, int w, int h, int a) const {
127    blit(destination->raw,x,y,w,h,a);
128128}
129129
130bool Surface::blitCenter(SDL_Surface *destination, int x, int y, int w, int h, int a) const {
130void Surface::blitCenter(SDL_Surface *destination, int x, int y, int w, int h, int a) const {
131131    int oh, ow;
132132    if (w==0) ow = halfW; else ow = min(halfW,w/2);
133133    if (h==0) oh = halfH; else oh = min(halfH,h/2);
134    return blit(destination,x-ow,y-oh,w,h,a);
134    blit(destination,x-ow,y-oh,w,h,a);
135135}
136bool Surface::blitCenter(Surface *destination, int x, int y, int w, int h, int a) const {
137    return blitCenter(destination->raw,x,y,w,h,a);
136void Surface::blitCenter(Surface *destination, int x, int y, int w, int h, int a) const {
137    blitCenter(destination->raw,x,y,w,h,a);
138138}
139139
140bool Surface::blitRight(SDL_Surface *destination, int x, int y, int w, int h, int a) const {
140void Surface::blitRight(SDL_Surface *destination, int x, int y, int w, int h, int a) const {
141141    if (!w) w = raw->w;
142    return blit(destination,x-min(raw->w,w),y,w,h,a);
142    blit(destination,x-min(raw->w,w),y,w,h,a);
143143}
144bool Surface::blitRight(Surface *destination, int x, int y, int w, int h, int a) const {
144void Surface::blitRight(Surface *destination, int x, int y, int w, int h, int a) const {
145145    if (!w) w = raw->w;
146    return blitRight(destination->raw,x,y,w,h,a);
146    blitRight(destination->raw,x,y,w,h,a);
147147}
148148
149int Surface::box(Sint16 x, Sint16 y, Uint16 w, Uint16 h, Uint8 r, Uint8 g, Uint8 b, Uint8 a) {
150    return boxRGBA(raw, x, y, x + w - 1, y + h - 1, r, g, b, a);
149void Surface::box(Sint16 x, Sint16 y, Uint16 w, Uint16 h, Uint8 r, Uint8 g, Uint8 b, Uint8 a) {
150    boxRGBA(raw, x, y, x + w - 1, y + h - 1, r, g, b, a);
151151}
152int Surface::box(Sint16 x, Sint16 y, Uint16 w, Uint16 h, Uint8 r, Uint8 g, Uint8 b) {
152void Surface::box(Sint16 x, Sint16 y, Uint16 w, Uint16 h, Uint8 r, Uint8 g, Uint8 b) {
153153    SDL_Rect re = { x, y, w, h };
154    return SDL_FillRect(raw, &re, SDL_MapRGBA(raw->format, r, g, b, 255));
154    SDL_FillRect(raw, &re, SDL_MapRGBA(raw->format, r, g, b, 255));
155155}
156int Surface::box(Sint16 x, Sint16 y, Uint16 w, Uint16 h, RGBAColor c) {
157    return box(x, y, w, h, c.r, c.g, c.b, c.a);
156void Surface::box(Sint16 x, Sint16 y, Uint16 w, Uint16 h, RGBAColor c) {
157    box(x, y, w, h, c.r, c.g, c.b, c.a);
158158}
159int Surface::box(SDL_Rect re, RGBAColor c) {
160    return boxRGBA(
161        raw, re.x, re.y, re.x + re.w - 1, re.y + re.h - 1, c.r, c.g, c.b, c.a
162        );
159void Surface::box(SDL_Rect re, RGBAColor c) {
160    boxRGBA(raw, re.x, re.y, re.x + re.w - 1, re.y + re.h - 1, c.r, c.g, c.b, c.a);
163161}
164162
165int Surface::rectangle(Sint16 x, Sint16 y, Uint16 w, Uint16 h, Uint8 r, Uint8 g, Uint8 b, Uint8 a) {
166    return rectangleRGBA(raw, x, y, x + w - 1, y + h - 1, r, g, b, a);
163void Surface::rectangle(Sint16 x, Sint16 y, Uint16 w, Uint16 h, Uint8 r, Uint8 g, Uint8 b, Uint8 a) {
164    rectangleRGBA(raw, x, y, x + w - 1, y + h - 1, r, g, b, a);
167165}
168int Surface::rectangle(Sint16 x, Sint16 y, Uint16 w, Uint16 h, RGBAColor c) {
169    return rectangle(x, y, w, h, c.r, c.g, c.b, c.a);
166void Surface::rectangle(Sint16 x, Sint16 y, Uint16 w, Uint16 h, RGBAColor c) {
167    rectangle(x, y, w, h, c.r, c.g, c.b, c.a);
170168}
171int Surface::rectangle(SDL_Rect re, RGBAColor c) {
172    return rectangle(re.x, re.y, re.w, re.h, c.r, c.g, c.b, c.a);
169void Surface::rectangle(SDL_Rect re, RGBAColor c) {
170    rectangle(re.x, re.y, re.w, re.h, c.r, c.g, c.b, c.a);
173171}
174172
175173void Surface::clearClipRect() {
...... 
188186    SDL_SetClipRect(raw,&rect);
189187}
190188
191bool Surface::blit(Surface *destination, SDL_Rect container, Font::HAlign halign, Font::VAlign valign) const {
189void Surface::blit(Surface *destination, SDL_Rect container, Font::HAlign halign, Font::VAlign valign) const {
192190    switch (halign) {
193191    case Font::HAlignLeft:
194192        break;
...... 
211209        break;
212210    }
213211
214    return blit(destination,container.x,container.y);
212    blit(destination,container.x,container.y);
215213}
src/surface.h
6161    void setClipRect(int x, int y, int w, int h);
6262    void setClipRect(SDL_Rect rect);
6363
64    bool blit(Surface *destination, int x, int y, int w=0, int h=0, int a=-1) const;
65    bool blit(Surface *destination, SDL_Rect container, Font::HAlign halign = Font::HAlignLeft, Font::VAlign valign = Font::VAlignTop) const;
66    bool blitCenter(Surface *destination, int x, int y, int w=0, int h=0, int a=-1) const;
67    bool blitRight(Surface *destination, int x, int y, int w=0, int h=0, int a=-1) const;
64    void blit(Surface *destination, int x, int y, int w=0, int h=0, int a=-1) const;
65    void blit(Surface *destination, SDL_Rect container, Font::HAlign halign = Font::HAlignLeft, Font::VAlign valign = Font::VAlignTop) const;
66    void blitCenter(Surface *destination, int x, int y, int w=0, int h=0, int a=-1) const;
67    void blitRight(Surface *destination, int x, int y, int w=0, int h=0, int a=-1) const;
6868
6969    void write(Font *font, const std::string &text, int x, int y,
7070            Font::HAlign halign = Font::HAlignLeft,
...... 
7272        font->write(this, text, x, y, halign, valign);
7373    }
7474
75    int box(Sint16 x, Sint16 y, Uint16 w, Uint16 h, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
76    int box(Sint16 x, Sint16 y, Uint16 w, Uint16 h, Uint8 r, Uint8 g, Uint8 b);
77    int box(Sint16 x, Sint16 y, Uint16 w, Uint16 h, RGBAColor);
78    int box(SDL_Rect, RGBAColor);
79    int rectangle(Sint16, Sint16, Uint16, Uint16, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
80    int rectangle(Sint16, Sint16, Uint16, Uint16, RGBAColor);
81    int rectangle(SDL_Rect, RGBAColor);
75    void box(Sint16 x, Sint16 y, Uint16 w, Uint16 h, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
76    void box(Sint16 x, Sint16 y, Uint16 w, Uint16 h, Uint8 r, Uint8 g, Uint8 b);
77    void box(Sint16 x, Sint16 y, Uint16 w, Uint16 h, RGBAColor);
78    void box(SDL_Rect, RGBAColor);
79    void rectangle(Sint16, Sint16, Uint16, Uint16, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
80    void rectangle(Sint16, Sint16, Uint16, Uint16, RGBAColor);
81    void rectangle(SDL_Rect, RGBAColor);
8282
8383private:
8484    Surface(SDL_Surface *raw, bool freeWhenDone);
85    bool blit(SDL_Surface *destination, int x, int y, int w=0, int h=0, int a=-1) const;
86    bool blitCenter(SDL_Surface *destination, int x, int y, int w=0, int h=0, int a=-1) const;
87    bool blitRight(SDL_Surface *destination, int x, int y, int w=0, int h=0, int a=-1) const;
85    void blit(SDL_Surface *destination, int x, int y, int w=0, int h=0, int a=-1) const;
86    void blitCenter(SDL_Surface *destination, int x, int y, int w=0, int h=0, int a=-1) const;
87    void blitRight(SDL_Surface *destination, int x, int y, int w=0, int h=0, int a=-1) const;
8888
8989    SDL_Surface *raw;
9090    bool freeWhenDone;

Archive Download the corresponding diff file



interactive