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:
Hermet Park
2018-08-13 19:29:38 +09:00
committed by Subhransu Mohanty
parent a36f340a0b
commit adddac6180
3 changed files with 16 additions and 18 deletions

View File

@@ -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);
}
}

View File

@@ -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);

View File

@@ -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)