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_BLITTERS_HPP
7 #define UNISON_VIDEO_SDL_BLITTERS_HPP
9 #include <unison/video/Blitters.hpp>
10 #include <unison/video/Coord.hpp>
11 #include <unison/video/Surface.hpp>
23 static SDL_Surface *create_sdl_surface_from(Surface &src)
25 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
26 SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(src.get_pixels(), src.get_size().x, src.get_size().y, 32, src.get_size().x * 4, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
28 SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(src.get_pixels().get_pixels(), src.get_size().x, src.get_size().y, 32, src.get_size().x * 4, 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff);
33 static SDL_Surface *create_sdl_surface_from(const Surface &src)
35 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
36 SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(const_cast<Color *>(src.get_pixels()), src.get_size().x, src.get_size().y, 32, src.get_size().x * 4, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
38 SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(const_cast<Color *>(src.get_pixels()).get_pixels(), src.get_size().x, src.get_size().y, 32, src.get_size().x * 4, 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff);
43 static SDL_Surface *optimize(const Surface &src);
45 static void blit_upper(SDL_Surface *src, Rect src_rect, SDL_Surface *dst, Point dst_pos, void (*blit_lower)(SDL_Surface *, const Rect &, SDL_Surface *, const Point &));
47 static void blit_lower_none(SDL_Surface *src, const Rect &src_rect, SDL_Surface *dst, const Point &dst_pos);
49 static void blit_lower_mask(SDL_Surface *src, const Rect &src_rect, SDL_Surface *dst, const Point &dst_pos);
51 static void blit_lower_alpha(SDL_Surface *src, const Rect &src_rect, SDL_Surface *dst, const Point &dst_pos);
53 static void blit_lower_add(SDL_Surface *src, const Rect &src_rect, SDL_Surface *dst, const Point &dst_pos);
55 static void blit_lower_mod(SDL_Surface *src, const Rect &src_rect, SDL_Surface *dst, const Point &dst_pos);
57 static void blit_blend_none(SDL_Surface *src, const Rect &src_rect, SDL_Surface *dst, const Point &dst_pos)
59 blit_upper(src, src_rect, dst, dst_pos, blit_lower_none);
62 static void blit_blend_mask(SDL_Surface *src, const Rect &src_rect, SDL_Surface *dst, const Point &dst_pos)
64 blit_upper(src, src_rect, dst, dst_pos, blit_lower_mask);
67 static void blit_blend_alpha(SDL_Surface *src, const Rect &src_rect, SDL_Surface *dst, const Point &dst_pos)
69 blit_upper(src, src_rect, dst, dst_pos, blit_lower_alpha);
72 static void blit_blend_add(SDL_Surface *src, const Rect &src_rect, SDL_Surface *dst, const Point &dst_pos)
74 blit_upper(src, src_rect, dst, dst_pos, blit_lower_add);
77 static void blit_blend_mod(SDL_Surface *src, const Rect &src_rect, SDL_Surface *dst, const Point &dst_pos)
79 blit_upper(src, src_rect, dst, dst_pos, blit_lower_mod);
82 static void blit_blend(SDL_Surface *src, const Rect &src_rect, SDL_Surface *dst, const Point &dst_pos, BlendMode blend)
87 blit_blend_none(src, src_rect, dst, dst_pos);
90 blit_blend_mask(src, src_rect, dst, dst_pos);
93 blit_blend_alpha(src, src_rect, dst, dst_pos);
96 blit_blend_add(src, src_rect, dst, dst_pos);
99 blit_blend_mod(src, src_rect, dst, dst_pos);