1 // Copyright Timothy Goya 2007.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
6 #ifndef UNISON_VIDEO_SDL_TEXTURE_HPP
7 #define UNISON_VIDEO_SDL_TEXTURE_HPP
9 #include <unison/video/backend/Texture.hpp>
10 #include <unison/video/Surface.hpp>
23 class Texture : public Backend::Texture
26 Texture(const Surface &surface);
27 //Texture(const Surface &surface, const std::string &name);
28 //Texture(Backend::Texture *texture);
31 const Surface get_surface();
33 void blit(const Surface &src, const Point &dst_pos, const Rect &src_rect, const RenderOptions &options);
34 void blit(const Video::Texture &src, const Point &dst_pos, const Rect &src_rect, const RenderOptions &options);
35 void fill(const Color &color, const Rect &rect);
36 void fill_blend(const Color &color, const Rect &rect);
38 SDL_Surface *get_transform(const RenderOptions &options, unsigned int numerator, unsigned int denominator);
43 static void ref(SDL_Surface *surface)
51 SDL_Surface *data[256];
55 memset(data, 0, 256 * sizeof(SDL_Surface *));
60 std::for_each(data, data + 256, SDL_FreeSurface);
63 void operator = (const AlphaMap &other)
65 std::for_each(other.data, other.data + 256, ref);
66 std::for_each(data, data + 256, SDL_FreeSurface);
67 memcpy(data, other.data, 256 * sizeof(SDL_Surface *));
70 SDL_Surface *&operator [] (Uint8 alpha)
75 //std::map<Color, AlphaMap> cache;
76 std::map<Color, AlphaMap> n_cache;
77 std::map<Color, AlphaMap> h_cache;
78 std::map<Color, AlphaMap> v_cache;
79 std::map<Color, AlphaMap> d_cache;