diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-04-03 16:08:56 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-04-03 16:08:56 (GMT) |
| commit | 838a612026c821c03e663c818d4bc9fe740febd8 (patch) | |
| tree | 4b467bec3336452d8f65793b1cee31f0ffb05d2e /src/client/Client.cpp | |
| parent | 73c5082cbcdd3a986765723bd4182e45386ce766 (diff) | |
| download | powder-838a612026c821c03e663c818d4bc9fe740febd8.zip powder-838a612026c821c03e663c818d4bc9fe740febd8.tar.gz | |
Use a single instance of a background simulation for thumbnail rendering
Diffstat (limited to 'src/client/Client.cpp')
| -rw-r--r-- | src/client/Client.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/client/Client.cpp b/src/client/Client.cpp index b472518..4b7ef95 100644 --- a/src/client/Client.cpp +++ b/src/client/Client.cpp @@ -530,10 +530,13 @@ Thumbnail * Client::GetPreview(int saveID, int saveDate) if(thumbData) { return new Thumbnail(saveID, saveDate, thumbData, ui::Point(imgw, imgh)); + free(thumbData); } else { - return new Thumbnail(saveID, saveDate, (pixel *)malloc((128*128) * PIXELSIZE), ui::Point(128, 128)); + thumbData = (pixel *)malloc((128*128) * PIXELSIZE); + return new Thumbnail(saveID, saveDate, thumbData, ui::Point(128, 128)); + free(thumbData); } } else @@ -747,10 +750,13 @@ Thumbnail * Client::GetThumbnail(int saveID, int saveDate) if(thumbData) { thumbnailCache[thumbnailCacheNextID] = new Thumbnail(saveID, saveDate, thumbData, ui::Point(imgw, imgh)); + free(thumbData); } else { - thumbnailCache[thumbnailCacheNextID] = new Thumbnail(saveID, saveDate, (pixel *)malloc((128*128) * PIXELSIZE), ui::Point(128, 128)); + thumbData = (pixel *)malloc((128*128) * PIXELSIZE); + thumbnailCache[thumbnailCacheNextID] = new Thumbnail(saveID, saveDate, thumbData, ui::Point(128, 128)); + free(thumbData); } return thumbnailCache[thumbnailCacheNextID++]; } @@ -765,7 +771,9 @@ Thumbnail * Client::GetThumbnail(int saveID, int saveDate) { delete thumbnailCache[thumbnailCacheNextID]; } - thumbnailCache[thumbnailCacheNextID] = new Thumbnail(saveID, saveDate, (pixel *)malloc((128*128) * PIXELSIZE), ui::Point(128, 128)); + thumbData = (pixel *)malloc((128*128) * PIXELSIZE); + thumbnailCache[thumbnailCacheNextID] = new Thumbnail(saveID, saveDate, thumbData, ui::Point(128, 128)); + free(thumbData); return thumbnailCache[thumbnailCacheNextID++]; } } |
