mirror of https://github.com/procxx/kepka.git
Correctly start lottie animations.
This commit is contained in:
parent
4bd0683e91
commit
f19ff1f9b2
|
@ -47,7 +47,9 @@ public:
|
|||
explicit FrameRendererObject(
|
||||
crl::weak_on_queue<FrameRendererObject> weak);
|
||||
|
||||
void append(std::unique_ptr<SharedState> entry);
|
||||
void append(
|
||||
std::unique_ptr<SharedState> entry,
|
||||
const FrameRequest &request);
|
||||
void frameShown();
|
||||
void updateFrameRequest(
|
||||
not_null<SharedState*> entry,
|
||||
|
@ -132,10 +134,10 @@ FrameRendererObject::FrameRendererObject(
|
|||
: _weak(std::move(weak)) {
|
||||
}
|
||||
|
||||
void FrameRendererObject::append(std::unique_ptr<SharedState> state) {
|
||||
_entries.push_back({ std::move(state) });
|
||||
auto &entry = _entries.back();
|
||||
entry.request = entry.state->frameForPaint()->request;
|
||||
void FrameRendererObject::append(
|
||||
std::unique_ptr<SharedState> state,
|
||||
const FrameRequest &request) {
|
||||
_entries.push_back({ std::move(state), request });
|
||||
queueGenerateFrames();
|
||||
}
|
||||
|
||||
|
@ -537,10 +539,12 @@ std::shared_ptr<FrameRenderer> FrameRenderer::Instance() {
|
|||
return result;
|
||||
}
|
||||
|
||||
void FrameRenderer::append(std::unique_ptr<SharedState> entry) {
|
||||
_wrapped.with([entry = std::move(entry)](
|
||||
void FrameRenderer::append(
|
||||
std::unique_ptr<SharedState> entry,
|
||||
const FrameRequest &request) {
|
||||
_wrapped.with([=, entry = std::move(entry)](
|
||||
FrameRendererObject &unwrapped) mutable {
|
||||
unwrapped.append(std::move(entry));
|
||||
unwrapped.append(std::move(entry), request);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,9 @@ public:
|
|||
static std::shared_ptr<FrameRenderer> CreateIndependent();
|
||||
static std::shared_ptr<FrameRenderer> Instance();
|
||||
|
||||
void append(std::unique_ptr<SharedState> entry);
|
||||
void append(
|
||||
std::unique_ptr<SharedState> entry,
|
||||
const FrameRequest &request);
|
||||
|
||||
void updateFrameRequest(
|
||||
not_null<SharedState*> entry,
|
||||
|
|
|
@ -71,8 +71,8 @@ void MultiPlayer::startAtRightTime(std::unique_ptr<SharedState> state) {
|
|||
lastSyncTime,
|
||||
_delay);
|
||||
state->start(this, _started, _delay, frameIndex);
|
||||
|
||||
_renderer->append(std::move(state));
|
||||
const auto request = state->frameForPaint()->request;
|
||||
_renderer->append(std::move(state), request);
|
||||
}
|
||||
|
||||
int MultiPlayer::countFrameIndex(
|
||||
|
@ -323,20 +323,22 @@ void MultiPlayer::checkNextFrameRender() {
|
|||
void MultiPlayer::updateFrameRequest(
|
||||
not_null<const Animation*> animation,
|
||||
const FrameRequest &request) {
|
||||
const auto state = [&] {
|
||||
const auto state = [&]() -> Lottie::SharedState* {
|
||||
const auto key = animation;
|
||||
if (const auto i = _active.find(animation); i != end(_active)) {
|
||||
return i->second.get();
|
||||
return i->second;
|
||||
} else if (const auto j = _paused.find(animation);
|
||||
j != end(_paused)) {
|
||||
return j->second.state.get();
|
||||
return j->second.state;
|
||||
} else if (const auto k = _pendingToStart.find(animation);
|
||||
k != end(_pendingToStart)) {
|
||||
return k->second.state.get();
|
||||
return nullptr;
|
||||
}
|
||||
Unexpected("Animation in MultiPlayer::updateFrameRequest.");
|
||||
}();
|
||||
_renderer->updateFrameRequest(state, request);
|
||||
if (state) {
|
||||
_renderer->updateFrameRequest(state, request);
|
||||
}
|
||||
}
|
||||
|
||||
void MultiPlayer::markFrameDisplayed(crl::time now) {
|
||||
|
|
|
@ -45,7 +45,8 @@ void SinglePlayer::start(
|
|||
_state = state.get();
|
||||
auto information = state->information();
|
||||
state->start(this, crl::now());
|
||||
_renderer->append(std::move(state));
|
||||
const auto request = state->frameForPaint()->request;
|
||||
_renderer->append(std::move(state), request);
|
||||
_updates.fire({ std::move(information) });
|
||||
|
||||
crl::on_main_update_requests(
|
||||
|
|
Loading…
Reference in New Issue