Skip to content

Commit

Permalink
CVideo: removed update_rect functions
Browse files Browse the repository at this point in the history
These have been functionally useless, since none of their code was ever executed. Since this hasn't caused
any problems this far, I'm removing them.
  • Loading branch information
Vultraz committed Dec 6, 2016
1 parent 0c18c9c commit bf86912
Show file tree
Hide file tree
Showing 20 changed files with 1 addition and 124 deletions.
11 changes: 0 additions & 11 deletions src/display.cpp
Expand Up @@ -1325,7 +1325,6 @@ void display::flip()
const Uint32 color = SDL_MapRGBA(video().getSurface()->format,0,0,0,SDL_ALPHA_OPAQUE);
// Adjust the alpha if you want to balance cpu-cost / smooth sunset
sdl::fill_rect_alpha(r, color, 1, frameBuffer);
update_rect(r);
}
font::draw_floating_labels(frameBuffer);
events::raise_volatile_draw_event();
Expand Down Expand Up @@ -1403,7 +1402,6 @@ static void draw_panel(CVideo &video, const theme::panel& panel, std::vector<std
surf.assign(tile_surface(surf,loc.w,loc.h));
}
video.blit_surface(loc.x, loc.y, surf);
update_rect(loc);
}
}

Expand Down Expand Up @@ -1447,7 +1445,6 @@ static void draw_label(CVideo& video, surface target, const theme::label& label)
font::draw_text(&video,loc,label.font_size(),font::NORMAL_COLOR,text,loc.x,loc.y);
}

update_rect(loc);
}

void display::draw_all_panels()
Expand Down Expand Up @@ -1642,8 +1639,6 @@ void display::draw_init()
const surface& screen = get_screen_surface();
clip_rect_setter set_clip_rect(screen, &clip_rect);
draw_background(screen, clip_rect, theme_.border().background_image);
update_rect(clip_rect);

redraw_background_ = false;

// Force a full map redraw
Expand Down Expand Up @@ -1986,7 +1981,6 @@ bool display::scroll(int xmove, int ymove, bool force)
invalidate_locations_in_rect(r);
}
scroll_event_.notify_observers();
update_rect(map_area());

redrawMinimap_ = true;
return true;
Expand Down Expand Up @@ -2527,8 +2521,6 @@ void display::draw_invalidated() {
int xpos = get_location_x(loc);
int ypos = get_location_y(loc);

update_rect(xpos, ypos, zoom_, zoom_);

const bool on_map = get_map().on_board(loc);
SDL_Rect hex_rect = sdl::create_rect(xpos, ypos, zoom_, zoom_);
if(!sdl::rects_overlap(hex_rect,clip_rect)) {
Expand Down Expand Up @@ -2819,7 +2811,6 @@ void display::refresh_report(const std::string& report_name, const config * new_

if (surf) {
sdl_blit(surf, nullptr, screen_.getSurface(), &rect);
update_rect(rect);
}

// If the rectangle has just changed, assign the surface to it
Expand All @@ -2838,7 +2829,6 @@ void display::refresh_report(const std::string& report_name, const config * new_
ERR_DP << "Could not backup background for report!" << std::endl;
}
}
update_rect(rect);
}

tooltips::clear_tooltips(rect);
Expand Down Expand Up @@ -3003,7 +2993,6 @@ void display::invalidate_all()
#pragma omp critical(invalidated_)
#endif //_OPENMP
invalidated_.clear();
update_rect(map_area());
}

bool display::invalidate(const map_location& loc)
Expand Down
1 change: 0 additions & 1 deletion src/editor/palette/editor_palettes.cpp
Expand Up @@ -403,7 +403,6 @@ void editor_palette<Item>::draw_contents()
y += item_space_;
counter++;
}
update_rect(location());
}
template void editor_palette<t_translation::terrain_code>::draw_contents();
template void editor_palette<unit_type>::draw_contents();
Expand Down
1 change: 0 additions & 1 deletion src/editor/palette/location_palette.cpp
Expand Up @@ -358,7 +358,6 @@ void location_palette::draw_contents()
// Adjust location
y += item_space_;
}
update_rect(location());
}

