Skip to content

Commit

Permalink
Fix single-frame 60 fps lotties.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Sep 6, 2022
1 parent e66d57f commit 6ed1c22
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion lottie/details/lottie_frame_provider_direct.cpp
Expand Up @@ -22,7 +22,9 @@ int GetLottieFrameRate(not_null<rlottie::Animation*> animation, Quality quality)
int GetLottieFramesCount(not_null<rlottie::Animation*> animation, Quality quality) {
const auto rate = int(qRound(animation->frameRate()));
const auto count = int(animation->totalFrame());
return (quality == Quality::Default && rate == 60) ? (count / 2) : count;
return (quality == Quality::Default && rate == 60)
? ((count + 1) / 2)
: count;
}

int GetLottieFrameIndex(not_null<rlottie::Animation*> animation, Quality quality, int index) {
Expand Down
3 changes: 2 additions & 1 deletion lottie/lottie_frame_generator.cpp
Expand Up @@ -27,7 +27,8 @@ FrameGenerator::FrameGenerator(const QByteArray &bytes)
auto height = size_t();
_rlottie->size(width, height);
_size = QSize(width, height);
_framesCount = _rlottie->totalFrame() / _multiplier;
_framesCount = (_rlottie->totalFrame() + _multiplier - 1)
/ _multiplier;
_frameDuration = (rate > 0) ? (1000 * _multiplier / rate) : 0;
}
if (!_framesCount || !_frameDuration || _size.isEmpty()) {
Expand Down
4 changes: 2 additions & 2 deletions lottie/lottie_icon.cpp
Expand Up @@ -153,11 +153,11 @@ void Icon::Inner::prepareFromAsync(
auto width = size_t();
auto height = size_t();
rlottie->size(width, height);
_framesCount = rlottie->totalFrame();
if (_limitFps && rlottie->frameRate() == 60) {
_frameMultiplier = 2;
_framesCount /= _frameMultiplier;
}
_framesCount = (rlottie->totalFrame() + _frameMultiplier - 1)
/ _frameMultiplier;
if (!_framesCount || !width || !height) {
return;
}
Expand Down

0 comments on commit 6ed1c22

Please sign in to comment.