mirror of
https://github.com/thorvg/thorvg.git
synced 2025-07-28 17:15:57 +00:00
common canvas: fix non-updated paints.
When shapes are poped from canvas while retaining shapes instances, they have no chances to redraw after pushed again due to missing flag. This patch fixes it by forcely updating flag on pushing time. @Issues: 181
This commit is contained in:
parent
9e8410b9bd
commit
e9939dec82
4 changed files with 15 additions and 11 deletions
|
@ -63,7 +63,7 @@ Result Canvas::draw() noexcept
|
|||
|
||||
Result Canvas::update(Paint* paint) noexcept
|
||||
{
|
||||
return pImpl->update(paint);
|
||||
return pImpl->update(paint, false);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
struct Canvas::Impl
|
||||
{
|
||||
Array<Paint*> paints;
|
||||
RenderMethod* renderer;
|
||||
RenderMethod* renderer;
|
||||
|
||||
Impl(RenderMethod* pRenderer):renderer(pRenderer)
|
||||
{
|
||||
|
@ -49,7 +49,7 @@ struct Canvas::Impl
|
|||
if (!p) return Result::MemoryCorruption;
|
||||
paints.push(p);
|
||||
|
||||
return update(p);
|
||||
return update(p, true);
|
||||
}
|
||||
|
||||
Result clear(bool free)
|
||||
|
@ -72,19 +72,20 @@ struct Canvas::Impl
|
|||
return Result::Success;
|
||||
}
|
||||
|
||||
Result update(Paint* paint)
|
||||
Result update(Paint* paint, bool force)
|
||||
{
|
||||
if (!renderer) return Result::InsufficientCondition;
|
||||
|
||||
Array<RenderData> clips;
|
||||
auto flag = force ? RenderUpdateFlag::All : RenderUpdateFlag::None;
|
||||
|
||||
//Update single paint node
|
||||
if (paint) {
|
||||
paint->pImpl->update(*renderer, nullptr, 255, clips, RenderUpdateFlag::None);
|
||||
paint->pImpl->update(*renderer, nullptr, 255, clips, flag);
|
||||
//Update all retained paint nodes
|
||||
} else {
|
||||
for (auto paint = paints.data; paint < (paints.data + paints.count); ++paint) {
|
||||
(*paint)->pImpl->update(*renderer, nullptr, 255, clips, RenderUpdateFlag::None);
|
||||
(*paint)->pImpl->update(*renderer, nullptr, 255, clips, flag);
|
||||
}
|
||||
}
|
||||
return Result::Success;
|
||||
|
|
|
@ -49,13 +49,14 @@ struct Picture::Impl
|
|||
if (paint) {
|
||||
paint->pImpl->dispose(renderer);
|
||||
delete(paint);
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (pixels) {
|
||||
return renderer.dispose(rdata);
|
||||
auto ret = renderer.dispose(rdata);
|
||||
rdata = nullptr;
|
||||
return ret;
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void resize()
|
||||
|
|
|
@ -215,7 +215,9 @@ struct Shape::Impl
|
|||
|
||||
bool dispose(RenderMethod& renderer)
|
||||
{
|
||||
return renderer.dispose(rdata);
|
||||
auto ret = renderer.dispose(rdata);
|
||||
rdata = nullptr;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool render(RenderMethod& renderer)
|
||||
|
|
Loading…
Add table
Reference in a new issue