std::vector<std::string> location_palette::action_pressed() const
Expand Down
2 changes: 0 additions & 2 deletions src/editor/palette/tristate_button.cpp
Expand Up @@ -268,8 +268,6 @@ void tristate_button::draw_contents() {
clipArea.h -= 2 * offset;
font::draw_text(&video(), clipArea, font_size, button_color, label_, textx,
texty);

update_rect(loc);
}

//TODO move to widget
Expand Down
4 changes: 0 additions & 4 deletions src/floating_label.cpp
Expand Up @@ -181,8 +181,6 @@ void floating_label::draw(surface screen)
const clip_rect_setter clip_setter(screen, &clip_rect_);
sdl_copy_portion(screen,&rect,buf_,nullptr);
sdl_blit(surf_,nullptr,screen,&rect);

update_rect(rect);
}

void floating_label::undraw(surface screen)
Expand All @@ -194,8 +192,6 @@ void floating_label::undraw(surface screen)
const clip_rect_setter clip_setter(screen, &clip_rect_);
sdl_blit(buf_,nullptr,screen,&rect);

update_rect(rect);

move(xmove_,ymove_);
if(lifetime_ > 0) {
--lifetime_;
Expand Down
14 changes: 0 additions & 14 deletions src/gui/widgets/window.cpp
Expand Up @@ -674,7 +674,6 @@ int window::show(const bool restore, const unsigned auto_close_timeout)
if(restore_) {
SDL_Rect rect = get_rectangle();
sdl_blit(restorer_, 0, video_.getSurface(), &rect);
update_rect(get_rectangle());
font::undraw_floating_labels(video_.getSurface());
}
throw;
Expand All @@ -686,7 +685,6 @@ int window::show(const bool restore, const unsigned auto_close_timeout)
if(restore_) {
SDL_Rect rect = get_rectangle();
sdl_blit(restorer_, 0, video_.getSurface(), &rect);
update_rect(get_rectangle());
font::undraw_floating_labels(video_.getSurface());
}

Expand All @@ -711,9 +709,6 @@ void window::draw()
if(restore_ && restorer_) {
SDL_Rect rect = get_rectangle();
sdl_blit(restorer_, 0, frame_buffer, &rect);
// Since the old area might be bigger as the new one, invalidate
// it.
update_rect(rect);
}

layout();
Expand Down Expand Up @@ -746,7 +741,6 @@ void window::draw()
/* Force to update and redraw the entire screen */
dirty_list_.clear();
dirty_list_.push_back(std::vector<widget*>(1, this));
update_rect(screen_area());
}
}

Expand All @@ -761,7 +755,6 @@ void window::draw()
= SDL_MapRGBA(frame_buffer->format, 0, 0, 0, SDL_ALPHA_OPAQUE);

sdl::fill_rect_alpha(r, color, 1, frame_buffer);
update_rect(r);
}
}
return;
Expand All @@ -781,7 +774,6 @@ void window::draw()
#if 0
dirty_list_.clear();
dirty_list_.push_back(std::vector<widget*>(1, this));
update_rect(screen_area());
#else
clip_rect_setter clip(frame_buffer, &dirty_rect);
#endif
Expand Down Expand Up @@ -854,18 +846,13 @@ void window::draw()
(**ritor).draw_foreground(frame_buffer, 0, 0);
(**ritor).set_is_dirty(false);
}

update_rect(dirty_rect);
}

dirty_list_.clear();

std::vector<widget*> call_stack;
populate_dirty_list(*this, call_stack);
assert(dirty_list_.empty());

SDL_Rect rect = get_rectangle();
update_rect(rect);
}

