Skip to content

Commit

Permalink
Display: avoid temp vectors when rendering partial fog/shround images…
Browse files Browse the repository at this point in the history
… on hex
  • Loading branch information
Vultraz committed Mar 18, 2018
1 parent eeece5e commit 2ba020a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
18 changes: 4 additions & 14 deletions src/display.cpp
Expand Up @@ -903,7 +903,7 @@ static const std::string& get_direction(size_t n)
return dirs[n >= dirs.size() ? 0 : n];
}

std::vector<texture> display::get_fog_shroud_images(const map_location& loc, image::TYPE /*image_type*/)
void display::draw_fog_shroud_transition_images(const map_location& loc, image::TYPE /*image_type*/)
{
std::vector<std::string> names;

Expand Down Expand Up @@ -979,18 +979,10 @@ std::vector<texture> display::get_fog_shroud_images(const map_location& loc, ima
}
}

// now get the surfaces
std::vector<texture> res;
res.reserve(names.size());

// Now render the images
for(std::string& name : names) {
texture tex(image::get_texture(name)); // TODO: image_type
if(tex) {
res.push_back(std::move(tex));
}
render_scaled_to_zoom(image::get_texture(name), loc); // TODO: image_type
}

return res;
}

void display::toggle_benchmark()
Expand Down Expand Up @@ -2601,9 +2593,7 @@ void display::draw_gamemap()

// Transitions to main hexes.
if(!is_shrouded) {
for(const texture& t : get_fog_shroud_images(loc, image_type)) {
render_scaled_to_zoom(t, loc);
}
draw_fog_shroud_transition_images(loc, image_type);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/display.hpp
Expand Up @@ -973,8 +973,8 @@ class display : public video2::draw_layering
*/
virtual const SDL_Rect& get_clip_rect();

/** Gets the appropriate fog or shroud images for a specific hex. */
std::vector<texture> get_fog_shroud_images(const map_location& loc, image::TYPE image_type);
/** Draw the appropriate fog or shroud transition images for a specific hex. */
void draw_fog_shroud_transition_images(const map_location& loc, image::TYPE image_type);

void draw_image_for_report(surface& img, SDL_Rect& rect);

Expand Down

0 comments on commit 2ba020a

Please sign in to comment.