Use fill_rectangle over fill_rect when possible

The rectangle drawing primitives are most suitable for drawing to the full screen with global rects,
not specific surfaces. The rect issue *could* be solvable, but the bigger issue is if the surface needs
further processing the rectangle won't be present.
This commit is contained in:
Charles Dang 2017-05-26 16:11:14 +11:00
parent a221d40abf
commit 4b95691660
3 changed files with 6 additions and 7 deletions

View file

@ -1862,8 +1862,8 @@ void display::draw_minimap_units()
, round_double(u_w)
, round_double(u_h)
};
const Uint32 mapped_col = SDL_MapRGB(video().getSurface()->format,col.r,col.g,col.b);
sdl::fill_rect(video().getSurface(), &r, mapped_col);
sdl::fill_rectangle(r, col);
}
}

View file

@ -168,7 +168,7 @@ void textbox::set_cursor_pos(const int cursor_pos)
set_dirty(true);
}
void textbox::draw_cursor(int pos, CVideo &video) const
void textbox::draw_cursor(int pos) const
{
if(show_cursor_ && editable_ && enabled()) {
SDL_Rect rect {
@ -178,8 +178,7 @@ void textbox::draw_cursor(int pos, CVideo &video) const
, location().h
};
surface frame_buffer = video.getSurface();
sdl::fill_rect(frame_buffer,&rect,SDL_MapRGB(frame_buffer->format,255,255,255));
sdl::fill_rectangle(rect, {255, 255, 255, 255});
}
}
@ -253,7 +252,7 @@ void textbox::draw_contents()
}
}
draw_cursor((cursor_pos_ == 0 ? 0 : cursor_pos_ - 1), video());
draw_cursor(cursor_pos_ == 0 ? 0 : cursor_pos_ - 1);
}
void textbox::set_editable(bool value)

View file

@ -104,7 +104,7 @@ private:
void pass_event_to_target(const SDL_Event& event);
void draw_cursor(int pos, CVideo &video) const;
void draw_cursor(int pos) const;
void update_text_cache(bool reset = false, const color_t& color =font::NORMAL_COLOR);
surface add_text_line(const ucs4::string& text, const color_t& color =font::NORMAL_COLOR);
bool is_selection();