mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-01-31 16:25:51 +00:00
lottieplayer: merge setPos() with renderList()
renderList() build render tree based on current Position. merge both api helps user to avoid mistake. Change-Id: Ia158f28b5ab66ec6e20665726a21d7f1c4e4cc13
This commit is contained in:
committed by
Subhransu Mohanty
parent
a36f340a0b
commit
adddac6180
@@ -162,8 +162,7 @@ void LottieView::seek(float pos)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mPlayer->setPos(pos);
|
||||
const std::vector<LOTNode *> &renderList = mPlayer->renderList();
|
||||
const std::vector<LOTNode *> &renderList = mPlayer->renderList(pos);
|
||||
update(renderList);
|
||||
}
|
||||
}
|
||||
@@ -186,8 +185,7 @@ void LottieView::render()
|
||||
}
|
||||
mBuffer.buffer = nullptr;
|
||||
} else {
|
||||
mPlayer->setPos(mPendingPos);
|
||||
const std::vector<LOTNode *> &renderList = mPlayer->renderList();
|
||||
const std::vector<LOTNode *> &renderList = mPlayer->renderList(mPendingPos);
|
||||
update(renderList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,10 +46,9 @@ public:
|
||||
|
||||
float playTime() const;
|
||||
|
||||
void setPos(float pos);
|
||||
float pos();
|
||||
|
||||
const std::vector<LOTNode *> &renderList() const;
|
||||
const std::vector<LOTNode *> &renderList(float pos) const;
|
||||
|
||||
// TODO: Consider correct position...
|
||||
void setSize(int width, int height);
|
||||
|
||||
@@ -7,15 +7,18 @@
|
||||
#include <fstream>
|
||||
|
||||
class LOTPlayerPrivate {
|
||||
|
||||
private:
|
||||
bool setPos(float pos);
|
||||
|
||||
public:
|
||||
LOTPlayerPrivate();
|
||||
bool setFilePath(std::string path);
|
||||
void setSize(const VSize &sz);
|
||||
VSize size() const;
|
||||
float playTime() const;
|
||||
bool setPos(float pos);
|
||||
float pos();
|
||||
const std::vector<LOTNode *> &renderList() const;
|
||||
const std::vector<LOTNode *> &renderList(float pos);
|
||||
bool render(float pos, const LOTBuffer &buffer);
|
||||
|
||||
public:
|
||||
@@ -48,13 +51,13 @@ VSize LOTPlayerPrivate::size() const
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<LOTNode *> &LOTPlayerPrivate::renderList() const
|
||||
const std::vector<LOTNode *> &LOTPlayerPrivate::renderList(float pos)
|
||||
{
|
||||
if (!mCompItem) {
|
||||
static std::vector<LOTNode *> empty;
|
||||
return empty;
|
||||
}
|
||||
|
||||
this->setPos(pos);
|
||||
return mCompItem->renderList();
|
||||
}
|
||||
|
||||
@@ -66,7 +69,10 @@ float LOTPlayerPrivate::playTime() const
|
||||
|
||||
bool LOTPlayerPrivate::setPos(float pos)
|
||||
{
|
||||
if (!mModel || !mCompItem) return false;
|
||||
if (!mModel || !mCompItem) {
|
||||
vWarning << "Invalid data, mModel(?), mCompItem(?)";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pos > 1.0) pos = 1.0;
|
||||
if (pos < 0) pos = 0;
|
||||
@@ -244,19 +250,14 @@ float LOTPlayer::playTime() const
|
||||
return d->playTime();
|
||||
}
|
||||
|
||||
void LOTPlayer::setPos(float pos)
|
||||
{
|
||||
d->setPos(pos);
|
||||
}
|
||||
|
||||
float LOTPlayer::pos()
|
||||
{
|
||||
return d->pos();
|
||||
}
|
||||
|
||||
const std::vector<LOTNode *> &LOTPlayer::renderList() const
|
||||
const std::vector<LOTNode *> &LOTPlayer::renderList(float pos) const
|
||||
{
|
||||
return d->renderList();
|
||||
return d->renderList(pos);
|
||||
}
|
||||
|
||||
std::future<bool> LOTPlayer::render(float pos, LOTBuffer buffer)
|
||||
|
||||
Reference in New Issue
Block a user