diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-05-03 20:06:20 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2018-05-03 20:06:24 +0200 |
commit | 0cf9f4bcd0697264f887fde7ce7117715e728b36 (patch) | |
tree | 38bda56e5cb59cca51cd6a8d1a6b1ee89d924761 /src/Gif.cpp | |
parent | ccb89261bd51e448124c462f289d43afcd9006de (diff) |
Remove gif file data if gif fails to load
Diffstat (limited to 'src/Gif.cpp')
-rw-r--r-- | src/Gif.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
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(); |