Skip to content

Commit

Permalink
Rename ttexture to timage.
Browse files Browse the repository at this point in the history
  • Loading branch information
lipk committed Jul 17, 2014
1 parent 0acb2e1 commit 7d35356
Show file tree
Hide file tree
Showing 18 changed files with 124 additions and 124 deletions.
38 changes: 19 additions & 19 deletions src/display.cpp
Expand Up @@ -338,7 +338,7 @@ void display::init_flags_for_side_internal(size_t n, const std::string& side_col
}

#ifdef SDL_GPU
sdl::ttexture display::get_flag(const map_location& loc)
sdl::timage display::get_flag(const map_location& loc)
{
t_translation::t_terrain terrain = get_map().get_terrain(loc);

Expand All @@ -357,7 +357,7 @@ sdl::ttexture display::get_flag(const map_location& loc)
}
}

return sdl::ttexture();
return sdl::timage();
}
#else
surface display::get_flag(const map_location& loc)
Expand Down Expand Up @@ -949,7 +949,7 @@ static const std::string& get_direction(size_t n)
}

#ifdef SDL_GPU
std::vector<sdl::ttexture> display::get_fog_shroud_images(const map_location& loc, image::TYPE image_type)
std::vector<sdl::timage> display::get_fog_shroud_images(const map_location& loc, image::TYPE image_type)
#else
std::vector<surface> display::get_fog_shroud_images(const map_location& loc, image::TYPE image_type)
#endif
Expand Down Expand Up @@ -1031,14 +1031,14 @@ std::vector<surface> display::get_fog_shroud_images(const map_location& loc, ima

// now get the surfaces
#ifdef SDL_GPU
std::vector<sdl::ttexture> res;
std::vector<sdl::timage> res;
#else
std::vector<surface> res;
#endif

BOOST_FOREACH(std::string& name, names) {
#ifdef SDL_GPU
const sdl::ttexture img(image::get_texture(name, image_type));
const sdl::timage img(image::get_texture(name, image_type));
if (!img.null())
res.push_back(img);
#else
Expand All @@ -1053,7 +1053,7 @@ std::vector<surface> display::get_fog_shroud_images(const map_location& loc, ima

// TODO: proper SDL_gpu implementation
#ifdef SDL_GPU
std::vector<sdl::ttexture> display::get_terrain_images(
std::vector<sdl::timage> display::get_terrain_images(
const map_location &loc,
const std::string& timeid,
image::TYPE image_type,
Expand All @@ -1066,7 +1066,7 @@ std::vector<surface> display::get_terrain_images(const map_location &loc,
#endif
{
#ifdef SDL_GPU
std::vector<sdl::ttexture> res;
std::vector<sdl::timage> res;
#else
std::vector<surface> res;
#endif
Expand Down Expand Up @@ -1143,7 +1143,7 @@ std::vector<surface> display::get_terrain_images(const map_location &loc,

if (!surf.null()) {
#ifdef SDL_GPU
res.push_back(sdl::ttexture(surf));
res.push_back(sdl::timage(surf));
#else
res.push_back(surf);
#endif
Expand All @@ -1157,14 +1157,14 @@ std::vector<surface> display::get_terrain_images(const map_location &loc,
#ifdef SDL_GPU
void display::drawing_buffer_add(const tdrawing_layer layer,
const map_location& loc, int x, int y,
const sdl::ttexture &img)
const sdl::timage &img)
{
drawing_buffer_.push_back(tblit(layer, loc, x, y, img));
}

void display::drawing_buffer_add(const tdrawing_layer layer,
const map_location& loc, int x, int y,
const std::vector<sdl::ttexture> &imgs)
const std::vector<sdl::timage> &imgs)
{
drawing_buffer_.push_back(tblit(layer, loc, x, y, imgs));
}
Expand Down Expand Up @@ -1276,7 +1276,7 @@ void display::drawing_buffer_commit()
*/

BOOST_FOREACH(tblit &blit, drawing_buffer_) {
BOOST_FOREACH(sdl::ttexture& img, blit.images()) {
BOOST_FOREACH(sdl::timage& img, blit.images()) {
if (!img.null()) {
screen_.draw_texture(img, blit.x(), blit.y());
}
Expand Down Expand Up @@ -1545,8 +1545,8 @@ void display::draw_text_in_hex(const map_location& loc,
const int y = get_location_y(loc) - text_surf->h/2
+ static_cast<int>(y_in_hex* hex_size());
#ifdef SDL_GPU
sdl::ttexture text_img(text_surf);
sdl::ttexture back_img(back_surf);
sdl::timage text_img(text_surf);
sdl::timage back_img(back_surf);

for (int dy=-1; dy <= 1; ++dy) {
for (int dx=-1; dx <= 1; ++dx) {
Expand Down Expand Up @@ -1612,7 +1612,7 @@ void display::render_image(int x, int y, const display::tdrawing_layer drawing_l
return;
}
#ifdef SDL_GPU
sdl::ttexture img(surf);
sdl::timage img(surf);

if(submerged > 0.0) {
// divide the surface into 2 parts
Expand Down Expand Up @@ -2760,7 +2760,7 @@ void display::draw_hex(const map_location& loc) {
? image::get_lighted_image(overlays.first->second.image, lt, image::SCALED_TO_HEX)
: image::get_image(overlays.first->second.image, image_type);
#ifdef SDL_GPU
drawing_buffer_add(LAYER_TERRAIN_BG, loc, xpos, ypos, sdl::ttexture(surf));
drawing_buffer_add(LAYER_TERRAIN_BG, loc, xpos, ypos, sdl::timage(surf));
#else
drawing_buffer_add(LAYER_TERRAIN_BG, loc, xpos, ypos, surf);
#endif
Expand Down Expand Up @@ -2854,8 +2854,8 @@ void display::draw_hex(const map_location& loc) {
off_y -= text->h / 2;
}
#ifdef SDL_GPU
drawing_buffer_add(LAYER_FOG_SHROUD, loc, off_x, off_y, sdl::ttexture(bg));
drawing_buffer_add(LAYER_FOG_SHROUD, loc, off_x, off_y, sdl::ttexture(text));
drawing_buffer_add(LAYER_FOG_SHROUD, loc, off_x, off_y, sdl::timage(bg));
drawing_buffer_add(LAYER_FOG_SHROUD, loc, off_x, off_y, sdl::timage(text));
#else
drawing_buffer_add(LAYER_FOG_SHROUD, loc, off_x, off_y, bg);
drawing_buffer_add(LAYER_FOG_SHROUD, loc, off_x, off_y, text);
Expand All @@ -2873,8 +2873,8 @@ void display::draw_hex(const map_location& loc) {
off_y -= text->h / 2;
}
#ifdef SDL_GPU
drawing_buffer_add(LAYER_FOG_SHROUD, loc, off_x, off_y, sdl::ttexture(bg));
drawing_buffer_add(LAYER_FOG_SHROUD, loc, off_x, off_y, sdl::ttexture(text));
drawing_buffer_add(LAYER_FOG_SHROUD, loc, off_x, off_y, sdl::timage(bg));
drawing_buffer_add(LAYER_FOG_SHROUD, loc, off_x, off_y, sdl::timage(text));
#else
drawing_buffer_add(LAYER_FOG_SHROUD, loc, off_x, off_y, bg);
drawing_buffer_add(LAYER_FOG_SHROUD, loc, off_x, off_y, text);
Expand Down
26 changes: 13 additions & 13 deletions src/display.hpp
Expand Up @@ -439,11 +439,11 @@ class display : public filter_context
* mouseover_hex_overlay_ require a prerendered surface
* and is drawn underneath the mouse's location
*/
void set_mouseover_hex_overlay(const sdl::ttexture& image)
void set_mouseover_hex_overlay(const sdl::timage& image)
{ mouseover_hex_overlay_ = image; }

void clear_mouseover_hex_overlay()
{ mouseover_hex_overlay_ = sdl::ttexture(); }
{ mouseover_hex_overlay_ = sdl::timage(); }
#else
/**
* mouseover_hex_overlay_ require a prerendered surface
Expand Down Expand Up @@ -726,12 +726,12 @@ class display : public filter_context
enum TERRAIN_TYPE { BACKGROUND, FOREGROUND};

#ifdef SDL_GPU
std::vector<sdl::ttexture> get_terrain_images(const map_location &loc,
std::vector<sdl::timage> get_terrain_images(const map_location &loc,
const std::string& timeid,
image::TYPE type,
TERRAIN_TYPE terrain_type);

std::vector<sdl::ttexture> get_fog_shroud_images(const map_location& loc, image::TYPE image_type);
std::vector<sdl::timage> get_fog_shroud_images(const map_location& loc, image::TYPE image_type);
#else
std::vector<surface> get_terrain_images(const map_location &loc,
const std::string& timeid,
Expand Down Expand Up @@ -798,10 +798,10 @@ class display : public filter_context
std::set<map_location> invalidated_;
std::set<map_location> previous_invalidated_;
#ifdef SDL_GPU
sdl::ttexture mouseover_hex_overlay_;
sdl::timage mouseover_hex_overlay_;
// If we're transitioning from one time of day to the next,
// then we will use these two masks on top of all hexes when we blit.
sdl::ttexture tod_hex_mask1, tod_hex_mask2;
sdl::timage tod_hex_mask1, tod_hex_mask2;
#else
surface mouseover_hex_overlay_;
// If we're transitioning from one time of day to the next,
Expand All @@ -825,7 +825,7 @@ class display : public filter_context

#ifdef SDL_GPU
// This surface must be freed by the caller
sdl::ttexture get_flag(const map_location& loc);
sdl::timage get_flag(const map_location& loc);
#else
// This surface must be freed by the caller
surface get_flag(const map_location& loc);
Expand Down Expand Up @@ -966,13 +966,13 @@ class display : public filter_context
public:
#ifdef SDL_GPU
tblit(const tdrawing_layer layer, const map_location& loc,
const int x, const int y, const sdl::ttexture& image)
const int x, const int y, const sdl::timage& image)
: x_(x), y_(y), images_(1, image), key_(loc, layer)
{}

tblit(const tdrawing_layer layer, const map_location& loc,
const int x, const int y,
const std::vector<sdl::ttexture>& images)
const std::vector<sdl::timage>& images)
: x_(x), y_(y), images_(images), key_(loc, layer)
{}
#else
Expand All @@ -994,7 +994,7 @@ class display : public filter_context
int x() const { return x_; }
int y() const { return y_; }
#ifdef SDL_GPU
std::vector<sdl::ttexture> &images() { return images_; }
std::vector<sdl::timage> &images() { return images_; }
#else
const std::vector<surface> &surf() const { return surf_; }
const SDL_Rect &clip() const { return clip_; }
Expand All @@ -1006,7 +1006,7 @@ class display : public filter_context
int x_; /**< x screen coordinate to render at. */
int y_; /**< y screen coordinate to render at. */
#ifdef SDL_GPU
std::vector<sdl::ttexture> images_;
std::vector<sdl::timage> images_;
#else
std::vector<surface> surf_; /**< surface(s) to render. */
SDL_Rect clip_; /**<
Expand All @@ -1024,11 +1024,11 @@ class display : public filter_context
#ifdef SDL_GPU
void drawing_buffer_add(const tdrawing_layer layer,
const map_location& loc, int x, int y,
const sdl::ttexture& img);
const sdl::timage& img);

void drawing_buffer_add(const tdrawing_layer layer,
const map_location& loc, int x, int y,
const std::vector<sdl::ttexture> &imgs);
const std::vector<sdl::timage> &imgs);
#else
/**
* Add an item to the drawing buffer. You need to update screen on affected area
Expand Down
18 changes: 9 additions & 9 deletions src/game_display.cpp
Expand Up @@ -60,7 +60,7 @@ std::map<map_location,fixed_t> game_display::debugHighlights_;
* This function is only used internally by game_display so I have moved it out of the header into the compilaton unit.
*/
#ifdef SDL_GPU
std::vector<sdl::ttexture> footsteps_images(const map_location& loc, const pathfind::marked_route & route_, const display_context * dc_);
std::vector<sdl::timage> footsteps_images(const map_location& loc, const pathfind::marked_route & route_, const display_context * dc_);
#else
std::vector<surface> footsteps_images(const map_location& loc, const pathfind::marked_route & route_, const display_context * dc_);
#endif
Expand Down Expand Up @@ -123,12 +123,12 @@ void game_display::new_turn()
#ifdef SDL_GPU
if(old_mask != NULL) {
const fixed_t proportion = ftofxp(1.0) - fxpdiv(i,niterations);
tod_hex_mask1 = sdl::ttexture(adjust_surface_alpha(old_mask,proportion));
tod_hex_mask1 = sdl::timage(adjust_surface_alpha(old_mask,proportion));
}

if(new_mask != NULL) {
const fixed_t proportion = fxpdiv(i,niterations);
tod_hex_mask2 = sdl::ttexture(adjust_surface_alpha(new_mask,proportion));
tod_hex_mask2 = sdl::timage(adjust_surface_alpha(new_mask,proportion));
}
#else
if(old_mask != NULL) {
Expand All @@ -154,8 +154,8 @@ void game_display::new_turn()
}

#ifdef SDL_GPU
tod_hex_mask1 = sdl::ttexture();
tod_hex_mask2 = sdl::ttexture();
tod_hex_mask1 = sdl::timage();
tod_hex_mask2 = sdl::timage();
#else
tod_hex_mask1.assign(NULL);
tod_hex_mask2.assign(NULL);
Expand Down Expand Up @@ -373,7 +373,7 @@ void game_display::draw_hex(const map_location& loc)
if (!(w->is_active() && w->has_temp_move()))
{
#ifdef SDL_GPU
std::vector<sdl::ttexture> footstepImages = footsteps_images(loc, route_, dc_);
std::vector<sdl::timage> footstepImages = footsteps_images(loc, route_, dc_);
#else
std::vector<surface> footstepImages = footsteps_images(loc, route_, dc_);
#endif
Expand Down Expand Up @@ -583,13 +583,13 @@ void game_display::draw_movement_info(const map_location& loc)
}

#ifdef SDL_GPU
std::vector<sdl::ttexture> footsteps_images(const map_location& loc, const pathfind::marked_route & route_, const display_context * dc_)
std::vector<sdl::timage> footsteps_images(const map_location& loc, const pathfind::marked_route & route_, const display_context * dc_)
#else
std::vector<surface> footsteps_images(const map_location& loc, const pathfind::marked_route & route_, const display_context * dc_)
#endif
{
#ifdef SDL_GPU
std::vector<sdl::ttexture> res;
std::vector<sdl::timage> res;
#else
std::vector<surface> res;
#endif
Expand Down Expand Up @@ -618,7 +618,7 @@ std::vector<surface> footsteps_images(const map_location& loc, const pathfind::m
const std::string foot_speed_prefix = game_config::foot_speed_prefix[image_number-1];

#ifdef SDL_GPU
sdl::ttexture teleport;
sdl::timage teleport;
#else
surface teleport = NULL;
#endif
Expand Down
22 changes: 11 additions & 11 deletions src/image.cpp
Expand Up @@ -623,13 +623,13 @@ surface load_from_disk(const locator &loc)
}

#ifdef SDL_GPU
sdl::ttexture load_texture(const locator &loc)
sdl::timage load_texture(const locator &loc)
{
surface img = load_from_disk(loc);
if (!img.null()) {
return sdl::ttexture(img);
return sdl::timage(img);
} else {
return sdl::ttexture();
return sdl::timage();
}
}
#endif
Expand Down Expand Up @@ -902,10 +902,10 @@ surface get_image(const image::locator& i_locator, TYPE type)
}

#ifdef SDL_GPU
sdl::ttexture get_texture(const locator& loc, TYPE type)
sdl::timage get_texture(const locator& loc, TYPE type)
{
if (loc.is_void()) {
return sdl::ttexture();
return sdl::timage();
}

texture_cache *cache;
Expand All @@ -924,25 +924,25 @@ sdl::ttexture get_texture(const locator& loc, TYPE type)
cache = &txt_hexed_images_;
break;
default:
return sdl::ttexture();
return sdl::timage();
}

if (!loc.in_cache(*cache)) {
if (type == UNSCALED || type == SCALED_TO_ZOOM) {
sdl::ttexture txt = load_texture(loc);
sdl::timage txt = load_texture(loc);
loc.add_to_cache(*cache, txt);
} else if (type == BRIGHTENED) {
surface surf = get_brightened(loc);
sdl::ttexture txt(surf);
sdl::timage txt(surf);
loc.add_to_cache(*cache, txt);
} else {
surface surf = get_hexed(loc);
sdl::ttexture txt(surf);
sdl::timage txt(surf);
loc.add_to_cache(*cache, txt);
}
}

sdl::ttexture result = loc.locate_in_cache(*cache);
sdl::timage result = loc.locate_in_cache(*cache);

switch (type) {
case UNSCALED:
Expand All @@ -956,7 +956,7 @@ sdl::ttexture get_texture(const locator& loc, TYPE type)
result.set_scale(zoom, zoom);
break;
default:
return sdl::ttexture();
return sdl::timage();
}

return result;
Expand Down

0 comments on commit 7d35356

Please sign in to comment.