#include <sdl_texture.hpp>
Public Member Functions | |
ColorCache () | |
~ColorCache () | |
void | 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 40 of file sdl_texture.hpp.
SDL::Texture::ColorCache::ColorCache | ( | ) | [inline] |
Definition at line 63 of file sdl_texture.hpp.
References CACHE_SIZE, and data.
00064 { 00065 memset(data, 0, CACHE_SIZE * sizeof(SDL_Surface *)); 00066 }
SDL::Texture::ColorCache::~ColorCache | ( | ) | [inline] |
Definition at line 68 of file sdl_texture.hpp.
References CACHE_SIZE, and data.
00069 { 00070 std::for_each(data, data + CACHE_SIZE, SDL_FreeSurface); 00071 }
static void SDL::Texture::ColorCache::ref | ( | SDL_Surface * | surface | ) | [inline, static] |
static int SDL::Texture::ColorCache::hash | ( | const Color & | color | ) | [inline, static] |
Definition at line 53 of file sdl_texture.hpp.
References Color::blue, Color::green, HASHED_BITS, and Color::red.
Referenced by operator[]().
00054 { 00055 return 00056 ((int) (color.red * ((1 << HASHED_BITS) - 1)) << (HASHED_BITS - 1) * 2) | 00057 ((int) (color.green * ((1 << HASHED_BITS) - 1)) << (HASHED_BITS - 1)) | 00058 ((int) (color.blue * ((1 << HASHED_BITS) - 1)) << 0); 00059 }
void SDL::Texture::ColorCache::operator= | ( | const ColorCache & | other | ) | [inline] |
Definition at line 73 of file sdl_texture.hpp.
References CACHE_SIZE, data, and ref().
00074 { 00075 std::for_each(other.data, other.data + CACHE_SIZE, ref); 00076 std::for_each(data, data + CACHE_SIZE, SDL_FreeSurface); 00077 memcpy(data, other.data, CACHE_SIZE * sizeof(SDL_Surface *)); 00078 }
SDL_Surface*& SDL::Texture::ColorCache::operator[] | ( | const Color & | color | ) | [inline] |
const int SDL::Texture::ColorCache::HASHED_BITS = 3 [static] |
const int SDL::Texture::ColorCache::CACHE_SIZE = 1 << (HASHED_BITS * 3) [static] |
Definition at line 43 of file sdl_texture.hpp.
Referenced by ColorCache(), operator=(), and ~ColorCache().
SDL_Surface* SDL::Texture::ColorCache::data[CACHE_SIZE] |
Definition at line 61 of file sdl_texture.hpp.
Referenced by ColorCache(), operator=(), operator[](), and ~ColorCache().