mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 12:04:29 +00:00
common picture: implement duplicate() method.
This commit is contained in:
parent
c1827df0a3
commit
87a0666034
3 changed files with 32 additions and 7 deletions
|
@ -77,7 +77,19 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
canvas->push(move(scene2));
|
canvas->push(move(scene2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Duplicate Picture
|
||||||
|
{
|
||||||
|
auto picture1 = tvg::Picture::gen();
|
||||||
|
picture1->load(EXAMPLE_DIR"/tiger.svg");
|
||||||
|
picture1->translate(370, 370);
|
||||||
|
picture1->scale(0.25);
|
||||||
|
|
||||||
|
auto picture2 = unique_ptr<tvg::Picture>(static_cast<tvg::Picture*>(picture1->duplicate()));
|
||||||
|
picture2->translate(550, 550);
|
||||||
|
|
||||||
|
canvas->push(move(picture1));
|
||||||
|
canvas->push(move(picture2));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -153,7 +153,7 @@ namespace tvg
|
||||||
auto ret = smethod->duplicate();
|
auto ret = smethod->duplicate();
|
||||||
|
|
||||||
//duplicate Transform
|
//duplicate Transform
|
||||||
if (rTransform) {
|
if (ret && rTransform) {
|
||||||
ret->pImpl->rTransform = new RenderTransform();
|
ret->pImpl->rTransform = new RenderTransform();
|
||||||
if (ret->pImpl->rTransform) {
|
if (ret->pImpl->rTransform) {
|
||||||
*ret->pImpl->rTransform = *rTransform;
|
*ret->pImpl->rTransform = *rTransform;
|
||||||
|
|
|
@ -43,16 +43,22 @@ struct Picture::Impl
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool update(RenderMethod &renderer, const RenderTransform* transform, RenderUpdateFlag flag)
|
void reload()
|
||||||
{
|
{
|
||||||
if (loader) {
|
if (loader && !paint) {
|
||||||
auto scene = loader->data();
|
auto scene = loader->data();
|
||||||
if (scene) {
|
if (scene) {
|
||||||
this->paint = scene.release();
|
paint = scene.release();
|
||||||
if (!this->paint) return false;
|
if (!paint) return;
|
||||||
loader->close();
|
loader->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool update(RenderMethod &renderer, const RenderTransform* transform, RenderUpdateFlag flag)
|
||||||
|
{
|
||||||
|
reload();
|
||||||
|
|
||||||
if (!paint) return false;
|
if (!paint) return false;
|
||||||
|
|
||||||
|
@ -107,8 +113,15 @@ struct Picture::Impl
|
||||||
|
|
||||||
Paint* duplicate()
|
Paint* duplicate()
|
||||||
{
|
{
|
||||||
//TODO:
|
reload();
|
||||||
return nullptr;
|
|
||||||
|
if (!paint) return nullptr;
|
||||||
|
auto ret = Picture::gen();
|
||||||
|
if (!ret) return nullptr;
|
||||||
|
auto dup = ret.get()->pImpl;
|
||||||
|
dup->paint = paint->duplicate();
|
||||||
|
|
||||||
|
return ret.release();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue