diff --git a/src/display.cpp b/src/display.cpp index 963671743be..207a26df0db 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -790,7 +790,7 @@ surface display::screenshot(bool map_screenshot) << " texture for map screenshot" << std::endl; texture output_texture(area.w, area.h, SDL_TEXTUREACCESS_TARGET); auto target_setter = draw::set_render_target(output_texture); - auto clipper = draw::set_clip(area); + auto clipper = draw::override_clip(area); map_screenshot_ = true; @@ -1264,7 +1264,7 @@ void display::drawing_buffer_commit() // std::list::sort() is a stable sort drawing_buffer_.sort(); - auto clipper = draw::set_clip(map_area()); + auto clipper = draw::reduce_clip(map_area()); /* * Info regarding the rendering algorithm. @@ -2566,19 +2566,18 @@ void display::render() bool display::expose(const SDL_Rect& region) { - if (region == sdl::empty_rect) { return false; } // TODO temp - //DBG_DP << "display::expose " << region << endl; - //invalidate_locations_in_rect(region); + // Note: clipping region is set by draw_manager, + // and will be contained by . + + // Blit from the pre-rendered front buffer. // TODO: draw_manager - API to get src region in output space rect src_region = region; src_region *= video().get_pixel_scale(); //DBG_DP << " src region " << src_region << endl; - //draw::blit(front_, region); draw::blit(front_, region, src_region); - //draw(); + + // Render halos. // TODO: draw_manager - halo render region not rely on clip? - // TODO: draw_manager - can we rely on clip already being set? - auto clipper = draw::set_clip(region); halo_man_.render(); // These all check for clip region overlap before drawing @@ -2679,7 +2678,7 @@ rect display::get_clip_rect() const void display::draw_invalidated() { // log_scope("display::draw_invalidated"); SDL_Rect clip_rect = get_clip_rect(); - auto clipper = draw::set_clip(clip_rect); + auto clipper = draw::reduce_clip(clip_rect); DBG_DP << "drawing " << invalidated_.size() << " invalidated hexes" << " with clip " << clip_rect << endl; for (const map_location& loc : invalidated_) { diff --git a/src/draw.cpp b/src/draw.cpp index 76a015ddad1..bea44dbe713 100644 --- a/src/draw.cpp +++ b/src/draw.cpp @@ -473,7 +473,7 @@ draw::clip_setter::~clip_setter() } } -draw::clip_setter draw::set_clip(const SDL_Rect& clip) +draw::clip_setter draw::override_clip(const SDL_Rect& clip) { return draw::clip_setter(clip); } diff --git a/src/draw.hpp b/src/draw.hpp index baefbe55b64..3d075e272cc 100644 --- a/src/draw.hpp +++ b/src/draw.hpp @@ -296,8 +296,8 @@ void tiled_highres(const texture& tex, /** A class to manage automatic restoration of the clipping region. * * This can be constructed on its own, or one of the utility functions - * set_clip() and reduce_clip() can be used. Constructing a clip_setter - * or using set_clip() will completely override the current clipping area. + * override_clip() and reduce_clip() can be used. Constructing a clip_setter + * or using override_clip() will completely override the current clipping area. * To intersect with the current clipping area in stead, use reduce_clip(). */ class clip_setter @@ -311,7 +311,7 @@ private: }; /** - * Set the clipping area. All draw calls will be clipped to this region. + * Override the clipping area. All draw calls will be clipped to this region. * * The clipping area is specified in draw-space coordinates. * @@ -323,13 +323,13 @@ private: * the clipping region will be restored to whatever * it was before this call. */ -clip_setter set_clip(const SDL_Rect& clip); +clip_setter override_clip(const SDL_Rect& clip); /** * Set the clipping area to the intersection of the current clipping * area and the given rectangle. * - * Otherwise acts as set_clip(). + * Otherwise acts as override_clip(). */ clip_setter reduce_clip(const SDL_Rect& clip); diff --git a/src/draw_manager.cpp b/src/draw_manager.cpp index 631f1cacd56..380681d56da 100644 --- a/src/draw_manager.cpp +++ b/src/draw_manager.cpp @@ -204,7 +204,7 @@ next: } DBG_DM << "drawing " << r << endl; //PLAIN_LOG << "+"; - auto clipper = draw::set_clip(r); + auto clipper = draw::override_clip(r); for (auto tld : top_level_drawables_) { rect i = r.intersect(tld->screen_location()); if (i.empty()) { diff --git a/src/widgets/menu_style.cpp b/src/widgets/menu_style.cpp index 8e889a2a7d5..3e796375ef5 100644 --- a/src/widgets/menu_style.cpp +++ b/src/widgets/menu_style.cpp @@ -153,7 +153,7 @@ void menu::imgsel_style::draw_row(menu& menu_ref, const std::size_t row_index, c // draw border texture image; SDL_Rect area; - auto clipper = draw::set_clip(rect); + auto clipper = draw::reduce_clip(rect); area.x = rect.x; area.y = rect.y; diff --git a/src/widgets/textbox.cpp b/src/widgets/textbox.cpp index a8d7d9bdb21..f7c0e2f7250 100644 --- a/src/widgets/textbox.cpp +++ b/src/widgets/textbox.cpp @@ -209,7 +209,7 @@ void textbox::draw_contents() const int endx = char_x_[end]; const int endy = char_y_[end]; - auto clipper = draw::set_clip(loc); + auto clipper = draw::reduce_clip(loc); while(starty <= endy) { const std::size_t right = starty == endy ? endx : text_image_.w();