summaryrefslogtreecommitdiff
path: root/src/search/Thumbnail.cpp
diff options
context:
space:
mode:
authorSimon 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)
commit838a612026c821c03e663c818d4bc9fe740febd8 (patch)
tree4b467bec3336452d8f65793b1cee31f0ffb05d2e /src/search/Thumbnail.cpp
parent73c5082cbcdd3a986765723bd4182e45386ce766 (diff)
downloadpowder-838a612026c821c03e663c818d4bc9fe740febd8.zip
powder-838a612026c821c03e663c818d4bc9fe740febd8.tar.gz
Use a single instance of a background simulation for thumbnail rendering
Diffstat (limited to 'src/search/Thumbnail.cpp')
-rw-r--r--src/search/Thumbnail.cpp44
1 files changed, 7 insertions, 37 deletions
diff --git a/src/search/Thumbnail.cpp b/src/search/Thumbnail.cpp
index 2fcd34a..6a97a08 100644
--- a/src/search/Thumbnail.cpp
+++ b/src/search/Thumbnail.cpp
@@ -6,9 +6,6 @@
*/
#include "Thumbnail.h"
-#include "simulation/Simulation.h"
-#include "simulation/SaveLoader.h"
-#include "Renderer.h"
Thumbnail::Thumbnail(const Thumbnail & thumb):
ID(thumb.ID),
@@ -34,42 +31,15 @@ Thumbnail::Thumbnail(int _id, int _datestamp, pixel * _data, ui::Point _size):
Data(_data),
Size(_size)
{
-}
-
-Thumbnail::Thumbnail(Save * save):
- ID(0),
- Datestamp(0),
- Data(NULL),
- Size(XRES+BARSIZE, YRES+MENUSIZE)
-{
- Graphics * g = new Graphics();
- Simulation * sim = new Simulation();
- Renderer * ren = new Renderer(g, sim);
- sim->Load(save->GetData(), save->GetDataLength());
- ren->render_parts();
-
- int width, height;
-
- pixel * dst;
- pixel * src = g->vid;
-
- if(SaveLoader::Info(save->GetData(), save->GetDataLength(), width, height))
- goto fail;
-
- dst = Data = (pixel *)malloc(PIXELSIZE * ((width*CELL)*(height*CELL)));
-
- for(int i = 0; i < height*CELL; i++)
+ if(_data)
{
- memcpy(dst, src, (width*CELL)*PIXELSIZE);
- dst+=(width*CELL);///PIXELSIZE;
- src+=XRES+BARSIZE;
+ Data = (pixel *)malloc((_size.X*_size.Y) * PIXELSIZE);
+ memcpy(Data, _data, (_size.X*_size.Y) * PIXELSIZE);
+ }
+ else
+ {
+ Data = NULL;
}
-
- Size = ui::Point(width*CELL, height*CELL);
-fail:
- delete ren;
- delete sim;
- delete g;
}
Thumbnail::~Thumbnail()