diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-05-03 13:25:07 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2018-05-03 13:25:12 +0200 |
commit | fcaea3d937a16a8d975989710f14320629c951d4 (patch) | |
tree | 54b0bcfdfe56834038c8fb69b3a329555f3803b9 | |
parent | c2841e19c227f9c0f7cef3023e012c5c80f6def4 (diff) |
Optimize gif rendering
-rw-r--r-- | src/Gif.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Gif.cpp b/src/Gif.cpp index 5b83158..f87b0ab 100644 --- a/src/Gif.cpp +++ b/src/Gif.cpp @@ -134,7 +134,12 @@ namespace dchat void Gif::draw(sf::RenderTarget &target) { - double frameDeltaCs = (double)frameTimer.getElapsedTime().asMilliseconds() * 0.1; // Centisecond + 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) + timeElapsedMilli = 0; + double frameDeltaCs = timeElapsedMilli * 0.1; // Centisecond frameTimer.restart(); timeElapsedCs += frameDeltaCs; |