void window::undraw()
Expand All @@ -875,7 +862,6 @@ void window::undraw()
sdl_blit(restorer_, 0, video_.getSurface(), &rect);
// Since the old area might be bigger as the new one, invalidate
// it.
update_rect(rect);
}
}

Expand Down
3 changes: 0 additions & 3 deletions src/halo.cpp
Expand Up @@ -251,8 +251,6 @@ bool halo_impl::effect::render()

sdl_blit(surf_,nullptr,screen,&rect);

update_rect(rect_);

return true;
}

Expand Down Expand Up @@ -286,7 +284,6 @@ void halo_impl::effect::unrender()

SDL_Rect rect = sdl::create_rect(xpos, ypos, surf_->w, surf_->h);
sdl_blit(buffer_,nullptr,screen,&rect);
update_rect(rect);
}

bool halo_impl::effect::on_location(const std::set<map_location>& locations) const
Expand Down
3 changes: 1 addition & 2 deletions src/help/help_text_area.cpp
Expand Up @@ -22,7 +22,7 @@
#include "sdl/rect.hpp" // for draw_rectangle, etc
#include "serialization/parser.hpp" // for read, write
#include "util.hpp" // for lexical_cast, etc
#include "video.hpp" // for update_rect, CVideo
#include "video.hpp" // for CVideo

#include <algorithm> // for max, min, find_if
#include <ostream> // for operator<<, stringstream, etc
Expand Down Expand Up @@ -539,7 +539,6 @@ void help_text_area::draw_contents()
sdl_blit(it->surf, nullptr, screen, &dst);
}
}
update_rect(loc);
}

void help_text_area::scroll(unsigned int)
Expand Down
1 change: 0 additions & 1 deletion src/intro.cpp
Expand Up @@ -56,7 +56,6 @@ void the_end(CVideo &video, std::string text, unsigned int duration)

const color_t col = color_t(uint8_t(n), uint8_t(n), uint8_t(n), uint8_t(n));
font::draw_text(&video,area,font_size,col,text,area.x,area.y);
update_rect(area);

events::pump();
events::raise_process_event();
Expand Down
1 change: 0 additions & 1 deletion src/playsingle_controller.cpp
Expand Up @@ -270,7 +270,6 @@ LEVEL_RESULT playsingle_controller::play_scenario(const config& level)
0, 0, gui_->video().getx(), gui_->video().gety(), 0, 0, 0, 1.0,
gui_->video().getSurface()
);
update_rect(0, 0, gui_->video().getx(), gui_->video().gety());
}

ai_testing::log_game_end();
Expand Down
3 changes: 0 additions & 3 deletions src/sdl/utils.cpp
Expand Up @@ -2497,7 +2497,6 @@ void surface_restorer::restore(SDL_Rect const &dst) const
src.x -= rect_.x;
src.y -= rect_.y;
sdl_blit(surface_, &src, target_->getSurface(), &dst2);
update_rect(dst2);
}

void surface_restorer::restore() const
Expand All @@ -2506,7 +2505,6 @@ void surface_restorer::restore() const
return;
SDL_Rect dst = rect_;
sdl_blit(surface_, nullptr, target_->getSurface(), &dst);
update_rect(rect_);
}

void surface_restorer::update()
Expand Down Expand Up @@ -2536,7 +2534,6 @@ void draw_centered_on_background(surface surf, const SDL_Rect& rect, const color
r.y = rect.y + (rect.h-surf->h)/2;
sdl_blit(surf, nullptr, target, &r);
}
update_rect(rect);
}

std::ostream& operator<<(std::ostream& s, const SDL_Rect& rect)
Expand Down
2 changes: 0 additions & 2 deletions src/show_dialog.cpp
Expand Up @@ -279,8 +279,6 @@ void dialog_frame::draw_border()
video_.blit_surface(dim_.interior.x + dim_.interior.w, dim_.interior.y, right_image);
}

update_rect(dim_.exterior);

