don't render fire on stamps (reduces lag)

This commit is contained in:
jacob1 2012-10-02 19:45:35 -04:00 committed by Simon Robertshaw
parent 63c364652d
commit 5c59b9d6cb
7 changed files with 35 additions and 28 deletions

View File

@ -28,16 +28,16 @@ ThumbnailBroker::~ThumbnailBroker()
void ThumbnailBroker::RenderThumbnail(GameSave * gameSave, int width, int height, ThumbnailListener * tListener) void ThumbnailBroker::RenderThumbnail(GameSave * gameSave, int width, int height, ThumbnailListener * tListener)
{ {
RenderThumbnail(gameSave, true, width, height, tListener); RenderThumbnail(gameSave, true, true, width, height, tListener);
} }
void ThumbnailBroker::RenderThumbnail(GameSave * gameSave, bool decorations, int width, int height, ThumbnailListener * tListener) void ThumbnailBroker::RenderThumbnail(GameSave * gameSave, bool decorations, bool fire, int width, int height, ThumbnailListener * tListener)
{ {
AttachThumbnailListener(tListener); AttachThumbnailListener(tListener);
pthread_mutex_lock(&thumbnailQueueMutex); pthread_mutex_lock(&thumbnailQueueMutex);
bool running = thumbnailQueueRunning; bool running = thumbnailQueueRunning;
thumbnailQueueRunning = true; thumbnailQueueRunning = true;
renderRequests.push_back(ThumbRenderRequest(new GameSave(*gameSave), decorations, width, height, ListenerHandle(tListener->ListenerRand, tListener))); renderRequests.push_back(ThumbRenderRequest(new GameSave(*gameSave), decorations, fire, width, height, ListenerHandle(tListener->ListenerRand, tListener)));
pthread_mutex_unlock(&thumbnailQueueMutex); pthread_mutex_unlock(&thumbnailQueueMutex);
if(!running) if(!running)
@ -122,7 +122,7 @@ void ThumbnailBroker::thumbnailQueueProcessTH()
std::cout << typeid(*this).name() << " Processing render request" << std::endl; std::cout << typeid(*this).name() << " Processing render request" << std::endl;
#endif #endif
Thumbnail * thumbnail = SaveRenderer::Ref().Render(req.Save, req.Decorations); Thumbnail * thumbnail = SaveRenderer::Ref().Render(req.Save, req.Decorations, req.Fire);
delete req.Save; delete req.Save;
if(thumbnail) if(thumbnail)

View File

@ -59,11 +59,12 @@ private:
public: public:
int Width, Height; int Width, Height;
bool Decorations; bool Decorations;
bool Fire;
GameSave * Save; GameSave * Save;
ListenerHandle CompletedListener; ListenerHandle CompletedListener;
ThumbRenderRequest(GameSave * save, bool decorations, int width, int height, ListenerHandle completedListener) : ThumbRenderRequest(GameSave * save, bool decorations, bool fire, int width, int height, ListenerHandle completedListener) :
Save(save), Width(width), Height(height), CompletedListener(completedListener), Decorations(decorations) {} Save(save), Width(width), Height(height), CompletedListener(completedListener), Decorations(decorations), Fire(fire) {}
ThumbRenderRequest() : Save(0), Decorations(true), Width(0), Height(0), CompletedListener(ListenerHandle(0, (ThumbnailListener*)NULL)) {} ThumbRenderRequest() : Save(0), Decorations(true), Fire(true), Width(0), Height(0), CompletedListener(ListenerHandle(0, (ThumbnailListener*)NULL)) {}
}; };
//Thumbnail retreival //Thumbnail retreival
@ -96,7 +97,7 @@ public:
virtual ~ThumbnailBroker(); virtual ~ThumbnailBroker();
void FlushThumbQueue(); void FlushThumbQueue();
void RenderThumbnail(GameSave * gameSave, bool decorations, int width, int height, ThumbnailListener * tListener); void RenderThumbnail(GameSave * gameSave, bool decorations, bool fire, int width, int height, ThumbnailListener * tListener);
void RenderThumbnail(GameSave * gameSave, int width, int height, ThumbnailListener * tListener); void RenderThumbnail(GameSave * gameSave, int width, int height, ThumbnailListener * tListener);
void RetrieveThumbnail(int saveID, int saveDate, int width, int height, ThumbnailListener * tListener); void RetrieveThumbnail(int saveID, int saveDate, int width, int height, ThumbnailListener * tListener);
void RetrieveThumbnail(int saveID, int width, int height, ThumbnailListener * tListener); void RetrieveThumbnail(int saveID, int width, int height, ThumbnailListener * tListener);

View File

