mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-01 18:11:30 +00:00
draw: Rename set_clip to override_clip to make usage clear
Also fixed a couple incorrect usages.
This commit is contained in:
parent
5c3d959ae0
commit
a7d1e8e03c
@ -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 <region>.
|
||||
|
||||
// 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_) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
10
src/draw.hpp
10
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);
|
||||
|
||||
|
@ -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()) {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user