if(top_left_ == nullptr || bot_left_ == nullptr || top_right_ == nullptr || bot_right_ == nullptr) {
return;
}
Expand Down
15 changes: 0 additions & 15 deletions src/storyscreen/render.cpp
Expand Up @@ -249,7 +249,6 @@ bool part_ui::render_floating_images()
{
floating_image::render_input& old_ri = imgs_[i];
sdl_blit(old_ri.image, nullptr, video_.getSurface(), &old_ri.rect);
update_rect(old_ri.rect);
}
}
back_button_.set_dirty();
Expand Down Expand Up @@ -339,13 +338,6 @@ void part_ui::render_title_box()

video_.blit_surface(base_rect_.x + titlebox_x, base_rect_.y + titlebox_y, txtsurf);

update_rect(
static_cast<size_t>(std::max(0, base_rect_.x + titlebox_x)),
static_cast<size_t>(std::max(0, base_rect_.y + titlebox_y)),
static_cast<size_t>(std::max(0, titlebox_w)),
static_cast<size_t>(std::max(0, titlebox_h))
);

next_button_.hide(false);
back_button_.hide(false);
play_button_.hide(false);
Expand Down Expand Up @@ -540,12 +532,6 @@ void part_ui::render_story_box()
play_button_.hide(false);
}

if (dirty_ || first) {
if(!imgs_.empty() && update_area.h > 0) {
update_rect(update_area);
}
}

// Time to do some visual effecta.
if (dirty_ || first) {
const int scan_height = 1, scan_width = txtsurf->w;
Expand All @@ -567,7 +553,6 @@ void part_ui::render_story_box()
// uses it nonetheless, no idea why...
// Here we'll use CVideo::blit_surface() instead.
video_.blit_surface(dstrect.x, dstrect.y, txtsurf, &scan);
update_rect(dstrect);
++scan.y;
}
else {
Expand Down
46 changes: 0 additions & 46 deletions src/video.cpp
Expand Up @@ -114,52 +114,6 @@ SDL_Rect screen_area()
return sdl::create_rect(0, 0, frameBuffer->w, frameBuffer->h);
}

void update_rect(size_t x, size_t y, size_t w, size_t h)
{
update_rect(sdl::create_rect(x, y, w, h));
}

void update_rect(const SDL_Rect& rect_value)
{

SDL_Rect rect = rect_value;

surface const fb = nullptr;
if(fb != nullptr) {
if(rect.x < 0) {
if(rect.x*-1 >= rect.w)
return;

rect.w += rect.x;
rect.x = 0;
}

if(rect.y < 0) {
if(rect.y*-1 >= rect.h)
return;

rect.h += rect.y;
rect.y = 0;
}

if(rect.x + rect.w > fb->w) {
rect.w = fb->w - rect.x;
}

if(rect.y + rect.h > fb->h) {
rect.h = fb->h - rect.y;
}

if(rect.x >= fb->w) {
return;
}

if(rect.y >= fb->h) {
return;
}
}
}

void CVideo::video_event_handler::handle_window_event(const SDL_Event &event)
{
if (event.type == SDL_WINDOWEVENT) {
Expand Down
4 changes: 0 additions & 4 deletions src/video.hpp
Expand Up @@ -31,10 +31,6 @@ class surface;

SDL_Rect screen_area();

//which areas of the screen will be updated when the buffer is flipped?
void update_rect(size_t x, size_t y, size_t w, size_t h);
void update_rect(const SDL_Rect& rect);

class CVideo {
public:
CVideo(const CVideo&) = delete;
Expand Down
2 changes: 0 additions & 2 deletions src/widgets/button.cpp
Expand Up @@ -389,8 +389,6 @@ void button::draw_contents()
clipArea.h -= 2*offset;
font::draw_text(&video(), clipArea, font_size, button_color, label_text_, textx, texty);
}

update_rect(loc);
}

bool button::hit(int x, int y) const
Expand Down

0 comments on commit bf86912

Please sign in to comment.