widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #05444
[Merge] lp:~widelands-dev/widelands/memory_leak into lp:widelands
SirVer has proposed merging lp:~widelands-dev/widelands/memory_leak into lp:widelands.
Commit message:
Fix memory leak and extra work in UI::Table::draw.
On each frame we created a downscaled texture if the image of a table entry was too small and leaked this texture immediately. This extra scaling work we did there was even unnecessary since OpenGL can scale down images while blitting for free.
Deleted that rescaling code, which makes the texture creation unnecessary, gets rid of the memory leak and also buys CPU cycles since a lot of work is now never done.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1535569 in widelands: "Messages window slows down game speed"
https://bugs.launchpad.net/widelands/+bug/1535569
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/memory_leak/+merge/283690
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/memory_leak into lp:widelands.
=== modified file 'src/ui_basic/table.cc'
--- src/ui_basic/table.cc 2016-01-11 15:18:51 +0000
+++ src/ui_basic/table.cc 2016-01-22 20:09:24 +0000
@@ -283,7 +283,7 @@
Columns::size_type const nr_columns = m_columns.size();
for (uint32_t i = 0, curx = 0; i < nr_columns; ++i) {
const Column& column = m_columns[i];
- int const curw = column.width;
+ int const curw = column.width;
Align alignment = mirror_alignment(column.alignment);
const Image* entry_picture = er.get_picture(i);
@@ -291,11 +291,10 @@
Point point(curx, y);
int picw = 0;
- int pich = 0;
- if (entry_picture) {
+ if (entry_picture != nullptr) {
picw = entry_picture->width();
- pich = entry_picture->height();
+ const int pich = entry_picture->height();
int draw_x = point.x;
@@ -319,22 +318,9 @@
draw_x += curw - blit_width;
}
- // Temporary texture for the scaled image
- Texture* scaled_texture = new Texture(blit_width, max_pic_height);
-
- // Initialize the rectangle
- scaled_texture->fill_rect(Rect(0, 0, blit_width, max_pic_height),
- RGBAColor(255, 255, 255, 0));
-
// Create the scaled image
- scaled_texture->blit(Rect(0, 0, blit_width, max_pic_height),
- *entry_picture,
- Rect(0, 0, picw, pich),
- 1.,
- BlendMode::UseAlpha);
-
- // This will now blit with any appropriate cropping
- dst.blit(Point(draw_x, point.y + 1), scaled_texture);
+ dst.blitrect_scale(Rect(draw_x, point.y + 1, blit_width, max_pic_height),
+ entry_picture, Rect(0, 0, picw, pich), 1., BlendMode::UseAlpha);
// For text alignment below
picw = blit_width;
Follow ups
-
Re: [Merge] lp:~widelands-dev/widelands/memory_leak into lp:widelands
From: kaputtnik, 2016-01-24
-
[Merge] lp:~widelands-dev/widelands/memory_leak into lp:widelands
From: noreply, 2016-01-24
-
Re: [Merge] lp:~widelands-dev/widelands/memory_leak into lp:widelands
From: SirVer, 2016-01-24
-
Re: [Merge] lp:~widelands-dev/widelands/memory_leak into lp:widelands
From: kaputtnik, 2016-01-24
-
Re: [Merge] lp:~widelands-dev/widelands/memory_leak into lp:widelands
From: GunChleoc, 2016-01-24
-
Bunnybot says...
From: bunnybot, 2016-01-23
-
Re: [Merge] lp:~widelands-dev/widelands/memory_leak into lp:widelands
From: Tino, 2016-01-23
-
Re: [Merge] lp:~widelands-dev/widelands/memory_leak into lp:widelands
From: kaputtnik, 2016-01-23
-
Re: [Merge] lp:~widelands-dev/widelands/memory_leak into lp:widelands
From: SirVer, 2016-01-23
-
[Merge] lp:~widelands-dev/widelands/memory_leak into lp:widelands
From: SirVer, 2016-01-23
-
Re: [Merge] lp:~widelands-dev/widelands/memory_leak into lp:widelands
From: kaputtnik, 2016-01-23
-
Re: [Merge] lp:~widelands-dev/widelands/memory_leak into lp:widelands
From: GunChleoc, 2016-01-23
-
Re: [Merge] lp:~widelands-dev/widelands/memory_leak into lp:widelands
From: kaputtnik, 2016-01-23
-
Bunnybot says...
From: bunnybot, 2016-01-23
-
Re: [Merge] lp:~widelands-dev/widelands/memory_leak into lp:widelands
From: SirVer, 2016-01-23
-
Bunnybot says...
From: bunnybot, 2016-01-23
-
[Merge] lp:~widelands-dev/widelands/memory_leak into lp:widelands
From: SirVer, 2016-01-22
-
[Merge] lp:~widelands-dev/widelands/memory_leak into lp:widelands
From: SirVer, 2016-01-22
-
Re: [Merge] lp:~widelands-dev/widelands/memory_leak into lp:widelands
From: GunChleoc, 2016-01-22
-
Bunnybot says...
From: bunnybot, 2016-01-22