2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Pause GIFs in message history.

This commit is contained in:
John Preston
2019-12-11 17:01:11 +03:00
parent 2d7adbc68a
commit 9339db900f
10 changed files with 176 additions and 36 deletions

View File

@@ -101,7 +101,6 @@ void Player::checkNextFrameRender() {
}
} else {
_renderFrameTimer.cancel();
_nextFrameTime = kTimeUnknown;
renderFrame(now);
}
}
@@ -110,6 +109,7 @@ void Player::checkNextFrameAvailability() {
Expects(_video != nullptr);
_nextFrameTime = _video->nextFrameDisplayTime();
Assert(_nextFrameTime != kFrameDisplayTimeAlreadyDone);
if (_nextFrameTime != kTimeUnknown) {
checkNextFrameRender();
}
@@ -117,13 +117,32 @@ void Player::checkNextFrameAvailability() {
void Player::renderFrame(crl::time now) {
Expects(_video != nullptr);
Expects(_nextFrameTime != kTimeUnknown);
Expects(_nextFrameTime != kFrameDisplayTimeAlreadyDone);
const auto position = _video->markFrameDisplayed(now);
Assert(position != kTimeUnknown);
if (_options.waitForMarkAsShown) {
_currentFrameTime = _nextFrameTime;
_nextFrameTime = kFrameDisplayTimeAlreadyDone;
} else {
_video->markFrameShown();
_nextFrameTime = kTimeUnknown;
}
Assert(position != kTimeUnknown);
videoPlayedTill(position);
}
bool Player::markFrameShown() {
Expects(_video != nullptr);
if (_nextFrameTime == kFrameDisplayTimeAlreadyDone) {
_nextFrameTime = kTimeUnknown;
_video->addTimelineDelay(crl::now() - _currentFrameTime);
}
return _video->markFrameShown();
}
template <typename Track>
void Player::trackReceivedTill(
const Track &track,
@@ -690,7 +709,9 @@ void Player::start() {
}
void Player::checkVideoStep() {
if (_nextFrameTime != kTimeUnknown) {
if (_nextFrameTime == kFrameDisplayTimeAlreadyDone) {
return;
} else if (_nextFrameTime != kTimeUnknown) {
checkNextFrameRender();
} else {
checkNextFrameAvailability();