#include <sdl_texture.hpp>
Public Member Functions | |
ColorCache () | |
ColorCache (const ColorCache &) | |
~ColorCache () | |
ColorCache & | operator= (const ColorCache &other) |
SDL_Surface *& | operator[] (const Color &color) |
Static Public Member Functions | |
static void | ref (SDL_Surface *surface) |
static int | hash (const Color &color) |
Public Attributes | |
SDL_Surface * | data [CACHE_SIZE] |
Static Public Attributes | |
static const int | HASHED_BITS = 3 |
static const int | CACHE_SIZE = 1 << (HASHED_BITS * 3) |
Definition at line 35 of file sdl_texture.hpp.
SDLTexture::ColorCache::ColorCache | ( | ) | [inline] |
Definition at line 58 of file sdl_texture.hpp.
References CACHE_SIZE, and data.
00059 { 00060 memset(data, 0, CACHE_SIZE * sizeof(SDL_Surface *)); 00061 }
SDLTexture::ColorCache::ColorCache | ( | const ColorCache & | ) |
SDLTexture::ColorCache::~ColorCache | ( | ) | [inline] |
Definition at line 65 of file sdl_texture.hpp.
References CACHE_SIZE, and data.
00066 { 00067 std::for_each(data, data + CACHE_SIZE, SDL_FreeSurface); 00068 }
static void SDLTexture::ColorCache::ref | ( | SDL_Surface * | surface | ) | [inline, static] |
static int SDLTexture::ColorCache::hash | ( | const Color & | color | ) | [inline, static] |
Definition at line 48 of file sdl_texture.hpp.
References Color::blue, Color::green, HASHED_BITS, and Color::red.
Referenced by operator[]().
00049 { 00050 return 00051 ((int) (color.red * ((1 << HASHED_BITS) - 1)) << (HASHED_BITS - 1) * 2) | 00052 ((int) (color.green * ((1 << HASHED_BITS) - 1)) << (HASHED_BITS - 1)) | 00053 ((int) (color.blue * ((1 << HASHED_BITS) - 1)) << 0); 00054 }
ColorCache& SDLTexture::ColorCache::operator= | ( | const ColorCache & | other | ) | [inline] |
Definition at line 70 of file sdl_texture.hpp.
References CACHE_SIZE, data, and ref().
00071 { 00072 if (this != &other) 00073 { 00074 std::for_each(other.data, other.data + CACHE_SIZE, ref); 00075 std::for_each(data, data + CACHE_SIZE, SDL_FreeSurface); 00076 memcpy(data, other.data, CACHE_SIZE * sizeof(SDL_Surface *)); 00077 } 00078 return *this; 00079 }
SDL_Surface*& SDLTexture::ColorCache::operator[] | ( | const Color & | color | ) | [inline] |
const int SDLTexture::ColorCache::HASHED_BITS = 3 [static] |
const int SDLTexture::ColorCache::CACHE_SIZE = 1 << (HASHED_BITS * 3) [static] |
Definition at line 38 of file sdl_texture.hpp.
Referenced by ColorCache(), operator=(), and ~ColorCache().
Definition at line 56 of file sdl_texture.hpp.
Referenced by ColorCache(), operator=(), operator[](), and ~ColorCache().