From ec30301aec53b74cb6e939ead5ad1b93e78bc9c6 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Tue, 27 Jun 2023 18:31:43 +0900 Subject: [PATCH] common shape: +tiny opimization. don't update a frame, if the color is not changed. --- src/lib/tvgShape.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/lib/tvgShape.cpp b/src/lib/tvgShape.cpp index 251a9d26..2d89bdc4 100644 --- a/src/lib/tvgShape.cpp +++ b/src/lib/tvgShape.cpp @@ -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 { - 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) { delete(pImpl->rs.fill); pImpl->rs.fill = nullptr; 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; }