#include "scoped_resource.hpp"
#include "util.hpp"
#include "SDL.h"
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
Go to the source code of this file.
Classes | |
struct | surface |
struct | surface::free_sdl_surface |
struct | pixel_data |
struct | surface_lock |
struct | surface_restorer |
struct | clip_rect_setter |
Defines | |
#define | SDL_BUTTON_WHEELUP 4 |
#define | SDL_BUTTON_WHEELDOWN 5 |
#define | SDL_BUTTON_WHEELLEFT 6 |
#define | SDL_BUTTON_WHEELRIGHT 7 |
Functions | |
SDLKey | sdl_keysym_from_name (std::string const &keyname) |
bool | point_in_rect (int x, int y, const SDL_Rect &rect) |
bool | rects_overlap (const SDL_Rect &rect1, const SDL_Rect &rect2) |
SDL_Rect | intersect_rects (SDL_Rect const &rect1, SDL_Rect const &rect2) |
SDL_Rect | create_rect (const int x, const int y, const int w, const int h) |
Creates an empty SDL_Rect. | |
bool | operator< (const surface &a, const surface &b) |
surface | make_neutral_surface (surface const &surf) |
surface | create_optimized_surface (surface const &surf) |
surface | stretch_surface_horizontal (const surface &surf, const unsigned w, const bool optimize=true) |
Streches a surface in the horizontal direction. | |
surface | stretch_surface_vertical (const surface &surf, const unsigned h, const bool optimize=true) |
Streches a surface in the vertical direction. | |
surface | scale_surface (surface const &surf, int w, int h, bool optimize=true) |
surface | scale_surface_blended (surface const &surf, int w, int h, bool optimize=true) |
surface | adjust_surface_colour (surface const &surf, int r, int g, int b, bool optimize=true) |
surface | greyscale_image (surface const &surf, bool optimize=true) |
surface | darken_image (surface const &surf, bool optimize=true) |
surface | recolor_image (surface surf, const std::map< Uint32, Uint32 > &map_rgb, bool optimize=true) |
surface | brighten_image (surface const &surf, fixed_t amount, bool optimize=true) |
surface | get_surface_portion (surface const &surf, SDL_Rect &rect) |
surface | adjust_surface_alpha (surface const &surf, fixed_t amount, bool optimize=true) |
surface | adjust_surface_alpha_add (surface const &surf, int amount, bool optimize=true) |
surface | mask_surface (surface const &surf, surface const &mask) |
Applies a mask on a surface. | |
surface | blur_surface (surface const &surf, int depth=1, bool optimize=true) |
Cross-fades a surface. | |
surface | blur_alpha_surface (surface const &surf, int depth=1, bool optimize=true) |
Cross-fades a surface with alpha channel. | |
surface | cut_surface (surface const &surf, SDL_Rect const &r) |
Cuts a rectangle from a surface. | |
surface | blend_surface (surface const &surf, double amount, Uint32 colour, bool optimize=true) |
surface | flip_surface (surface const &surf, bool optimize=true) |
surface | flop_surface (surface const &surf, bool optimize=true) |
surface | create_compatible_surface (surface const &surf, int width=-1, int height=-1) |
void | blit_surface (const surface &src, const SDL_Rect *srcrect, surface &dst, const SDL_Rect *dstrect) |
Replacement for SDL_BlitSurface. | |
void | fill_rect_alpha (SDL_Rect &rect, Uint32 colour, Uint8 alpha, surface const &target) |
SDL_Rect | get_non_transparent_portion (surface const &surf) |
bool | operator== (const SDL_Rect &a, const SDL_Rect &b) |
bool | operator!= (const SDL_Rect &a, const SDL_Rect &b) |
bool | operator== (const SDL_Color &a, const SDL_Color &b) |
bool | operator!= (const SDL_Color &a, const SDL_Color &b) |
SDL_Color | inverse (const SDL_Color &colour) |
SDL_Color | int_to_color (const Uint32 rgb) |
Uint32 | color_to_int (const SDL_Color &rgb) |
void | draw_rectangle (int x, int y, int w, int h, Uint32 colour, surface tg) |
void | draw_solid_tinted_rectangle (int x, int y, int w, int h, int r, int g, int b, double alpha, surface target) |
void | draw_centered_on_background (surface surf, const SDL_Rect &rect, const SDL_Color &color, surface target) |
Variables | |
const SDL_Rect | empty_rect = { 0, 0, 0, 0 } |
Definition in file sdl_utils.hpp.
#define SDL_BUTTON_WHEELDOWN 5 |
Definition at line 38 of file sdl_utils.hpp.
Referenced by gui::scrollbar::handle_event(), gui::scrollarea::handle_event(), map_editor::terrain_palette::handle_event(), map_editor::handle_mouse_button_event(), and events::mouse_handler::mouse_press().
#define SDL_BUTTON_WHEELLEFT 6 |
Definition at line 42 of file sdl_utils.hpp.
Referenced by map_editor::handle_mouse_button_event(), and events::mouse_handler::mouse_press().
#define SDL_BUTTON_WHEELRIGHT 7 |
Definition at line 46 of file sdl_utils.hpp.
Referenced by map_editor::handle_mouse_button_event(), and events::mouse_handler::mouse_press().
#define SDL_BUTTON_WHEELUP 4 |
Definition at line 34 of file sdl_utils.hpp.
Referenced by gui::scrollbar::handle_event(), gui::scrollarea::handle_event(), map_editor::terrain_palette::handle_event(), map_editor::handle_mouse_button_event(), and events::mouse_handler::mouse_press().
Definition at line 730 of file sdl_utils.cpp.
References b, create_optimized_surface(), boost::foreach_detail_::end(), fxpmult, g, make_neutral_surface(), surface_lock::pixels(), and r.
Referenced by game_display::new_turn(), display::render_unit_image(), and map_editor::set_mouseover_overlay().
Definition at line 769 of file sdl_utils.cpp.
References b, create_optimized_surface(), boost::foreach_detail_::end(), g, make_neutral_surface(), surface_lock::pixels(), and r.
Definition at line 517 of file sdl_utils.cpp.
References b, create_optimized_surface(), boost::foreach_detail_::end(), g, make_neutral_surface(), surface_lock::pixels(), and r.
Referenced by image::get_scaled_to_hex(), and image::getMinimap().
Definition at line 1158 of file sdl_utils.cpp.
References a, b, create_optimized_surface(), boost::foreach_detail_::end(), g, make_neutral_surface(), surface_lock::pixels(), and r.
Referenced by gui::button::draw_contents(), and display::render_unit_image().
void blit_surface | ( | const surface & | src, | |
const SDL_Rect * | srcrect, | |||
surface & | dst, | |||
const SDL_Rect * | dstrect | |||
) |
Replacement for SDL_BlitSurface.
SDL_BlitSurface has problems with blitting partly transparent surfaces so this is a replacement. It ignores the SDL_SRCALPHA and SDL_SRCCOLORKEY flags. src and dst will have the SDL_RLEACCEL flag removed. The return value of SDL_BlistSurface is normally ignored so no return value. The rectangles are const and will not be modified.
src | The surface to blit. | |
srcrect | The region of the surface to blit | |
dst | The surface to blit on. | |
dstrect | The offset to blit the surface on, only x and y are used. |
Definition at line 1291 of file sdl_utils.cpp.
References minimum(), and surface_lock::pixels().
Referenced by gui2::twindow::draw(), gui2::tpanel::draw(), gui2::tlistbox::draw(), gui2::tcontrol::draw(), gui2::ttext::draw(), gui2::timage::draw(), and image::getMinimap().
Cross-fades a surface with alpha channel.
Definition at line 984 of file sdl_utils.cpp.
References create_optimized_surface(), make_neutral_surface(), minimum(), and surface_lock::pixels().
Cross-fades a surface.
Definition at line 865 of file sdl_utils.cpp.
References create_optimized_surface(), make_neutral_surface(), minimum(), and surface_lock::pixels().
Referenced by gui::dialog_frame::draw_background().
Definition at line 688 of file sdl_utils.cpp.
References b, create_optimized_surface(), boost::foreach_detail_::end(), fxpmult, g, make_neutral_surface(), surface_lock::pixels(), and r.
Referenced by image::get_brightened(), image::get_semi_brightened(), and display::render_unit_image().
Uint32 color_to_int | ( | const SDL_Color & | rgb | ) |
Definition at line 42 of file sdl_utils.cpp.
Definition at line 1264 of file sdl_utils.cpp.
Referenced by gui::textbox::append_text(), cut_surface(), cursor::draw(), game_display::draw_bar(), fill_rect_alpha(), get_surface_portion(), image::getMinimap(), main(), font::render_text(), display::screenshot(), and map_editor::set_mouseover_overlay().
Definition at line 137 of file sdl_utils.cpp.
References display_format_alpha().
Referenced by adjust_surface_alpha(), adjust_surface_alpha_add(), adjust_surface_colour(), blend_surface(), blur_alpha_surface(), blur_surface(), brighten_image(), darken_image(), flip_surface(), flop_surface(), image::get_image(), greyscale_image(), recolor_image(), scale_surface(), scale_surface_blended(), stretch_surface_horizontal(), and stretch_surface_vertical().
SDL_Rect create_rect | ( | const int | x, | |
const int | y, | |||
const int | w, | |||
const int | h | |||
) |
Creates an empty SDL_Rect.
Since SDL_Rect can't be created as temp variable in one step create this wrapper.
Definition at line 95 of file sdl_utils.cpp.
References rect.
Referenced by gui2::create_rect(), and gui2::twidget::get_rect().
Cuts a rectangle from a surface.
Definition at line 1107 of file sdl_utils.cpp.
References create_compatible_surface(), surface_lock::pixels(), and size.
Referenced by image::locator::load_image_sub_file().
Definition at line 602 of file sdl_utils.cpp.
References b, create_optimized_surface(), boost::foreach_detail_::end(), g, make_neutral_surface(), surface_lock::pixels(), and r.
void draw_centered_on_background | ( | surface | surf, | |
const SDL_Rect & | rect, | |||
const SDL_Color & | color, | |||
surface | target | |||
) |
Definition at line 1698 of file sdl_utils.cpp.
References r, and update_rect().
Referenced by display::draw_minimap(), mp::create::hide_children(), and mp::create::process_event().
void draw_rectangle | ( | int | x, | |
int | y, | |||
int | w, | |||
int | h, | |||
Uint32 | colour, | |||
surface | tg | |||
) |
Definition at line 1675 of file sdl_utils.cpp.
Referenced by map_editor::brush_bar::draw(), map_editor::terrain_palette::draw(), help::help_text_area::draw_contents(), display::draw_minimap(), and map_editor::update_l_button_palette().
void draw_solid_tinted_rectangle | ( | int | x, | |
int | y, | |||
int | w, | |||
int | h, | |||
int | r, | |||
int | g, | |||
int | b, | |||
double | alpha, | |||
surface | target | |||
) |
Definition at line 1689 of file sdl_utils.cpp.
References fill_rect_alpha(), and rect.
Referenced by draw_background(), gui::textbox::draw_contents(), gui::menu::draw_row(), gui::menu::style::draw_row_bg(), map_editor::preferences_dialog(), about::show_about(), show_intro_part(), and show_intro_part_helper().
void fill_rect_alpha | ( | SDL_Rect & | rect, | |
Uint32 | colour, | |||
Uint8 | alpha, | |||
surface const & | target | |||
) |
Definition at line 1446 of file sdl_utils.cpp.
References create_compatible_surface(), and r.
Referenced by gui::textbox::draw_contents(), draw_solid_tinted_rectangle(), and display::flip().
Definition at line 1205 of file sdl_utils.cpp.
References create_optimized_surface(), make_neutral_surface(), and surface_lock::pixels().
Referenced by image::locator::load_image_sub_file(), and image::reverse_image().
Definition at line 1234 of file sdl_utils.cpp.
References create_optimized_surface(), make_neutral_surface(), and surface_lock::pixels().
Referenced by image::locator::load_image_sub_file(), and display::render_unit_image().
SDL_Rect get_non_transparent_portion | ( | surface const & | surf | ) |
Definition at line 1507 of file sdl_utils.cpp.
References make_neutral_surface(), and surface_lock::pixels().
Referenced by display::draw_image_for_report().
Definition at line 1466 of file sdl_utils.cpp.
References create_compatible_surface().
Referenced by gui::dialog_frame::draw_background(), display::draw_image_for_report(), display::refresh_report(), gui2::twindow::show(), and surface_restorer::update().
Definition at line 557 of file sdl_utils.cpp.
References b, create_optimized_surface(), boost::foreach_detail_::end(), g, make_neutral_surface(), surface_lock::pixels(), and r.
Referenced by gui::slider::draw_contents(), gui::button::draw_contents(), and display::render_unit_image().
SDL_Color int_to_color | ( | const Uint32 | rgb | ) |
Definition at line 33 of file sdl_utils.cpp.
Referenced by game_display::add_chat_message(), game_display::draw_movement_info(), team::get_minimap_colour(), events::menu_handler::label_terrain(), and terrain_label::read().
SDL_Rect intersect_rects | ( | SDL_Rect const & | rect1, | |
SDL_Rect const & | rect2 | |||
) |
Definition at line 82 of file sdl_utils.cpp.
Referenced by surface_restorer::restore(), and display::scroll().
SDL_Color inverse | ( | const SDL_Color & | colour | ) |
Definition at line 121 of file sdl_utils.cpp.
References get_neutral_pixel_format().
Referenced by adjust_surface_alpha(), adjust_surface_alpha_add(), adjust_surface_colour(), blend_surface(), blur_alpha_surface(), blur_surface(), brighten_image(), game_display::calculate_energy_bar(), composer::compose(), create_cursor(), darken_image(), flip_surface(), flop_surface(), get_non_transparent_portion(), greyscale_image(), cutter::load_masks(), main(), mask_surface(), recolor_image(), scale_surface(), scale_surface_blended(), gui2::twindow::show(), stretch_surface_horizontal(), stretch_surface_vertical(), and gui2::timage::timage().
Applies a mask on a surface.
Definition at line 808 of file sdl_utils.cpp.
References b, boost::foreach_detail_::end(), g, make_neutral_surface(), surface_lock::pixels(), and r.
Referenced by image::get_hexed(), and image::locator::load_image_sub_file().
bool operator!= | ( | const SDL_Color & | a, | |
const SDL_Color & | b | |||
) |
bool operator!= | ( | const SDL_Rect & | a, | |
const SDL_Rect & | b | |||
) |
bool operator== | ( | const SDL_Color & | a, | |
const SDL_Color & | b | |||
) |
Definition at line 1586 of file sdl_utils.cpp.
bool operator== | ( | const SDL_Rect & | a, | |
const SDL_Rect & | b | |||
) |
Definition at line 1576 of file sdl_utils.cpp.
bool point_in_rect | ( | int | x, | |
int | y, | |||
const SDL_Rect & | rect | |||
) |
Definition at line 71 of file sdl_utils.cpp.
Referenced by gui::textbox::handle_event(), gui::scrollbar::handle_event(), gui::scrollarea::handle_event(), mp::gamebrowser::handle_event(), map_editor::brush_bar::handle_event(), map_editor::terrain_palette::handle_event(), map_editor::handle_mouse_button_event(), display::hex_clicked_on(), gui::button::hit(), display::minimap_location_on(), gui::slider::mouse_down(), gui::slider::mouse_motion(), help::help_text_area::item_at::operator()(), play_controller::play_slice(), gui::dialog::process(), help::help_browser::process_event(), gui::widget::process_help_string(), and gui2::tevent_handler::set_hover().
surface recolor_image | ( | surface | surf, | |
const std::map< Uint32, Uint32 > & | map_rgb, | |||
bool | optimize = true | |||
) |
Definition at line 652 of file sdl_utils.cpp.
References create_optimized_surface(), boost::foreach_detail_::end(), make_neutral_surface(), and surface_lock::pixels().
Referenced by image::locator::load_image_sub_file().
bool rects_overlap | ( | const SDL_Rect & | rect1, | |
const SDL_Rect & | rect2 | |||
) |
Definition at line 76 of file sdl_utils.cpp.
Referenced by display::create_buttons(), game_display::draw(), draw_panel(), gui::widget::hidden(), unit::redraw_unit(), and display::render_unit_image().
Definition at line 273 of file sdl_utils.cpp.
References a, b, create_optimized_surface(), ftofxp, fxpdiv, fxptoi, g, loc, make_neutral_surface(), surface_lock::pixels(), and r.
Referenced by gui::button::button(), map_editor::brush_bar::draw(), map_editor::terrain_palette::draw(), gui2::timage::draw(), draw_background(), gui::dialog_frame::draw_border(), mp::ui::draw_contents(), display::draw_image_for_report(), draw_label(), draw_panel(), gui::menu::imgsel_style::draw_row_bg(), gui::menu::style::get_item_image(), image::get_scaled_to_zoom(), image::get_unmasked(), image::getMinimap(), map_editor::set_mouseover_overlay(), about::show_about(), and show_intro_part().
Definition at line 433 of file sdl_utils.cpp.
References a, b, create_optimized_surface(), g, make_neutral_surface(), surface_lock::pixels(), r, and value.
Referenced by gui::scrollbar::draw_contents(), and image::getMinimap().
SDLKey sdl_keysym_from_name | ( | std::string const & | keyname | ) |
Definition at line 49 of file sdl_utils.cpp.
References name.
Referenced by hotkey::hotkey_item::load_from_config().
Streches a surface in the horizontal direction.
The stretches a surface it uses the first pixel in the horizontal direction of the original surface and copies that to the destination. This means only the first column of the original is used for the destination.
surf | The source surface. | |
w | The width of the resulting surface. | |
optimize | Should the return surface be RLE optimized. |
0 | Returned upon error. | |
surf | Returned if w == surf->w, note this ignores the optimize flag. |
Definition at line 168 of file sdl_utils.cpp.
References create_optimized_surface(), make_neutral_surface(), and surface_lock::pixels().
Referenced by gui2::timage::draw().
Streches a surface in the vertical direction.
The stretches a surface it uses the first pixel in the vertical direction of the original surface and copies that to the destination. This means only the first row of the original is used for the destination.
surf | The source surface. | |
h | The height of the resulting surface. | |
optimize | Should the return surface be RLE optimized. |
0 | Returned upon error. | |
surf | Returned if h == surf->h, note this ignores the optimize flag. |
Definition at line 228 of file sdl_utils.cpp.
References create_optimized_surface(), make_neutral_surface(), and surface_lock::pixels().
Referenced by gui2::timage::draw().
const SDL_Rect empty_rect = { 0, 0, 0, 0 } [static] |
Definition at line 50 of file sdl_utils.hpp.
Referenced by display::display(), font::get_floating_label_rect(), gui::menu::get_item_rect_internal(), display::redraw_everything(), and gui::dialog::show().
Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |