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
|
Result Canvas::update(Paint* paint) noexcept
|
||||||
{
|
{
|
||||||
return pImpl->update(paint);
|
return pImpl->update(paint, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,4 +72,4 @@ Result Canvas::sync() noexcept
|
||||||
if (pImpl->renderer->sync()) return Result::Success;
|
if (pImpl->renderer->sync()) return Result::Success;
|
||||||
|
|
||||||
return Result::InsufficientCondition;
|
return Result::InsufficientCondition;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
struct Canvas::Impl
|
struct Canvas::Impl
|
||||||
{
|
{
|
||||||
Array<Paint*> paints;
|
Array<Paint*> paints;
|
||||||
RenderMethod* renderer;
|
RenderMethod* renderer;
|
||||||
|
|
||||||
Impl(RenderMethod* pRenderer):renderer(pRenderer)
|
Impl(RenderMethod* pRenderer):renderer(pRenderer)
|
||||||
{
|
{
|
||||||
|
@ -49,7 +49,7 @@ struct Canvas::Impl
|
||||||
if (!p) return Result::MemoryCorruption;
|
if (!p) return Result::MemoryCorruption;
|
||||||
paints.push(p);
|
paints.push(p);
|
||||||
|
|
||||||
return update(p);
|
return update(p, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result clear(bool free)
|
Result clear(bool free)
|
||||||
|
@ -72,19 +72,20 @@ struct Canvas::Impl
|
||||||
return Result::Success;
|
return Result::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result update(Paint* paint)
|
Result update(Paint* paint, bool force)
|
||||||
{
|
{
|
||||||
if (!renderer) return Result::InsufficientCondition;
|
if (!renderer) return Result::InsufficientCondition;
|
||||||
|
|
||||||
Array<RenderData> clips;
|
Array<RenderData> clips;
|
||||||
|
auto flag = force ? RenderUpdateFlag::All : RenderUpdateFlag::None;
|
||||||
|
|
||||||
//Update single paint node
|
//Update single paint node
|
||||||
if (paint) {
|
if (paint) {
|
||||||
paint->pImpl->update(*renderer, nullptr, 255, clips, RenderUpdateFlag::None);
|
paint->pImpl->update(*renderer, nullptr, 255, clips, flag);
|
||||||
//Update all retained paint nodes
|
//Update all retained paint nodes
|
||||||
} else {
|
} else {
|
||||||
for (auto paint = paints.data; paint < (paints.data + paints.count); ++paint) {
|
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;
|
return Result::Success;
|
||||||
|
|
|
@ -49,13 +49,14 @@ struct Picture::Impl
|
||||||
if (paint) {
|
if (paint) {
|
||||||
paint->pImpl->dispose(renderer);
|
paint->pImpl->dispose(renderer);
|
||||||
delete(paint);
|
delete(paint);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (pixels) {
|
else if (pixels) {
|
||||||
return renderer.dispose(rdata);
|
auto ret = renderer.dispose(rdata);
|
||||||
|
rdata = nullptr;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void resize()
|
void resize()
|
||||||
|
|
|
@ -215,7 +215,9 @@ struct Shape::Impl
|
||||||
|
|
||||||
bool dispose(RenderMethod& renderer)
|
bool dispose(RenderMethod& renderer)
|
||||||
{
|
{
|
||||||
return renderer.dispose(rdata);
|
auto ret = renderer.dispose(rdata);
|
||||||
|
rdata = nullptr;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool render(RenderMethod& renderer)
|
bool render(RenderMethod& renderer)
|
||||||
|
|
Loading…
Add table
Reference in a new issue