#include <sdlsurface.h>
Inheritance diagram for Wt::SDLSurface:
Public Types | |
IgnoreEndian | |
BigEndian = SDL_BIG_ENDIAN | |
LittleEndian = SDL_LIL_ENDIAN | |
ScaleFree | |
ScaleMin | |
ScaleMax | |
enum | Endian { IgnoreEndian, BigEndian = SDL_BIG_ENDIAN, LittleEndian = SDL_LIL_ENDIAN } |
enum | ScaleMode { ScaleFree, ScaleMin, ScaleMax } |
Public Member Functions | |
SDLSurface (int w, int h, int depth=-1, int flags=0) | |
constructor for a sized surface | |
SDLSurface (SDL_Surface *surface=0) | |
constructor from SDL_Surface. we take over ownership | |
SDLSurface (const std::string &filename) | |
constructor from file | |
operator const SDL_Surface * () const | |
operator SDL_Surface * () | |
int | lock () |
int | unlock () |
void | detach () |
int | pixel (int pixel_offset) const |
SDLColor | pixelColor (int pixel_offset) const |
int | pixel (int x, int y) const |
SDLColor | pixelColor (int x, int y) const |
void | setPixel (int pixel_offset, int pixel_value) |
void | setPixelColor (int pixel_offset, const SDLColor &color) |
void | setPixel (int x, int y, int pixel_value) |
void | setPixelColor (int x, int y, const SDLColor &color) |
Informative methods | |
int | flags () const |
bool | isSWSurface () const |
bool | isHWSurface () const |
bool | hasAsyncBlit () const |
bool | hasHWPalette () const |
bool | hasHWAcceleration () const |
bool | hasTransparentColor () const |
bool | hasRLEAccell () const |
bool | hasAlpha () const |
bool | isTransparent () const |
bool | isOpaque () const |
bool | isPreallocated () const |
const SDLPixelFormat | pixelFormat () const |
int | width () const |
int | height () const |
int | bytesPerLine () const |
const void * | pixels () const |
int | depth () const |
void * | pixels () |
void * | bits () |
int | pixelOffset (int x, int y) const |
void * | pixelAddress (int pixel_offset) const |
void * | pixelAddress (int x, int y) const |
void * | scanLine (int y) |
size_t | numBytes () const |
int | serialNumber () const |
Clipping Methods | |
SDLRect | clipRect () const |
SDLRect | setClipRect (const SDLRect &rect) |
Colors and transparency methods | |
void | setPalette (const std::vector< SDLColor > &ca, int offset, int flags=SDLPalette::Logical|SDLPalette::Physical) |
SDLColor | color (int index) const |
void | setColor (int i, const SDLColor &c) |
int | numColors () const |
void | setNumColors (int ncolors) |
bool | isGrayscale () const |
void | setTransparentColor (const SDLColor &color=SDLColor()) |
void | clearTransparentColor () |
SDLColor | transparentColor () const |
void | setAlpha (int alpha=SDLColor::Transparent) |
void | clearAlpha () |
int | alpha () const |
Painting and blitting methods | |
int | fill (int v) |
int | fill (const SDLRect &dst, int v) |
int | blit (const SDLSurface &src) |
full blit | |
int | blit (int x, int y, const SDLSurface &src) |
blit to | |
int | blit (int x, int y, const SDLSurface &src, const SDLRect &src_rect) |
blit to from | |
int | blitAlphaCopy (const SDLSurface &src) |
copy to from src | |
int | blitAlphaCopy (int x, int y, const SDLSurface &src) |
copy to from src | |
int | blitAlphaCopy (int x, int y, const SDLSurface &src, const SDLRect &src_rect) |
copy to from src rect | |
bool | load (const std::string &fileName) |
load an image from a file | |
bool | load (const void *p, size_t size) |
load an image from mem | |
Scaling methods | |
SDLSurface | scale (int w, int h, ScaleMode mode=ScaleFree) const |
SDLSurface | smoothScale (int w, int h, ScaleMode mode=ScaleFree) const |
SDLSurface | scaleWidth (int w) const |
SDLSurface | scaleHeight (int h) const |
Surface conversion methods | |
int | convertTo (const SDLSurface src) |
int | convertToDisplay () |
int | convertDepth (int new_depth) |
void | resize (int x, int y) |
Static Public Member Functions | |
static int | defaultDepth () |
static int | systemByteOrder () |
Determines the byte order of the display hardware. | |
static int | systemBitOrder () |
Determines the bit order of the display hardware. | |
Protected Member Functions | |
int | readPixel8bpp (int pixel_offset) const |
void | writePixel8bpp (int pixel_offset, int pixel_value) |
int | readPixel16bpp (int pixel_offset) const |
void | writePixel16bpp (int pixel_offset, int pixel_value) |
int | readPixel24bpp (int pixel_offset) const |
void | writePixel24bpp (int pixel_offset, int pixel_value) |
int | readPixel32bpp (int pixel_offset) const |
void | writePixel32bpp (int pixel_offset, int pixel_value) |
void | onDepthChange () |
SDLSurface | scale_surface (int w, int h, bool smooth, ScaleMode mode) const |
Static Protected Attributes | |
static const FlagMap | flagMap |
Private Types | |
typedef boost::shared_ptr< SDL_Surface > | Ptr |
typedef int(SDLSurface::*) | readPixelFunction (int) const |
typedef void(SDLSurface::*) | writePixelFunction (int, int) |
Private Member Functions | |
operator const Ptr () const | |
operator Ptr () | |
Private Attributes | |
Ptr | sdl_surface |
readPixelFunction | read_pixel |
writePixelFunction | write_pixel |
Classes | |
class | Deleter |
boost smart pointers with it More... |
Definition at line 41 of file sdlsurface.h.
typedef boost::shared_ptr<SDL_Surface> Wt::SDLSurface::Ptr [private] |
Definition at line 346 of file sdlsurface.h.
typedef int(SDLSurface::*) Wt::SDLSurface::readPixelFunction(int) const [private] |
Definition at line 358 of file sdlsurface.h.
typedef void(SDLSurface::*) Wt::SDLSurface::writePixelFunction(int, int) [private] |
Definition at line 359 of file sdlsurface.h.
Definition at line 44 of file sdlsurface.h.
00044 { 00045 IgnoreEndian, 00046 BigEndian = SDL_BIG_ENDIAN, 00047 LittleEndian = SDL_LIL_ENDIAN 00048 } Endian;
constructor for a sized surface
Definition at line 66 of file sdlsurface.cpp.
References height(), onDepthChange(), trace, and width().
Referenced by convertDepth(), Wt::SDLDisplay::resize(), and scale_surface().
00067 : sdl_surface( 00068 SDL_CreateRGBSurface(flagMap.state(flags ? flags : static_cast<int>(W::DefaultPixmapFlags)), 00069 w, h, (depth > 0) ? depth : defaultDepth(), 00070 0, 0, 0, 0), Deleter()) { 00071 trace("sdlsurface", 00072 "Creating new SDL_Surface %p [%d x %d]\n", 00073 static_cast<SDL_Surface *>(*this), width(), height()); 00074 onDepthChange(); 00075 }
Here is the call graph for this function:
Wt::SDLSurface::SDLSurface | ( | SDL_Surface * | surface = 0 |
) |
constructor from SDL_Surface. we take over ownership
Definition at line 77 of file sdlsurface.cpp.
References height(), onDepthChange(), trace, and width().
00078 : sdl_surface(surface, Deleter()) { 00079 if (surface) { 00080 trace("sdlsurface", 00081 "Creating from existing SDL_Surface %p [%d x %d]\n", 00082 static_cast<SDL_Surface *>(*this), width(), height()); 00083 } else { 00084 trace("sdlsurface", "Creating NULL SDL_Surface %p\n", 0); 00085 } 00086 onDepthChange(); 00087 }
Here is the call graph for this function:
Wt::SDLSurface::SDLSurface | ( | const std::string & | filename | ) |
constructor from file
Definition at line 89 of file sdlsurface.cpp.
References Error, and onDepthChange().
00090 : sdl_surface(IMG_Load_RW(SDL_RWFromFile( 00091 filename.c_str(), "rb"), 1), Deleter()) { 00092 00093 if(!*this) { 00094 Error("IMG_Load_RW: %s (%s)\n", IMG_GetError(), filename.c_str()); 00095 } 00096 00097 onDepthChange(); 00098 }
Here is the call graph for this function:
int Wt::SDLSurface::alpha | ( | ) | const [inline] |
Definition at line 224 of file sdlsurface.h.
References Wt::SDLPixelFormat::alpha(), and pixelFormat().
Referenced by blitAlphaCopy(), isTransparent(), and setAlpha().
00224 { 00225 return pixelFormat().alpha(); 00226 }
Here is the call graph for this function:
void* Wt::SDLSurface::bits | ( | ) | [inline] |
Definition at line 162 of file sdlsurface.h.
References pixels().
00162 { 00163 return pixels(); 00164 }
Here is the call graph for this function:
int Wt::SDLSurface::blit | ( | int | x, | |
int | y, | |||
const SDLSurface & | src, | |||
const SDLRect & | src_rect | |||
) |
blit to from
SDL breakage
Definition at line 300 of file sdlsurface.cpp.
References Wt::deconst(), detach(), and Wt::safe_blit().
00301 { 00302 ///SDL breakage 00303 SDLRect s = src_rect; 00304 SDLRect dst(x, y, 0, 0); 00305 detach(); 00306 return safe_blit(deconst(src), s, *this, dst); 00307 }
Here is the call graph for this function:
int Wt::SDLSurface::blit | ( | int | x, | |
int | y, | |||
const SDLSurface & | src | |||
) |
blit to
Definition at line 294 of file sdlsurface.cpp.
References Wt::deconst(), detach(), and Wt::safe_blit().
00294 { 00295 SDLRect dst(x, y, 0, 0); 00296 detach(); 00297 return safe_blit(deconst(src), 0, *this, dst); 00298 }
Here is the call graph for this function:
int Wt::SDLSurface::blit | ( | const SDLSurface & | src | ) |
full blit
if (source surface has SDL_SRCALPHA set) { if (source surface has alpha channel (that is, format->Amask != 0)) blit using per-pixel alpha, ignoring any colour key else { if (source surface has SDL_SRCCOLORKEY set) blit using the colour key AND the per-surface alpha value else blit using the per-surface alpha value } } else { if (source surface has SDL_SRCCOLORKEY set) blit using the colour key else ordinary opaque rectangular blit }
Note: The per-surface alpha value of 128 is considered a special case and is optimised, so it's much faster than other per-surface values.
Alpha effects surface blitting in the following ways:
RGBA->RGB with SDL_SRCALPHA The source is alpha-blended with the destination, using the alpha channel. SDL_SRCCOLORKEY and the per-surface alpha are ignored.
RGBA->RGB without SDL_SRCALPHA The RGB data is copied from the source. The source alpha channel and the per-surface alpha value are ignored.
RGB->RGBA with SDL_SRCALPHA The source is alpha-blended with the destination using the per-surface alpha value. If SDL_SRCCOLORKEY is set, only the pixels not matching the colorkey value are copied. The alpha channel of the copied pixels is set to opaque.
RGB->RGBA without SDL_SRCALPHA The RGB data is copied from the source and the alpha value of the copied pixels is set to opaque. If SDL_SRCCOLORKEY is set, only the pixels not matching the colorkey value are copied.
RGBA->RGBA with SDL_SRCALPHA The source is alpha-blended with the destination using the source alpha channel. The alpha channel in the destination surface is left untouched. SDL_SRCCOLORKEY is ignored.
RGBA->RGBA without SDL_SRCALPHA The RGBA data is copied to the destination surface. If SDL_SRCCOLORKEY is set, only the pixels not matching the colorkey value are copied.
RGB->RGB with SDL_SRCALPHA The source is alpha-blended with the destination using the per-surface alpha value. If SDL_SRCCOLORKEY is set, only the pixels not matching the colorkey value are copied.
RGB->RGB without SDL_SRCALPHA The RGB data is copied from the source. If SDL_SRCCOLORKEY is set, only the pixels not matching the colorkey value are copied.
Note: Note that RGBA->RGBA blits (with SDL_SRCALPHA set) keep the alpha of the destination surface. This means that you cannot compose two arbitrary RGBA surfaces this way and get the result you would expect from "overlaying" them; the destination alpha will work as a mask.
Also note that per-pixel and per-surface alpha cannot be combined; the per-pixel alpha is always used if available
Definition at line 289 of file sdlsurface.cpp.
References Wt::deconst(), detach(), and Wt::safe_blit().
Referenced by blitAlphaCopy(), and convertDepth().
Here is the call graph for this function:
int Wt::SDLSurface::blitAlphaCopy | ( | int | x, | |
int | y, | |||
const SDLSurface & | src, | |||
const SDLRect & | src_rect | |||
) |
copy to from src rect
Definition at line 377 of file sdlsurface.cpp.
References alpha(), blit(), Wt::deconst(), depth(), hasAlpha(), hasTransparentColor(), Wt::SDLColor::Opaque, pixelFormat(), and Wt::SDLPixelFormat::transparentPixelValue().
00378 { 00379 assert(depth() == src.depth()); 00380 00381 bool has_alpha = src.hasAlpha(); 00382 bool has_colorkey = src.hasTransparentColor(); 00383 int alpha = 0, pv = 0; 00384 00385 // note: we can't use set/clearAlpha beacuse of detach 00386 if (has_alpha) { 00387 alpha = src.alpha(); 00388 SDL_SetAlpha(deconst(src), 0, SDLColor::Opaque); 00389 } 00390 00391 if (has_colorkey) { 00392 pv = src.pixelFormat().transparentPixelValue(); 00393 SDL_SetColorKey(deconst(src), 0, 0); 00394 } 00395 00396 int status = blit(x, y, src, src_rect); 00397 00398 if (has_alpha) { 00399 SDL_SetAlpha(deconst(src), SDL_SRCALPHA, alpha); 00400 } 00401 00402 if (has_colorkey) { 00403 SDL_SetColorKey(deconst(src), SDL_SRCCOLORKEY | SDL_RLEACCEL, pv); 00404 } 00405 return status; 00406 }
Here is the call graph for this function:
int Wt::SDLSurface::blitAlphaCopy | ( | int | x, | |
int | y, | |||
const SDLSurface & | src | |||
) |
copy to from src
Definition at line 412 of file sdlsurface.cpp.
References blitAlphaCopy(), height(), and width().
00412 { 00413 return blitAlphaCopy(x, y, src, SDLRect(0, 0, src.width(), src.height())); 00414 }
Here is the call graph for this function:
int Wt::SDLSurface::blitAlphaCopy | ( | const SDLSurface & | src | ) |
copy to from src
Definition at line 408 of file sdlsurface.cpp.
References height(), and width().
Referenced by blitAlphaCopy().
00408 { 00409 return blitAlphaCopy(0, 0, src, SDLRect(0, 0, src.width(), src.height())); 00410 }
Here is the call graph for this function:
int Wt::SDLSurface::bytesPerLine | ( | ) | const [inline] |
Definition at line 146 of file sdlsurface.h.
References sdl_surface.
Referenced by numBytes(), pixelOffset(), and scanLine().
00146 { 00147 return sdl_surface->pitch; 00148 }
void Wt::SDLSurface::clearAlpha | ( | ) |
Definition at line 192 of file sdlsurface.cpp.
References detach(), and Wt::SDLColor::Opaque.
00192 { 00193 detach(); 00194 SDL_SetAlpha(*this, 0, SDLColor::Opaque); 00195 }
Here is the call graph for this function:
void Wt::SDLSurface::clearTransparentColor | ( | ) |
Definition at line 182 of file sdlsurface.cpp.
References detach().
00182 { 00183 detach(); 00184 SDL_SetColorKey(*this, 0, 0); 00185 }
Here is the call graph for this function:
SDLRect Wt::SDLSurface::clipRect | ( | ) | const |
Definition at line 112 of file sdlsurface.cpp.
References Wt::deconst(), and sdl_surface.
00112 { 00113 SDLRect r; 00114 SDL_GetClipRect(deconst(*this), r); 00115 assert(r == sdl_surface->clip_rect); 00116 return r; 00117 }
Here is the call graph for this function:
Definition at line 205 of file sdlsurface.h.
References Wt::SDLPixelFormat::palette(), and pixelFormat().
Referenced by setPixelColor(), and setTransparentColor().
00205 { 00206 return pixelFormat().palette()[index]; 00207 }
Here is the call graph for this function:
Definition at line 354 of file sdlsurface.cpp.
References blit(), height(), sdl_surface, SDLSurface(), and width().
00354 { 00355 SDLSurface dst = SDLSurface(width(), height(), new_depth); 00356 if (dst) { 00357 dst.blit(*this); 00358 sdl_surface = dst; 00359 return 0; 00360 } 00361 return -1; 00362 }
Here is the call graph for this function:
int Wt::SDLSurface::convertTo | ( | const SDLSurface | src | ) |
Definition at line 329 of file sdlsurface.cpp.
References flags(), pixelFormat(), and sdl_surface.
00329 { 00330 if (*this == src) 00331 return 0; 00332 /// \bug GCC bug. does not enfoce constness 00333 SDLPixelFormat f = src.pixelFormat(); 00334 SDLSurface dst = SDL_ConvertSurface(*this, f, src.flags()); 00335 00336 if (dst) { 00337 sdl_surface = dst; 00338 return 0; 00339 } 00340 00341 return -1; 00342 }
Here is the call graph for this function:
int Wt::SDLSurface::convertToDisplay | ( | ) |
Definition at line 344 of file sdlsurface.cpp.
References sdl_surface.
00344 { 00345 SDLSurface dst = SDL_DisplayFormatAlpha(*this); 00346 if (dst) { 00347 sdl_surface = dst; 00348 return 0; 00349 } 00350 00351 return -1; 00352 }
int Wt::SDLSurface::defaultDepth | ( | ) | [static] |
Definition at line 373 of file sdlsurface.cpp.
References Wt::Singleton< DERIVED >::instance().
00373 { 00374 return SDLDisplay::instance()->depth(); 00375 }
Here is the call graph for this function:
int Wt::SDLSurface::depth | ( | ) | const [inline] |
Definition at line 154 of file sdlsurface.h.
References Wt::SDLPixelFormat::bitsPerPixel(), and pixelFormat().
Referenced by blitAlphaCopy(), Wt::SDLDisplay::load(), and onDepthChange().
00154 { 00155 return pixelFormat().bitsPerPixel(); 00156 }
Here is the call graph for this function:
void Wt::SDLSurface::detach | ( | ) |
Definition at line 51 of file sdlsurface.cpp.
References flags(), pixelFormat(), and sdl_surface.
Referenced by blit(), clearAlpha(), clearTransparentColor(), fill(), lock(), setAlpha(), setClipRect(), setPalette(), setTransparentColor(), and unlock().
00051 { 00052 //avoid detaching if we are the only client for this surface 00053 if (!sdl_surface.unique()) { 00054 /// \bug GCC bug. does not enfoce constness 00055 SDLPixelFormat f = pixelFormat(); 00056 sdl_surface.reset(SDL_ConvertSurface(*this, f, flags()), Deleter()); 00057 } 00058 }
Here is the call graph for this function:
Definition at line 202 of file sdlsurface.cpp.
References detach().
00202 { 00203 SDLRect r = dst; 00204 detach(); 00205 return SDL_FillRect(*this, r, v); 00206 }
Here is the call graph for this function:
Definition at line 197 of file sdlsurface.cpp.
References detach().
00197 { 00198 detach(); 00199 return SDL_FillRect(*this, 0, v); 00200 }
Here is the call graph for this function:
int Wt::SDLSurface::flags | ( | ) | const [inline] |
Definition at line 77 of file sdlsurface.h.
References sdl_surface.
Referenced by convertTo(), detach(), Wt::SDLDisplay::hasDoubleBuffer(), Wt::SDLDisplay::hasFrame(), Wt::SDLDisplay::hasOpenGL(), Wt::SDLDisplay::hasOpenGLBlit(), Wt::SDLDisplay::isAnyFormat(), Wt::SDLDisplay::isFullScreen(), Wt::SDLDisplay::isResizable(), Wt::SDLDisplay::load(), resize(), Wt::SDLDisplay::resize(), and setPalette().
00077 { 00078 return sdl_surface->flags; 00079 }
bool Wt::SDLSurface::hasAlpha | ( | ) | const [inline] |
Definition at line 109 of file sdlsurface.h.
References sdl_surface.
Referenced by blitAlphaCopy(), and isTransparent().
00109 { 00110 return sdl_surface->flags & SDL_SRCALPHA; 00111 }
bool Wt::SDLSurface::hasAsyncBlit | ( | ) | const [inline] |
Definition at line 89 of file sdlsurface.h.
References sdl_surface.
00089 { 00090 return sdl_surface->flags & SDL_ASYNCBLIT; 00091 }
bool Wt::SDLSurface::hasHWAcceleration | ( | ) | const [inline] |
Definition at line 97 of file sdlsurface.h.
References sdl_surface.
00097 { 00098 return sdl_surface->flags & SDL_HWACCEL; 00099 }
bool Wt::SDLSurface::hasHWPalette | ( | ) | const [inline] |
Definition at line 93 of file sdlsurface.h.
References sdl_surface.
00093 { 00094 return sdl_surface->flags & SDL_HWPALETTE; 00095 }
bool Wt::SDLSurface::hasRLEAccell | ( | ) | const [inline] |
Definition at line 105 of file sdlsurface.h.
References sdl_surface.
00105 { 00106 return sdl_surface->flags & SDL_RLEACCEL; 00107 }
bool Wt::SDLSurface::hasTransparentColor | ( | ) | const [inline] |
Definition at line 101 of file sdlsurface.h.
References sdl_surface.
Referenced by blitAlphaCopy(), and isTransparent().
00101 { 00102 return sdl_surface->flags & SDL_SRCCOLORKEY; 00103 }
int Wt::SDLSurface::height | ( | ) | const [inline] |
Definition at line 142 of file sdlsurface.h.
References sdl_surface.
Referenced by blitAlphaCopy(), convertDepth(), numBytes(), Wt::SDLDisplay::resize(), scale_surface(), scaleWidth(), and SDLSurface().
00142 { 00143 return sdl_surface->h; 00144 }
bool Wt::SDLSurface::isGrayscale | ( | ) | const |
Definition at line 161 of file sdlsurface.cpp.
References numColors(), Wt::SDLPixelFormat::palette(), and pixelFormat().
00161 { 00162 SDLPalette pal = pixelFormat().palette(); 00163 if (pal) { 00164 int n = numColors(); 00165 for (int i = 0; i < n; i++) { 00166 SDLColor c = pal[i]; 00167 if (c.red() != c.green() || c.green() != c.blue()) 00168 return false; 00169 } 00170 return true; 00171 } else {} 00172 00173 return false; 00174 }
Here is the call graph for this function:
bool Wt::SDLSurface::isHWSurface | ( | ) | const [inline] |
Definition at line 85 of file sdlsurface.h.
References sdl_surface.
00085 { 00086 return sdl_surface->flags & SDL_HWSURFACE; 00087 }
bool Wt::SDLSurface::isOpaque | ( | ) | const [inline] |
Definition at line 126 of file sdlsurface.h.
References isTransparent().
00126 { 00127 return !isTransparent(); 00128 }
Here is the call graph for this function:
bool Wt::SDLSurface::isPreallocated | ( | ) | const [inline] |
Definition at line 130 of file sdlsurface.h.
References sdl_surface.
00130 { 00131 return sdl_surface->flags & SDL_PREALLOC; 00132 }
bool Wt::SDLSurface::isSWSurface | ( | ) | const [inline] |
Definition at line 81 of file sdlsurface.h.
References sdl_surface.
00081 { 00082 return sdl_surface->flags & SDL_SWSURFACE; 00083 }
bool Wt::SDLSurface::isTransparent | ( | ) | const [inline] |
There are 3 mechanisms of transparency
Definition at line 120 of file sdlsurface.h.
References alpha(), hasAlpha(), hasTransparentColor(), Wt::SDLColor::Opaque, and pixelFormat().
Referenced by isOpaque().
00120 { 00121 return (hasTransparentColor() || 00122 (hasAlpha() && 00123 (pixelFormat().alphaMask() || alpha() != SDLColor::Opaque))); 00124 }
Here is the call graph for this function:
bool Wt::SDLSurface::load | ( | const void * | p, | |
size_t | size | |||
) |
load an image from mem
Definition at line 319 of file sdlsurface.cpp.
References sdl_surface.
00319 { 00320 SDLSurface dst = IMG_Load_RW(SDL_RWFromConstMem(p, size), 1); 00321 00322 if (dst) { 00323 sdl_surface = dst; 00324 return true; 00325 } 00326 return false; 00327 }
bool Wt::SDLSurface::load | ( | const std::string & | fileName | ) |
load an image from a file
Definition at line 309 of file sdlsurface.cpp.
References sdl_surface.
00309 { 00310 SDLSurface dst = IMG_Load_RW(SDL_RWFromFile(filename.c_str(), "rb"), 1); 00311 00312 if (dst) { 00313 sdl_surface = dst; 00314 return true; 00315 } 00316 return false; 00317 }
int Wt::SDLSurface::lock | ( | ) |
Definition at line 100 of file sdlsurface.cpp.
References detach().
00100 { 00101 detach() 00102 ; 00103 return SDL_LockSurface(*this); 00104 }
Here is the call graph for this function:
size_t Wt::SDLSurface::numBytes | ( | ) | const [inline] |
Definition at line 182 of file sdlsurface.h.
References bytesPerLine(), Wt::SDLPixelFormat::bytesPerPixel(), height(), pixelFormat(), and width().
00182 { 00183 //return height() * pitch(); 00184 return (height() - 1) * bytesPerLine() + 00185 width() * pixelFormat().bytesPerPixel(); 00186 }
Here is the call graph for this function:
int Wt::SDLSurface::numColors | ( | ) | const |
Definition at line 140 of file sdlsurface.cpp.
References Wt::SDLPixelFormat::palette(), pixelFormat(), and Wt::SDLPalette::size().
Referenced by isGrayscale(), and setNumColors().
00140 { 00141 SDLPalette pal = pixelFormat().palette(); 00142 return (pal) ? pal.size() : 0; 00143 }
Here is the call graph for this function:
void Wt::SDLSurface::onDepthChange | ( | ) | [protected] |
Definition at line 469 of file sdlsurface.cpp.
References depth(), read_pixel, readPixel16bpp(), readPixel24bpp(), readPixel32bpp(), readPixel8bpp(), write_pixel, writePixel16bpp(), writePixel24bpp(), writePixel32bpp(), and writePixel8bpp().
Referenced by SDLSurface().
00469 { 00470 // don't crash on NULL surfaces 00471 if (!*this) 00472 return; 00473 switch (depth()) { 00474 case 0: 00475 read_pixel = 0; 00476 write_pixel = 0; 00477 assert(0); 00478 break; 00479 case 8: 00480 read_pixel = &SDLSurface::readPixel8bpp; 00481 write_pixel = &SDLSurface::writePixel8bpp; 00482 break; 00483 case 16: 00484 read_pixel = &SDLSurface::readPixel16bpp; 00485 write_pixel = &SDLSurface::writePixel16bpp; 00486 break; 00487 case 24: 00488 read_pixel = &SDLSurface::readPixel24bpp; 00489 write_pixel = &SDLSurface::writePixel24bpp; 00490 break; 00491 case 32: 00492 read_pixel = &SDLSurface::readPixel32bpp; 00493 write_pixel = &SDLSurface::writePixel32bpp; 00494 break; 00495 default: 00496 assert(0); 00497 break; 00498 } 00499 }
Here is the call graph for this function:
Wt::SDLSurface::operator const Ptr | ( | ) | const [inline, private] |
Definition at line 350 of file sdlsurface.h.
References sdl_surface.
00350 { 00351 return sdl_surface; 00352 }
Wt::SDLSurface::operator const SDL_Surface * | ( | ) | const [inline] |
Definition at line 67 of file sdlsurface.h.
References sdl_surface.
00067 { 00068 return sdl_surface.get(); 00069 }
Wt::SDLSurface::operator Ptr | ( | ) | [inline, private] |
Definition at line 354 of file sdlsurface.h.
References sdl_surface.
00354 { 00355 return sdl_surface; 00356 }
Wt::SDLSurface::operator SDL_Surface * | ( | ) | [inline] |
Definition at line 71 of file sdlsurface.h.
References sdl_surface.
00071 { 00072 return sdl_surface.get(); 00073 }
Definition at line 286 of file sdlsurface.h.
References pixel(), and pixelOffset().
00286 { 00287 return pixel(pixelOffset(x, y)); 00288 }
Here is the call graph for this function:
Definition at line 278 of file sdlsurface.h.
References read_pixel.
Referenced by pixel(), pixelColor(), and readPixel24bpp().
00278 { 00279 return (this->*read_pixel)(pixel_offset); 00280 }
Definition at line 174 of file sdlsurface.h.
References pixelOffset(), and pixels().
00174 { 00175 return (Uint8 *) pixels() + pixelOffset(x, y); 00176 }
Here is the call graph for this function:
void* Wt::SDLSurface::pixelAddress | ( | int | pixel_offset | ) | const [inline] |
Definition at line 170 of file sdlsurface.h.
References pixels().
Referenced by readPixel16bpp(), readPixel24bpp(), readPixel32bpp(), readPixel8bpp(), scanLine(), writePixel16bpp(), writePixel24bpp(), writePixel32bpp(), and writePixel8bpp().
00170 { 00171 return (Uint8 *) pixels() + pixel_offset; 00172 }
Here is the call graph for this function:
Definition at line 290 of file sdlsurface.h.
References Wt::SDLPixelFormat::mapToColor(), pixel(), and pixelFormat().
00290 { 00291 return pixelFormat().mapToColor((pixel(x, y))); 00292 }
Here is the call graph for this function:
Definition at line 282 of file sdlsurface.h.
References Wt::SDLPixelFormat::mapToColor(), pixel(), and pixelFormat().
00282 { 00283 return pixelFormat().mapToColor((pixel(pixel_offset))); 00284 }
Here is the call graph for this function:
const SDLPixelFormat Wt::SDLSurface::pixelFormat | ( | ) | const [inline] |
Definition at line 134 of file sdlsurface.h.
References sdl_surface.
Referenced by alpha(), blitAlphaCopy(), color(), convertTo(), depth(), detach(), isGrayscale(), isTransparent(), numBytes(), numColors(), pixelColor(), pixelOffset(), readPixel24bpp(), resize(), Wt::SDLDisplay::resize(), setNumColors(), setPixelColor(), setTransparentColor(), transparentColor(), and writePixel24bpp().
00134 { 00135 return sdl_surface->format; 00136 }
Definition at line 166 of file sdlsurface.h.
References bytesPerLine(), Wt::SDLPixelFormat::bytesPerPixel(), and pixelFormat().
Referenced by pixel(), pixelAddress(), and setPixel().
00166 { 00167 return y * bytesPerLine() + x * pixelFormat().bytesPerPixel(); 00168 }
Here is the call graph for this function:
void* Wt::SDLSurface::pixels | ( | ) | [inline] |
Definition at line 158 of file sdlsurface.h.
References sdl_surface.
00158 { 00159 return sdl_surface->pixels; 00160 }
const void* Wt::SDLSurface::pixels | ( | ) | const [inline] |
Definition at line 150 of file sdlsurface.h.
References sdl_surface.
Referenced by bits(), and pixelAddress().
00150 { 00151 return sdl_surface->pixels; 00152 }
Definition at line 424 of file sdlsurface.cpp.
References pixelAddress().
Referenced by onDepthChange().
00424 { 00425 return * (Uint16 *) pixelAddress(pixel_offset); 00426 }
Here is the call graph for this function:
Definition at line 432 of file sdlsurface.cpp.
References Wt::SDLPixelFormat::blueShift(), Wt::SDLPixelFormat::greenShift(), pixel(), pixelAddress(), pixelFormat(), and Wt::SDLPixelFormat::redShift().
Referenced by onDepthChange().
00432 { 00433 Uint8* screen_loc = (Uint8 *) pixelAddress(pixel_offset); 00434 const SDLPixelFormat f = pixelFormat(); 00435 Uint32 pixel = 0; 00436 int shift; 00437 00438 // I´m not sure on this, Karsten 01/1999 00439 shift = f.redShift(); 00440 pixel = *(screen_loc + shift / 8) << shift; 00441 shift = f.greenShift(); 00442 pixel |= *(screen_loc + shift / 8) << shift; 00443 shift = f.blueShift(); 00444 pixel |= *(screen_loc + shift / 8) << shift; 00445 return pixel; 00446 }
Here is the call graph for this function:
Definition at line 461 of file sdlsurface.cpp.
References pixelAddress().
Referenced by onDepthChange().
00461 { 00462 return * (Uint32 *) pixelAddress(pixel_offset); 00463 }
Here is the call graph for this function:
Definition at line 416 of file sdlsurface.cpp.
References pixelAddress().
Referenced by onDepthChange().
00416 { 00417 return * (Uint8 *) pixelAddress(pixel_offset); 00418 }
Here is the call graph for this function:
Reimplemented in Wt::SDLDisplay.
Definition at line 364 of file sdlsurface.cpp.
References Wt::SDLPixelFormat::alphaMask(), Wt::SDLPixelFormat::bitsPerPixel(), Wt::SDLPixelFormat::blueMask(), flags(), Wt::SDLPixelFormat::greenMask(), pixelFormat(), Wt::SDLPixelFormat::redMask(), and sdl_surface.
00364 { 00365 SDLPixelFormat f = pixelFormat(); 00366 SDLSurface dst = SDL_CreateRGBSurface(flags(), x, y, f.bitsPerPixel(), 00367 f.redMask(), f.greenMask(), 00368 f.blueMask(), f.alphaMask()); 00369 if (dst) 00370 sdl_surface = dst; 00371 }
Here is the call graph for this function:
SDLSurface Wt::SDLSurface::scale | ( | int | w, | |
int | h, | |||
ScaleMode | mode = ScaleFree | |||
) | const |
Definition at line 519 of file sdlsurface.cpp.
References scale_surface().
00519 { 00520 return scale_surface(w, h, false, mode); 00521 }
Here is the call graph for this function:
SDLSurface Wt::SDLSurface::scale_surface | ( | int | w, | |
int | h, | |||
bool | smooth, | |||
ScaleMode | mode | |||
) | const [protected] |
Definition at line 501 of file sdlsurface.cpp.
References Wt::deconst(), height(), ScaleFree, ScaleMax, ScaleMin, SDLSurface(), and width().
Referenced by scale(), scaleHeight(), scaleWidth(), and smoothScale().
00502 { 00503 if (mode != ScaleFree && (width() * h != height() * w)) { 00504 double r1 = static_cast<double>(width()) / 00505 static_cast<double>(height()); 00506 double r2 = static_cast<double>(w) / 00507 static_cast<double>(h); 00508 if ( (mode == ScaleMin & (r2 > r1)) || (mode == ScaleMax & (r2 < r1)) ) 00509 w = static_cast<int>(h * r1); 00510 if ( (mode == ScaleMin & (r2 < r1)) || (mode == ScaleMax & (r2 > r1)) ) 00511 h = static_cast<int>(w / r1); 00512 } 00513 double zx = static_cast<double>(w) / static_cast<double>(width()); 00514 double zy = static_cast<double>(h) / static_cast<double>(height()); 00515 00516 return SDLSurface(zoomSurface(deconst(*this), zx, zy, smooth)); 00517 }
Here is the call graph for this function:
SDLSurface Wt::SDLSurface::scaleHeight | ( | int | h | ) | const |
Definition at line 531 of file sdlsurface.cpp.
References scale_surface(), ScaleFree, and width().
00531 { 00532 return scale_surface(width(), h, false, ScaleFree); 00533 }
Here is the call graph for this function:
SDLSurface Wt::SDLSurface::scaleWidth | ( | int | w | ) | const |
Definition at line 527 of file sdlsurface.cpp.
References height(), scale_surface(), and ScaleFree.
00527 { 00528 return scale_surface(w, height(), false, ScaleFree); 00529 }
Here is the call graph for this function:
void* Wt::SDLSurface::scanLine | ( | int | y | ) | [inline] |
Definition at line 178 of file sdlsurface.h.
References bytesPerLine(), and pixelAddress().
00178 { 00179 return pixelAddress(y * bytesPerLine()); 00180 }
Here is the call graph for this function:
int Wt::SDLSurface::serialNumber | ( | ) | const [inline] |
void Wt::SDLSurface::setAlpha | ( | int | alpha = SDLColor::Transparent |
) |
Definition at line 119 of file sdlsurface.cpp.
References detach().
00119 { 00120 SDLRect r = rect; 00121 detach(); 00122 SDL_SetClipRect(*this, r); 00123 return r; 00124 }
Here is the call graph for this function:
Definition at line 135 of file sdlsurface.cpp.
References setPalette().
00135 { 00136 std::vector<SDLColor> ca(1, c); 00137 setPalette(ca, i); 00138 }
Here is the call graph for this function:
void Wt::SDLSurface::setNumColors | ( | int | ncolors | ) |
Definition at line 145 of file sdlsurface.cpp.
References numColors(), Wt::SDLPixelFormat::palette(), pixelFormat(), and setPalette().
00145 { 00146 int old = numColors(); 00147 00148 if (ncolors < old) { 00149 SDLPalette pal = pixelFormat().palette(); 00150 std::vector<SDLColor> ca; 00151 ca.reserve(ncolors); 00152 for (int i = 0; i < ncolors; i++) 00153 ca[i] = pal[i]; 00154 setPalette(ca, 0); 00155 } else if (ncolors > old) { 00156 std::vector<SDLColor> ca(ncolors - old, SDLColor()); 00157 setPalette(ca, old); 00158 } 00159 }
Here is the call graph for this function:
void Wt::SDLSurface::setPalette | ( | const std::vector< SDLColor > & | ca, | |
int | offset, | |||
int | flags = SDLPalette::Logical|SDLPalette::Physical | |||
) |
Definition at line 126 of file sdlsurface.cpp.
References detach(), and flags().
Referenced by setColor(), and setNumColors().
00127 { 00128 //SDL breakage 00129 SDL_Color *colors = const_cast<SDL_Color *>( 00130 reinterpret_cast<const SDL_Color *>(&ca[0])); 00131 detach(); 00132 SDL_SetPalette(*this, flags, colors, offset, ca.size()); 00133 }
Here is the call graph for this function:
Definition at line 302 of file sdlsurface.h.
References pixelOffset(), and setPixel().
00302 { 00303 setPixel(pixelOffset(x, y), pixel_value); 00304 }
Here is the call graph for this function:
Definition at line 294 of file sdlsurface.h.
References write_pixel.
Referenced by setPixel(), and setPixelColor().
00294 { 00295 (this->*write_pixel)(pixel_offset, pixel_value); 00296 }
Definition at line 306 of file sdlsurface.h.
References color(), pixelFormat(), and setPixel().
00306 { 00307 setPixel(x, y, pixelFormat().mapToPixelValue(color)); 00308 }
Here is the call graph for this function:
Definition at line 298 of file sdlsurface.h.
References color(), pixelFormat(), and setPixel().
00298 { 00299 setPixel(pixel_offset, pixelFormat().mapToPixelValue(color)); 00300 }
Here is the call graph for this function:
Definition at line 176 of file sdlsurface.cpp.
References color(), detach(), and pixelFormat().
00176 { 00177 detach(); 00178 SDL_SetColorKey(*this, SDL_SRCCOLORKEY | SDL_RLEACCEL, 00179 pixelFormat().mapToPixelValue(color)); 00180 }
Here is the call graph for this function:
SDLSurface Wt::SDLSurface::smoothScale | ( | int | w, | |
int | h, | |||
ScaleMode | mode = ScaleFree | |||
) | const |
Definition at line 523 of file sdlsurface.cpp.
References scale_surface().
00523 { 00524 return scale_surface(w, h, true, mode); 00525 }
Here is the call graph for this function:
static int Wt::SDLSurface::systemBitOrder | ( | ) | [inline, static] |
static int Wt::SDLSurface::systemByteOrder | ( | ) | [inline, static] |
SDLColor Wt::SDLSurface::transparentColor | ( | ) | const [inline] |
Definition at line 218 of file sdlsurface.h.
References pixelFormat(), and Wt::SDLPixelFormat::transparentColor().
00218 { 00219 return pixelFormat().transparentColor(); 00220 }
Here is the call graph for this function:
int Wt::SDLSurface::unlock | ( | ) |
Definition at line 106 of file sdlsurface.cpp.
References detach().
00106 { 00107 detach(); 00108 SDL_UnlockSurface(*this); 00109 return 0; 00110 }
Here is the call graph for this function:
int Wt::SDLSurface::width | ( | ) | const [inline] |
Definition at line 138 of file sdlsurface.h.
References sdl_surface.
Referenced by blitAlphaCopy(), convertDepth(), numBytes(), Wt::SDLDisplay::resize(), scale_surface(), scaleHeight(), and SDLSurface().
00138 { 00139 return sdl_surface->w; 00140 }
Definition at line 428 of file sdlsurface.cpp.
References pixelAddress().
Referenced by onDepthChange().
00428 { 00429 * (Uint16 *) pixelAddress(pixel_offset) = pixel_value; 00430 }
Here is the call graph for this function:
Definition at line 448 of file sdlsurface.cpp.
References Wt::SDLPixelFormat::blueShift(), Wt::SDLPixelFormat::greenShift(), pixelAddress(), pixelFormat(), and Wt::SDLPixelFormat::redShift().
Referenced by onDepthChange().
00448 { 00449 Uint8* screen_loc = (Uint8 *) pixelAddress(pixel_offset); 00450 int shift; 00451 const SDLPixelFormat f = pixelFormat(); 00452 00453 shift = f.redShift(); 00454 *(screen_loc + shift / 8) = pixel_value >> shift; 00455 shift = f.greenShift(); 00456 *(screen_loc + shift / 8) = pixel_value >> shift; 00457 shift = f.blueShift(); 00458 *(screen_loc + shift / 8) = pixel_value >> shift; 00459 }
Here is the call graph for this function:
Definition at line 465 of file sdlsurface.cpp.
References pixelAddress().
Referenced by onDepthChange().
00465 { 00466 * (Uint32 *) pixelAddress(pixel_offset) = pixel_value; 00467 }
Here is the call graph for this function:
Definition at line 420 of file sdlsurface.cpp.
References pixelAddress().
Referenced by onDepthChange().
00420 { 00421 * (Uint8 *) pixelAddress(pixel_offset) = pixel_value; 00422 }
Here is the call graph for this function:
const FlagMap Wt::SDLSurface::flagMap [static, protected] |
Initial value:
boost::assign::map_list_of (W::SWSurface, SDL_SWSURFACE) (W::HWSurface, SDL_HWSURFACE) (W::AsyncBlit, SDL_ASYNCBLIT) (W::HWPalette, SDL_HWPALETTE) (W::HWAccel, SDL_HWACCEL) (W::AnyFormat, SDL_ANYFORMAT) (W::DoubleBuffer, SDL_DOUBLEBUF) (W::FullScreen, SDL_FULLSCREEN) (W::OpenGL, SDL_OPENGL) (W::OpenGLBlit, SDL_OPENGLBLIT) (W::Resizable, SDL_RESIZABLE) (W::NoFrame, SDL_NOFRAME)
Definition at line 336 of file sdlsurface.h.
Referenced by Wt::SDLDisplay::load().
readPixelFunction Wt::SDLSurface::read_pixel [private] |
Ptr Wt::SDLSurface::sdl_surface [private] |
Definition at line 347 of file sdlsurface.h.
Referenced by bytesPerLine(), clipRect(), convertDepth(), convertTo(), convertToDisplay(), detach(), flags(), hasAlpha(), hasAsyncBlit(), hasHWAcceleration(), hasHWPalette(), hasRLEAccell(), hasTransparentColor(), height(), isHWSurface(), isPreallocated(), isSWSurface(), load(), operator const Ptr(), operator const SDL_Surface *(), operator Ptr(), operator SDL_Surface *(), pixelFormat(), pixels(), resize(), and width().
This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.