mirror of https://github.com/procxx/kepka.git
Fix stickers lagging on macOS.
This commit is contained in:
parent
ab16c88473
commit
ff0ff1d99c
|
@ -598,3 +598,11 @@ void Sandbox::execExternal(const QString &cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|
||||||
|
namespace crl {
|
||||||
|
|
||||||
|
rpl::producer<> on_main_update_requests() {
|
||||||
|
return Core::Sandbox::Instance().widgetUpdateRequests();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace crl
|
||||||
|
|
|
@ -85,7 +85,7 @@ std::unique_ptr<Animation> FromData(const QByteArray &data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Animation::Animation(QByteArray &&content)
|
Animation::Animation(QByteArray &&content)
|
||||||
: _timer([=] { checkNextFrame(); }) {
|
: _timer([=] { checkNextFrameRender(); }) {
|
||||||
const auto weak = base::make_weak(this);
|
const auto weak = base::make_weak(this);
|
||||||
crl::async([=, content = base::take(content)]() mutable {
|
crl::async([=, content = base::take(content)]() mutable {
|
||||||
content = UnpackGzip(content);
|
content = UnpackGzip(content);
|
||||||
|
@ -130,13 +130,18 @@ void Animation::parseDone(std::unique_ptr<SharedState> state) {
|
||||||
|| information.framesCount <= 0
|
|| information.framesCount <= 0
|
||||||
|| information.size.isEmpty()) {
|
|| information.size.isEmpty()) {
|
||||||
_updates.fire_error(Error::NotSupported);
|
_updates.fire_error(Error::NotSupported);
|
||||||
} else {
|
return;
|
||||||
_state = state.get();
|
|
||||||
_state->start(this, crl::now());
|
|
||||||
_renderer = FrameRenderer::Instance();
|
|
||||||
_renderer->append(std::move(state));
|
|
||||||
_updates.fire({ std::move(information) });
|
|
||||||
}
|
}
|
||||||
|
_state = state.get();
|
||||||
|
_state->start(this, crl::now());
|
||||||
|
_renderer = FrameRenderer::Instance();
|
||||||
|
_renderer->append(std::move(state));
|
||||||
|
_updates.fire({ std::move(information) });
|
||||||
|
|
||||||
|
crl::on_main_update_requests(
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
checkStep();
|
||||||
|
}, _lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animation::parseFailed() {
|
void Animation::parseFailed() {
|
||||||
|
@ -181,20 +186,35 @@ crl::time Animation::markFrameShown() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animation::checkNextFrame() {
|
void Animation::checkStep() {
|
||||||
|
if (_nextFrameTime != kTimeUnknown) {
|
||||||
|
checkNextFrameRender();
|
||||||
|
} else {
|
||||||
|
checkNextFrameAvailability();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Animation::checkNextFrameAvailability() {
|
||||||
Expects(_renderer != nullptr);
|
Expects(_renderer != nullptr);
|
||||||
|
|
||||||
const auto time = _state->nextFrameDisplayTime();
|
_nextFrameTime = _state->nextFrameDisplayTime();
|
||||||
if (time == kTimeUnknown) {
|
if (_nextFrameTime != kTimeUnknown) {
|
||||||
return;
|
checkStep();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Animation::checkNextFrameRender() {
|
||||||
|
Expects(_nextFrameTime != kTimeUnknown);
|
||||||
|
|
||||||
const auto now = crl::now();
|
const auto now = crl::now();
|
||||||
if (time > now) {
|
if (now < _nextFrameTime) {
|
||||||
_timer.callOnce(time - now);
|
if (!_timer.isActive()) {
|
||||||
|
_timer.callOnce(_nextFrameTime - now);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
_timer.cancel();
|
_timer.cancel();
|
||||||
|
|
||||||
|
_nextFrameTime = kTimeUnknown;
|
||||||
const auto position = markFrameDisplayed(now);
|
const auto position = markFrameDisplayed(now);
|
||||||
_updates.fire({ DisplayFrameRequest{ position } });
|
_updates.fire({ DisplayFrameRequest{ position } });
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,16 +50,20 @@ public:
|
||||||
crl::time markFrameDisplayed(crl::time now);
|
crl::time markFrameDisplayed(crl::time now);
|
||||||
crl::time markFrameShown();
|
crl::time markFrameShown();
|
||||||
|
|
||||||
void checkNextFrame();
|
void checkStep();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void parseDone(std::unique_ptr<SharedState> state);
|
void parseDone(std::unique_ptr<SharedState> state);
|
||||||
void parseFailed();
|
void parseFailed();
|
||||||
|
|
||||||
|
void checkNextFrameAvailability();
|
||||||
|
void checkNextFrameRender();
|
||||||
|
|
||||||
//crl::time _started = 0;
|
//crl::time _started = 0;
|
||||||
//PlaybackOptions _options;
|
//PlaybackOptions _options;
|
||||||
|
|
||||||
base::Timer _timer;
|
base::Timer _timer;
|
||||||
|
crl::time _nextFrameTime = kTimeUnknown;
|
||||||
SharedState *_state = nullptr;
|
SharedState *_state = nullptr;
|
||||||
std::shared_ptr<FrameRenderer> _renderer;
|
std::shared_ptr<FrameRenderer> _renderer;
|
||||||
rpl::event_stream<Update, Error> _updates;
|
rpl::event_stream<Update, Error> _updates;
|
||||||
|
|
|
@ -16,6 +16,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
namespace Lottie {
|
namespace Lottie {
|
||||||
|
|
||||||
|
constexpr auto kTimeUnknown = std::numeric_limits<crl::time>::min();
|
||||||
|
|
||||||
class Animation;
|
class Animation;
|
||||||
|
|
||||||
struct PlaybackOptions {
|
struct PlaybackOptions {
|
||||||
|
|
|
@ -279,7 +279,7 @@ bool SharedState::renderNextFrame(const FrameRequest &request) {
|
||||||
(counter + 1) % (2 * kFramesCount),
|
(counter + 1) % (2 * kFramesCount),
|
||||||
std::memory_order_release);
|
std::memory_order_release);
|
||||||
crl::on_main(_owner, [=] {
|
crl::on_main(_owner, [=] {
|
||||||
_owner->checkNextFrame();
|
_owner->checkStep();
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
@ -340,6 +340,10 @@ crl::time SharedState::nextFrameDisplayTime() const {
|
||||||
const auto next = (counter + 1) % (2 * kFramesCount);
|
const auto next = (counter + 1) % (2 * kFramesCount);
|
||||||
const auto index = next / 2;
|
const auto index = next / 2;
|
||||||
const auto frame = getFrame(index);
|
const auto frame = getFrame(index);
|
||||||
|
if (frame->displayed != kTimeUnknown) {
|
||||||
|
// Frame already displayed, but not yet shown.
|
||||||
|
return kTimeUnknown;
|
||||||
|
}
|
||||||
Assert(IsRendered(frame));
|
Assert(IsRendered(frame));
|
||||||
Assert(frame->display != kTimeUnknown);
|
Assert(frame->display != kTimeUnknown);
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,6 @@ class QImage;
|
||||||
|
|
||||||
namespace Lottie {
|
namespace Lottie {
|
||||||
|
|
||||||
constexpr auto kTimeUnknown = std::numeric_limits<crl::time>::min();
|
|
||||||
|
|
||||||
class Animation;
|
class Animation;
|
||||||
class JsonObject;
|
class JsonObject;
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "media/streaming/media_streaming_video_track.h"
|
#include "media/streaming/media_streaming_video_track.h"
|
||||||
#include "media/audio/media_audio.h" // for SupportsSpeedControl()
|
#include "media/audio/media_audio.h" // for SupportsSpeedControl()
|
||||||
#include "data/data_document.h" // for DocumentData::duration()
|
#include "data/data_document.h" // for DocumentData::duration()
|
||||||
#include "core/sandbox.h" // for widgetUpdateRequests() producer
|
|
||||||
|
|
||||||
namespace Media {
|
namespace Media {
|
||||||
namespace Streaming {
|
namespace Streaming {
|
||||||
|
@ -658,7 +657,7 @@ void Player::start() {
|
||||||
}
|
}
|
||||||
}, _sessionLifetime);
|
}, _sessionLifetime);
|
||||||
|
|
||||||
Core::Sandbox::Instance().widgetUpdateRequests(
|
crl::on_main_update_requests(
|
||||||
) | rpl::filter([=] {
|
) | rpl::filter([=] {
|
||||||
return !_videoFinished;
|
return !_videoFinished;
|
||||||
}) | rpl::start_with_next([=] {
|
}) | rpl::start_with_next([=] {
|
||||||
|
|
|
@ -8,7 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/effects/animations.h"
|
#include "ui/effects/animations.h"
|
||||||
|
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "core/sandbox.h"
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
namespace Animations {
|
namespace Animations {
|
||||||
|
@ -52,7 +51,7 @@ void Basic::markStopped() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Manager::Manager() {
|
Manager::Manager() {
|
||||||
Core::Sandbox::Instance().widgetUpdateRequests(
|
crl::on_main_update_requests(
|
||||||
) | rpl::filter([=] {
|
) | rpl::filter([=] {
|
||||||
return (_lastUpdateTime + kIgnoreUpdatesTimeout < crl::now());
|
return (_lastUpdateTime + kIgnoreUpdatesTimeout < crl::now());
|
||||||
}) | rpl::start_with_next([=] {
|
}) | rpl::start_with_next([=] {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 84072fba75f14620935e5e91788ce603daeb1988
|
Subproject commit d259aebc11df52cb6ff8c738580dc4d8f245d681
|
Loading…
Reference in New Issue