From 7877fee3fa573d2c13cf40f5054a9011ddc4a14d Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Thu, 2 Jun 2011 06:02:45 +0200 Subject: [PATCH] Surface: Remove alpha flag. As for SurfaceCollection, the alpha flag passed to the Surface constructor was also always true. Therefore there is no need to have the flag. --- src/surface.cpp | 11 ++++------- src/surface.h | 4 ++-- src/surfacecollection.cpp | 4 ++-- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/surface.cpp b/src/surface.cpp index 13ca2e6..264ea3c 100644 --- a/src/surface.cpp +++ b/src/surface.cpp @@ -49,10 +49,10 @@ Surface::Surface(Surface *s) { halfH = raw->h/2; } -Surface::Surface(const string &img, const string &skin, bool alpha) { +Surface::Surface(const string &img, const string &skin) { raw = NULL; dblbuffer = NULL; - load(img, alpha, skin); + load(img, skin); halfW = raw->w/2; halfH = raw->h/2; } @@ -78,7 +78,7 @@ SDL_PixelFormat *Surface::format() { return raw->format; } -void Surface::load(const string &img, bool alpha, const string &skin) { +void Surface::load(const string &img, const string &skin) { free(); string skinpath; @@ -92,10 +92,7 @@ void Surface::load(const string &img, bool alpha, const string &skin) { SDL_Surface *buf = loadPNG(skinpath); if (buf!=NULL) { - if (alpha) - raw = SDL_DisplayFormatAlpha(buf); - else - raw = SDL_DisplayFormat(buf); + raw = SDL_DisplayFormatAlpha(buf); SDL_FreeSurface(buf); } else { ERROR("Couldn't load surface '%s'\n", img.c_str()); diff --git a/src/surface.h b/src/surface.h index 6e3bc8b..98fbdcc 100644 --- a/src/surface.h +++ b/src/surface.h @@ -41,7 +41,7 @@ class Surface { public: Surface(); Surface(Surface *s); - Surface(const string &img, const string &skin="", bool alpha=true); + Surface(const string &img, const string &skin=""); ~Surface(); void enableVirtualDoubleBuffer(SDL_Surface *surface); @@ -75,7 +75,7 @@ public: private: SDL_PixelFormat *format(); - void load(const string &img, bool alpha=true, const string &skin=""); + void load(const string &img, const string &skin); bool blit(SDL_Surface *destination, int x, int y, int w=0, int h=0, int a=-1); bool blitCenter(SDL_Surface *destination, int x, int y, int w=0, int h=0, int a=-1); bool blitRight(SDL_Surface *destination, int x, int y, int w=0, int h=0, int a=-1); diff --git a/src/surfacecollection.cpp b/src/surfacecollection.cpp index 6d8d755..4774aa0 100644 --- a/src/surfacecollection.cpp +++ b/src/surfacecollection.cpp @@ -80,7 +80,7 @@ Surface *SurfaceCollection::add(const string &path) { return NULL; } else if (!fileExists(filePath)) return NULL; - Surface *s = new Surface(filePath, ""); + Surface *s = new Surface(filePath); surfaces[path] = s; return s; } @@ -94,7 +94,7 @@ Surface *SurfaceCollection::addSkinRes(const string &path) { string skinpath = getSkinFilePath(path); if (skinpath.empty()) return NULL; - Surface *s = new Surface(skinpath, "", true); + Surface *s = new Surface(skinpath); if (s != NULL) surfaces[path] = s; return s;