mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
common shape: +tiny opimization.
don't update a frame, if the color is not changed.
This commit is contained in:
parent
dce14a8449
commit
ec30301aec
1 changed files with 8 additions and 6 deletions
|
@ -244,18 +244,20 @@ Result Shape::appendRect(float x, float y, float w, float h, float rx, float ry)
|
||||||
|
|
||||||
Result Shape::fill(uint8_t r, uint8_t g, uint8_t b, uint8_t a) noexcept
|
Result Shape::fill(uint8_t r, uint8_t g, uint8_t b, uint8_t a) noexcept
|
||||||
{
|
{
|
||||||
pImpl->rs.color[0] = r;
|
|
||||||
pImpl->rs.color[1] = g;
|
|
||||||
pImpl->rs.color[2] = b;
|
|
||||||
pImpl->rs.color[3] = a;
|
|
||||||
pImpl->flag |= RenderUpdateFlag::Color;
|
|
||||||
|
|
||||||
if (pImpl->rs.fill) {
|
if (pImpl->rs.fill) {
|
||||||
delete(pImpl->rs.fill);
|
delete(pImpl->rs.fill);
|
||||||
pImpl->rs.fill = nullptr;
|
pImpl->rs.fill = nullptr;
|
||||||
pImpl->flag |= RenderUpdateFlag::Gradient;
|
pImpl->flag |= RenderUpdateFlag::Gradient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (r == pImpl->rs.color[0] && g == pImpl->rs.color[1] && b == pImpl->rs.color[2] && a == pImpl->rs.color[3]) return Result::Success;
|
||||||
|
|
||||||
|
pImpl->rs.color[0] = r;
|
||||||
|
pImpl->rs.color[1] = g;
|
||||||
|
pImpl->rs.color[2] = b;
|
||||||
|
pImpl->rs.color[3] = a;
|
||||||
|
pImpl->flag |= RenderUpdateFlag::Color;
|
||||||
|
|
||||||
return Result::Success;
|
return Result::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue