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:
Hermet Park 2024-02-05 17:12:38 +09:00 committed by Hermet Park
parent f03a3a87ff
commit 9e69089524
2 changed files with 2 additions and 11 deletions

View file

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

View file

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