Avoid surface copying when rendering text

This was a small proposed change as part of PR #844. While that PR is rather outdated at this point, this seemed like
a simple, useful change.
This commit is contained in:
Charles Dang 2017-02-17 05:32:24 +11:00
parent 1e8d8ff7d7
commit f70f1b37e4
3 changed files with 3 additions and 3 deletions

View file

@ -100,7 +100,7 @@ pango_text::~pango_text()
surface_.assign(nullptr);
}
surface pango_text::render() const
surface& pango_text::render() const
{
this->rerender();
return surface_;

View file

@ -90,7 +90,7 @@ public:
* Before rendering it tests whether a redraw is needed and if so it first
* redraws the surface before returning it.
*/
surface render() const;
surface& render() const;
/** Returns the width needed for the text. */
int get_width() const;

View file

@ -1346,7 +1346,7 @@ void text_shape::draw(surface& canvas,
: PANGO_ELLIPSIZE_END)
.set_characters_per_line(characters_per_line_);
surface surf = text_renderer.render();
surface& surf = text_renderer.render();
if(surf->w == 0) {
DBG_GUI_D << "Text: Rendering '" << text
<< "' resulted in an empty canvas, leave.\n";