From 0cf9f4bcd0697264f887fde7ce7117715e728b36 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 3 May 2018 20:06:20 +0200 Subject: Remove gif file data if gif fails to load --- src/Gif.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/Gif.cpp') diff --git a/src/Gif.cpp b/src/Gif.cpp index 4d1295c..6b38f10 100644 --- a/src/Gif.cpp +++ b/src/Gif.cpp @@ -135,9 +135,11 @@ namespace dchat void Gif::draw(sf::RenderTarget &target) { double timeElapsedMilli = (double)frameTimer.getElapsedTime().asMilliseconds(); - // If gif is not redrawn for a while, then we want to reset it; otherwise the decoding loop will take too long time. - // This means that if gif is not visible for a while and then it becomes visible, the gif will reset instead of trying to process several seconds of frames - if(timeElapsedMilli > 3000.0) + // If gif is not redrawn for a while, then we reset timer (gif is paused). This happens when gif is not visible and then appears visible + // (because it's visible in window). The reason this is done is to prevent too much time between rendering gif frames, as processing a gif + // requires to process all frames between two points in time, if elapsed frame time is too high, then we would require to process several + // frames of gif in one application render frame. + if(timeElapsedMilli > 1000.0) timeElapsedMilli = 0.0; double frameDeltaCs = timeElapsedMilli * 0.1; // Centisecond frameTimer.restart(); -- cgit v1.2.3