mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
renderer/canvas: Optimize logic by removing paint verification.
Allow direct updates to the paint object without prior validation. The verification process is deemed inefficient; users are expected to ensure the paint is updated using a canvas that contains it. This might break the backward compatibility.
This commit is contained in:
parent
f03a3a87ff
commit
9e69089524
2 changed files with 2 additions and 11 deletions
|
@ -96,17 +96,8 @@ struct Canvas::Impl
|
||||||
auto flag = RenderUpdateFlag::None;
|
auto flag = RenderUpdateFlag::None;
|
||||||
if (refresh || force) flag = RenderUpdateFlag::All;
|
if (refresh || force) flag = RenderUpdateFlag::All;
|
||||||
|
|
||||||
//Update single paint node
|
|
||||||
if (paint) {
|
if (paint) {
|
||||||
//TODO: Leave this for backward compatibility. Remove this when 1.0 out.
|
paint->pImpl->update(renderer, nullptr, clips, 255, flag);
|
||||||
for (auto paint2 : paints) {
|
|
||||||
if (paint2 == paint) {
|
|
||||||
paint->pImpl->update(renderer, nullptr, clips, 255, flag);
|
|
||||||
return Result::Success;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Result::InvalidArguments;
|
|
||||||
//Update all retained paint nodes
|
|
||||||
} else {
|
} else {
|
||||||
for (auto paint : paints) {
|
for (auto paint : paints) {
|
||||||
paint->pImpl->update(renderer, nullptr, clips, 255, flag);
|
paint->pImpl->update(renderer, nullptr, clips, 255, flag);
|
||||||
|
|
|
@ -160,7 +160,7 @@ TEST_CASE("Update", "[tvgSwCanvasBase]")
|
||||||
|
|
||||||
//No pushed shape
|
//No pushed shape
|
||||||
auto shape = Shape::gen();
|
auto shape = Shape::gen();
|
||||||
REQUIRE(canvas->update(shape.get()) == Result::InvalidArguments);
|
REQUIRE(canvas->update(shape.get()) == Result::Success);
|
||||||
|
|
||||||
//Normal case
|
//Normal case
|
||||||
auto ptr = shape.get();
|
auto ptr = shape.get();
|
||||||
|
|
Loading…
Add table
Reference in a new issue