@ -397,7 +397,7 @@ void PreviewView::NotifySaveChanged(PreviewModel * sender)
if(save->GetGameSave()) if(save->GetGameSave())
{ {
savePreview = SaveRenderer::Ref().Render(save->GetGameSave(), false); savePreview = SaveRenderer::Ref().Render(save->GetGameSave(), false, true);
if(savePreview && savePreview->Data && !(savePreview->Size.X == XRES/2 && savePreview->Size.Y == YRES/2)) if(savePreview && savePreview->Data && !(savePreview->Size.X == XRES/2 && savePreview->Size.Y == YRES/2))
{ {

View File

@ -70,7 +70,7 @@ LocalSaveActivity::LocalSaveActivity(SaveFile save) :
SetOkayButton(okayButton); SetOkayButton(okayButton);
if(save.GetGameSave()) if(save.GetGameSave())
ThumbnailBroker::Ref().RenderThumbnail(save.GetGameSave(), Size.X-16, -1, this); ThumbnailBroker::Ref().RenderThumbnail(save.GetGameSave(), true, false, Size.X-16, -1, this);
} }
void LocalSaveActivity::Save() void LocalSaveActivity::Save()

View File

@ -128,7 +128,7 @@ ServerSaveActivity::ServerSaveActivity(SaveInfo save, ServerSaveActivity::SaveUp
SetOkayButton(okayButton); SetOkayButton(okayButton);
if(save.GetGameSave()) if(save.GetGameSave())
ThumbnailBroker::Ref().RenderThumbnail(save.GetGameSave(), false, (Size.X/2)-16, -1, this); ThumbnailBroker::Ref().RenderThumbnail(save.GetGameSave(), false, true, (Size.X/2)-16, -1, this);
} }
ServerSaveActivity::ServerSaveActivity(SaveInfo save, bool saveNow, ServerSaveActivity::SaveUploadedCallback * callback) : ServerSaveActivity::ServerSaveActivity(SaveInfo save, bool saveNow, ServerSaveActivity::SaveUploadedCallback * callback) :

View File

@ -39,7 +39,7 @@ SaveRenderer::SaveRenderer(){
#endif #endif
} }
Thumbnail * SaveRenderer::Render(GameSave * save, bool decorations) Thumbnail * SaveRenderer::Render(GameSave * save, bool decorations, bool fire)
{ {
int width, height; int width, height;
Thumbnail * tempThumb; Thumbnail * tempThumb;
@ -71,13 +71,16 @@ Thumbnail * SaveRenderer::Render(GameSave * save, bool decorations)
ren->RenderBegin(); ren->RenderBegin();
ren->RenderEnd(); ren->RenderEnd();
#else #else
int frame = 15; if (fire)
while(frame)
{ {
frame--; int frame = 15;
ren->render_parts(); while(frame)
ren->render_fire(); {
ren->clearScreen(1.0f); frame--;
ren->render_parts();
ren->render_fire();
ren->clearScreen(1.0f);
}
} }
ren->RenderBegin(); ren->RenderBegin();
@ -119,13 +122,16 @@ Thumbnail * SaveRenderer::Render(GameSave * save, bool decorations)
ren->ClearAccumulation(); ren->ClearAccumulation();
int frame = 15; if (fire)
while(frame)
{ {
frame--; int frame = 15;
ren->render_parts(); while(frame)
ren->render_fire(); {
ren->clearScreen(1.0f); frame--;
ren->render_parts();
ren->render_fire();
ren->clearScreen(1.0f);
}
} }
ren->RenderBegin(); ren->RenderBegin();
@ -151,7 +157,7 @@ Thumbnail * SaveRenderer::Render(GameSave * save, bool decorations)
return tempThumb; return tempThumb;
} }
Thumbnail * SaveRenderer::Render(unsigned char * saveData, int dataSize, bool decorations) Thumbnail * SaveRenderer::Render(unsigned char * saveData, int dataSize, bool decorations, bool fire)
{ {
GameSave * tempSave; GameSave * tempSave;
try { try {
@ -166,7 +172,7 @@ Thumbnail * SaveRenderer::Render(unsigned char * saveData, int dataSize, bool de
return thumb; return thumb;
} }
Thumbnail * thumb = Render(tempSave, decorations); Thumbnail * thumb = Render(tempSave, decorations, fire);
delete tempSave; delete tempSave;
return thumb; return thumb;
} }

View File

@ -24,8 +24,8 @@ class SaveRenderer: public Singleton<SaveRenderer> {
Renderer * ren; Renderer * ren;
public: public:
SaveRenderer(); SaveRenderer();
Thumbnail * Render(GameSave * save, bool decorations = true); Thumbnail * Render(GameSave * save, bool decorations = true, bool fire = true);
Thumbnail * Render(unsigned char * saveData, int saveDataSize, bool decorations = true); Thumbnail * Render(unsigned char * saveData, int saveDataSize, bool decorations = true, bool fire = true);
virtual ~SaveRenderer(); virtual ~SaveRenderer();
private: private: