Skip to content

Commit

Permalink
Display: removed old drawing code and external draw calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Mar 13, 2018
1 parent 1ee7600 commit a7fbf15
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 96 deletions.
12 changes: 6 additions & 6 deletions src/actions/vision.cpp
Expand Up @@ -325,8 +325,8 @@ bool shroud_clearer::clear_unit(const map_location &view_loc, team &view_team,
move_unit_spectator * spectator, bool instant)
{
// Give animations a chance to progress; see bug #20324.
if ( !instant && display::get_singleton() )
display::get_singleton()->draw(true);
// TODO: ^ is this something we need to worry about now that external draw calls are removed?
// vultraz, 7/5/2017

bool cleared_something = false;
// Dummy variables to make some logic simpler.
Expand All @@ -340,15 +340,15 @@ bool shroud_clearer::clear_unit(const map_location &view_loc, team &view_team,
if ( view_team_ != &view_team ) {
calculate_jamming(&view_team);
// Give animations a chance to progress; see bug #20324.
if ( !instant && display::get_singleton() )
display::get_singleton()->draw(true);
// TODO: ^ is this something we need to worry about now that external draw calls are removed?
// vultraz, 7/5/2017
}

// Determine the hexes to clear.
pathfind::vision_path sight(costs, slowed, sight_range, view_loc, jamming_);
// Give animations a chance to progress; see bug #20324.
if ( !instant && display::get_singleton() )
display::get_singleton()->draw(true);
// TODO: ^ is this something we need to worry about now that external draw calls are removed?
// vultraz, 7/5/2017

// Clear the fog.
for (const pathfind::paths::step &dest : sight.destinations) {
Expand Down
81 changes: 6 additions & 75 deletions src/display.cpp
Expand Up @@ -788,7 +788,7 @@ bool display::screenshot(const std::string& filename, bool map_screenshot)
// we reroute render output to the screenshot surface and invalidate all
map_screenshot_= true ;
DBG_DP << "draw() with map_screenshot\n";
draw(true,true);
//draw(true,true);

// finally save the image on disk
res = image::save_image(map_screenshot_surf_,filename);
Expand Down Expand Up @@ -1814,7 +1814,7 @@ bool display::set_zoom(unsigned int amount, const bool validate_value_and_set_in

// Forces a redraw after zooming.
// This prevents some graphic glitches from occurring.
draw();
//draw();

return true;
}
Expand Down Expand Up @@ -1866,7 +1866,7 @@ void display::scroll_to_xy(int screenxpos, int screenypos, SCROLL_TYPE scroll_ty

if(scroll_type == WARP || scroll_type == ONSCREEN_WARP || turbo_speed() > 2.0 || preferences::scroll_speed() > 99) {
scroll(xmove,ymove,true);
draw();
//draw();
return;
}

Expand Down Expand Up @@ -1923,7 +1923,7 @@ void display::scroll_to_xy(int screenxpos, int screenypos, SCROLL_TYPE scroll_ty
scroll(dx,dy,true);
x_old += dx;
y_old += dy;
draw();
//draw();
}
}

Expand Down Expand Up @@ -2533,75 +2533,6 @@ void display::read(const config& cfg)

// #define SLOW_THINGS_DOWN

void display::draw()
{
draw_new();
//draw(true, false);
}

void display::draw(bool update)
{
draw(update, false);
}

void display::draw(bool update, bool force)
{
return;

// log_scope("display::draw");

if(video_.update_locked()) {
return;
}

if (dirty_) {
flip_locker flip_lock(video_);
dirty_ = false;
redraw_everything();
return;
}

// Trigger cache rebuild when preference gets changed
if (animate_water_ != preferences::animate_water()) {
animate_water_ = preferences::animate_water();
builder_->rebuild_cache_all();
}

set_scontext_unsynced leave_synced_context;

draw_init();

pre_draw();

// invalidate all that needs to be invalidated
invalidate_animations();
// at this stage we have everything that needs to be invalidated for this redraw
// save it as the previous invalidated, and merge with the previous invalidated_
// we merge with the previous redraw because if a hex had a unit last redraw but
// not this one, nobody will tell us to redraw (cleanup)

// these new invalidations cannot cause any propagation because
// if a hex was invalidated last turn but not this turn, then
// * case of no unit in neighbor hex=> no propagation
// * case of unit in hex but was there last turn=>its hexes are invalidated too
// * case of unit in hex not there last turn => it moved, so was invalidated previously
if(!get_map().empty()) {
#ifdef SLOW_THINGS_DOWN
int simulate_delay = 0;
#endif
post_commit();
draw_sidebar();

#ifdef SLOW_THINGS_DOWN
SDL_Delay(2 * simulate_delay + rand() % 20);
#endif
}

draw_wrap(update, force);

post_draw();
}

void display::redraw_everything()
{
if(video_.update_locked()) {
Expand Down Expand Up @@ -2647,7 +2578,7 @@ void display::redraw_everything()
int ticks1 = SDL_GetTicks();
//invalidate_all();
int ticks2 = SDL_GetTicks();
draw(true,true);
//draw(true,true);
int ticks3 = SDL_GetTicks();
LOG_DP << "invalidate and draw: " << (ticks3 - ticks2) << " and " << (ticks2 - ticks1) << "\n";

Expand Down Expand Up @@ -2888,7 +2819,7 @@ void display::draw_hex(const map_location& loc)
#endif
}

void display::draw_new()
void display::draw()
{
// Execute any pre-draw actions from derived classes.
pre_draw();
Expand Down
8 changes: 1 addition & 7 deletions src/display.hpp
Expand Up @@ -542,13 +542,7 @@ class display : public video2::draw_layering
* Not virtual, since it gathers common actions. Calls various protected
* virtuals (further below) to allow specialized behavior in derived classes.
*/
virtual void draw();

void draw(bool update);

void draw(bool update, bool force);

void draw_new();
virtual void draw() override;

map_labels& labels();
const map_labels& labels() const;
Expand Down
3 changes: 0 additions & 3 deletions src/gui/dialogs/editor/custom_tod.cpp
Expand Up @@ -288,9 +288,6 @@ void custom_tod::update_tod_display()
// redraw_everything() instead.

disp->update_tod(&get_selected_tod());

// redraw tiles
disp->draw(false);
}

void custom_tod::update_lawful_bonus(window& window)
Expand Down
4 changes: 0 additions & 4 deletions src/scripting/game_lua_kernel.cpp
Expand Up @@ -3287,7 +3287,6 @@ int game_lua_kernel::intf_color_adjust(lua_State *L)
vconfig cfg(luaW_checkvconfig(L, 1));

game_display_->adjust_color_overlay(cfg["red"], cfg["green"], cfg["blue"]);
game_display_->draw(true,true);
}
return 0;
}
Expand Down Expand Up @@ -3346,8 +3345,6 @@ int game_lua_kernel::intf_redraw(lua_State *L)
}
screen.recalculate_minimap();
}

screen.draw(true,true);
}
return 0;
}
Expand Down Expand Up @@ -3645,7 +3642,6 @@ int game_lua_kernel::intf_scroll(lua_State * L)

if (game_display_) {
game_display_->scroll(x, y, true);
game_display_->draw(true, true);
}

return 0;
Expand Down
1 change: 0 additions & 1 deletion src/units/udisplay.cpp
Expand Up @@ -692,7 +692,6 @@ void unit_recruited(const map_location& loc,const map_location& leader_loc)
disp->scroll_to_tile(loc,game_display::ONSCREEN,true,false);
}

disp->draw();
u->set_hidden(false);
animator.add_animation(&*u, "recruited", loc, leader_loc);
animator.start_animations();
Expand Down

0 comments on commit a7fbf15

Please sign in to comment.